fix(tui): always call input.detect_drop for reliable image attachment

Remove frontend regex pre-check that truncated paths containing spaces,
quotes, or Windows drive letters. Backend _detect_file_drop correctly
handles these patterns. This fixes image attachment for common filenames
like "Screenshot 2026-04-29.png".

Add tests:
- test_input_detect_drop_path_with_spaces: attaches image with spaces in name
- test_input_detect_drop_path_with_spaces_and_remainder: remainder handling

Also restored missing  in test_rollback_restore_resolves_number_and_file_path.

Scope: tui, vision, tests
This commit is contained in:
Harry Riddle 2026-04-29 20:39:52 +07:00 committed by Teknium
parent 19136dfc07
commit cc340c4a4d
2 changed files with 52 additions and 7 deletions

View file

@ -126,13 +126,9 @@ export function useSubmission(opts: UseSubmissionOptions) {
return sys('session not ready yet')
}
// Plain prompts are the common path and should not pay an extra RPC
// before prompt.submit. File-drop detection still runs for absolute,
// tilde, file://, and explicit relative paths.
if (!looksLikeSlashCommand(text) && !/(?:^|\s)(?:file:\/\/|~\/|\.?\.\/|\/)[^\s]+/.test(text)) {
return startSubmit(text, expand(text), showUserMessage)
}
// Always ask the backend whether this looks like a file drop.
// The backend's _detect_file_drop handles paths with spaces, quotes,
// Windows drive letters, and escaped characters correctly.
gw.request<InputDetectDropResponse>('input.detect_drop', { session_id: sid, text })
.then(r => {
if (!r?.matched) {