fix: treat drag-and-dropped absolute file paths as @-mentions instead of Unknown command#1580
fix: treat drag-and-dropped absolute file paths as @-mentions instead of Unknown command#1580jieshu666 wants to merge 10 commits into
Conversation
…duce flicker on slow terminals
… of Unknown command
There was a problem hiding this comment.
Code Review
This pull request introduces support for monthly and yearly automation schedules, including RRULE parsing, validation, and next-run calculation logic. It also implements a convenience feature that converts absolute file paths into @-mentions and removes redundant terminal flush calls. Review feedback highlights that the recurrence logic for monthly and yearly schedules currently uses clamping for invalid dates (e.g., the 31st of a 30-day month), which deviates from the RFC 5545 standard of skipping such occurrences. Furthermore, it is suggested to quote file paths containing spaces when converting them to @-mentions to ensure reliable parsing.
| let max_day = days_in_month(target_year, target_month); | ||
| let day = (*bymonthday).min(max_day); |
There was a problem hiding this comment.
The implementation of Monthly schedules uses clamping (min(max_day)) when the specified bymonthday exceeds the number of days in a month (e.g., day 31 in April). According to the RRULE specification (RFC 5545), such occurrences should be skipped unless otherwise specified. Clamping to the last day of the month is non-standard behavior for RRULE-based schedulers.
References
- Ensure appropriate handling of invalid inputs or states in all cases, following established standards like RFC 5545 for recurrence rules.
| let max_day = days_in_month(target_year, *bymonth); | ||
| let day = (*bymonthday).min(max_day); |
There was a problem hiding this comment.
Similar to the Monthly schedule, the Yearly schedule should skip occurrences where the BYMONTHDAY does not exist in the target month (e.g., February 30th), rather than clamping to the last day of the month, to remain compliant with the RRULE specification.
References
- Follow established standards for recurrence logic to ensure predictable behavior across different calendar months.
| if cmd.trim().starts_with('/') && command.contains('/') { | ||
| return CommandResult::action(AppAction::SendMessage(format!( | ||
| "@{}", | ||
| cmd.trim() | ||
| ))); |
There was a problem hiding this comment.
The path detection logic prepends @ to the trimmed input. If the absolute path contains spaces (e.g., /tmp/my documents/note.txt), the resulting message @/tmp/my documents/note.txt might not be correctly parsed by the @-mention system if it expects paths with spaces to be quoted. Wrapping the path in quotes when spaces are detected ensures reliable parsing by the file-mention system.
References
- Ensure that invalid inputs or states (like paths with spaces) are safely handled in all cases.
|
Thanks for the repro and tests. The absolute slash-path issue is already fixed on current main by the shared composer slash-command classifier, and #1568 is closed. I am closing this PR because it is now superseded and also carries unrelated automation/UI changes that we should not merge into the patch release. |
Problem
When a user drags a file from Finder on macOS, the terminal inserts the absolute path (e.g. /Users/name/file.txt). The leading / caused the command dispatcher to treat it as a slash command,
resulting in:
Root Cause
In commands::execute, all input starting with / is unconditionally routed to the slash-command match arms. Absolute file paths (/Users/...) start with / but contain path separators — unlike
real slash commands (/help, /model, /clear), which are single words.
Solution
In the unknown-command fallthrough arm (_), after skill matching fails and before returning "Unknown command", check whether the input looks like a filesystem path:
If both conditions are met, convert the input to an @-mention and send it as a message via AppAction::SendMessage. The existing file-mention system then resolves @/path/to/file and attaches the
file content to the model request.
Changes
crates/tui/src/commands/mod.rs: Added path-detection logic in the _ fallthrough arm of execute() (+11 lines). When the input looks like an absolute file path, it returnsAppAction::SendMessage("@").