Repository navigation
fix(session-ui): insert dropped file mentions after the first one - #49185
deepakajay0477 wants to merge 1 commit into
Conversation
addMention() searched the whole prompt for the last "@" before the cursor. Once the prompt contained a mention, that search landed on the existing mention's "@" and insertMention() could not replace a range that spans a mention part, so every drop after the first silently inserted nothing. The search is now scoped to the text part at the cursor and insertMention() always inserts.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Extra regression sweep before rolling this out locally:
|
Why this mattersv2 prompt input silently ignores file drops after the first EvidenceTip
Confirms scope — restore v1 caret-anchored behavior. Happy to help land as-is. Ask (design, light) — prospective
|
|
Thanks for the review, I was hit with this bug, I asked DeepSeek v4.1 f to fix it in a sandbox, I tested it several times, I don't know anything deeper ,and the bug was fixed, I hope it helps everyone, I am leaving it to the maintainers hoping it will come as an update, thank you. |
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
Issue for this PR
Closes #39705
Type of change
What does this PR do?
In the v2 prompt input, dropping files from the file tree inserts
@pathmentions. The first drop works, but every later drop is silently ignored once the prompt already contains a mention.Root cause is in
packages/session-ui/src/v2/components/prompt-input/store.ts.addMention()searched the entire prompt for the last@before the cursor (text.slice(0, end).lastIndexOf("@")) and replaced that range viainsertMention(). After the first drop, the last@is the start of the existing mention.insertMention()only rewrites text parts fully covered by the range, so the replacement produced no change and no error. The v1 prompt input inserted at the caret with an anchored/@(\S*)$/check, which is why it never had this bug.Changes:
addMention()now finds the replace range with a newmentionQueryStart()helper: it looks only inside the text part containing the cursor and only matches an in-progress query anchored at the cursor (/@(\S*)$/). When there is no such query, it inserts at the cursor.insertMention()is hardened: it clamps ranges that partially overlap a text part and falls back to appending the mention with a trailing space, so it can no longer silently no-op.Typed
@completion keeps the same behavior (the typed query is still replaced by the selected mention).How did you verify your code works?
bun test src/v2/components/prompt-input/store.test.tsinpackages/session-ui: 8 pass. Added 3 regression tests; with the fix reverted, 2 of them fail ("adds another mention when the prompt already contains one", "appends a mention when the cursor follows a trailing mention").bun run typecheckinpackages/session-uipasses.Screenshots / recordings
Not a visual change; behavior fix in mention insertion.
Checklist