Skip to content

fix: treat drag-and-dropped absolute file paths as @-mentions instead of Unknown command#1580

Closed
jieshu666 wants to merge 10 commits into
Hmbown:mainfrom
jieshu666:fix/drag-file-path-as-command
Closed

fix: treat drag-and-dropped absolute file paths as @-mentions instead of Unknown command#1580
jieshu666 wants to merge 10 commits into
Hmbown:mainfrom
jieshu666:fix/drag-file-path-as-command

Conversation

@jieshu666

Copy link
Copy Markdown
Contributor

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:

Error: Unknown command: /users/machunhong1/documents/agent. Type /help for available commands.

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:

  • The original input starts with /
  • The command name (after stripping the leading /) still contains a / separator

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 returns
    AppAction::SendMessage("@").
  • Tests: Added 3 new unit tests (+51 lines):
  • absolute_path_input_converts_to_file_mention — /Users/test/project/README.md produces SendMessage
  • absolute_path_with_spaces_converts_to_file_mention — /tmp/my documents/note.txt works with spaces
  • non_path_single_word_after_slash_still_unknown_command — /nonesuch still gets "Unknown command"

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +385 to +386
let max_day = days_in_month(target_year, target_month);
let day = (*bymonthday).min(max_day);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. Ensure appropriate handling of invalid inputs or states in all cases, following established standards like RFC 5545 for recurrence rules.

Comment on lines +413 to +414
let max_day = days_in_month(target_year, *bymonth);
let day = (*bymonthday).min(max_day);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. Follow established standards for recurrence logic to ensure predictable behavior across different calendar months.

Comment thread crates/tui/src/commands/mod.rs Outdated
Comment on lines +651 to +655
if cmd.trim().starts_with('/') && command.contains('/') {
return CommandResult::action(AppAction::SendMessage(format!(
"@{}",
cmd.trim()
)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. Ensure that invalid inputs or states (like paths with spaces) are safely handled in all cases.

@Hmbown

Hmbown commented May 14, 2026

Copy link
Copy Markdown
Owner

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.

@Hmbown Hmbown closed this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants