Skip to content

[bugfix] canvas: reopen the asset picker after leaving a dismissed @ (#394) - #400

Open
Birfy wants to merge 1 commit into
ThinkFlowLab:mainfrom
Birfy:fix/394-reference-picker-reopen
Open

Birfy wants to merge 1 commit into
ThinkFlowLab:mainfrom
Birfy:fix/394-reference-picker-reopen

Conversation

@Birfy

@Birfy Birfy commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

After Escape dismissed the project-asset picker at the @ in 前@后, moving the caret out and back could leave the picker closed (aria-expanded=false) while the editor was still focused on that mention.

close() keeps the dismissed mention start so Escape without motion stays closed. The selection-change path already cleared that dismissal when it saw an outside caret, but a rapid 2 → 3 → 2 move can be delivered only at the final offset. The previous saved-equality guard then skipped updateMention, so the leave was never observed.

This change records a leave on caret-navigation keydown. mentionDismissAfterEvent reopens when the caret returns to the same mention after that leave, including when selectionchange never reports the outside position. Escape without motion is unchanged.

Linked issue

Labels

  • Labels requested (type:bug, area:assets, area:canvas); this account could not apply them when opening the PR

Test plan

Local (Linux, Node v24.22.1, tip f125756c on origin/main 58b6a96d, Asia/Shanghai). Isolated fixture only; no user project and no paid generation.

The nightly failure was reported on 4360d9eb (reference_picker.mjs timed out 15s waiting for “引用项目资产” after Escape, right, then left; caret 2, aria-expanded=false). That editor path has not changed since that revision. This environment did not independently reproduce a hang on a fully synchronized ArrowRight / wait / ArrowLeft sequence; the fix targets the coalesced leave described in the issue, not a timeout increase.

node --test tests/referenceMentions.test.ts
# 8 passed, including “a dismissed mention stays closed until the caret leaves and returns”
# - Escape-equivalent: same mention, no leave → stays closed
# - observed leave (mentionStart null) then return → opens
# - coalesced leave (leftSinceDismiss=true, still on the mention) → opens

npx tsc --noEmit
# clean

npm test
# 838 passed, 1 failed: tests/browserHost.test.ts “installed server env … ambient Node PATH”
# (asserts PATH’s node is null; this box has /usr/bin/node). Same failure is present on origin/main in this environment and is unrelated to this change.

npm run check:i18n
# i18n: 3036 keys, 0 problem(s), 165 Chinese source lines (baseline 168)

Browser verification against the official script, including a new rapid leave/re-enter after Escape (no intermediate wait for the outside caret):

# Isolated creation_server.py on 8019; Vite on 5179 with OPENDIRECTOR_API_URL=http://127.0.0.1:8019
CREATION_WEB_URL=http://127.0.0.1:5179 CREATION_API_URL=http://127.0.0.1:8019 \
PLAYWRIGHT_MODULE=/tmp/od-pw/node_modules/playwright-core/index.mjs \
CHROMIUM_PATH=/home/box/.cache/ms-playwright/chromium-1248/chrome-linux64/chrome \
BROWSER=chromium \
node tests/browser/reference_picker.mjs
# {"isolated":true,"editors":["图片","视频"],"correctCaretBoundary":true,"pointerDismissal":true,
#  "typedCharacterDismissal":true,"atomicReferences":true,"normalizedLabels":true,
#  "independentAssetsPreserved":true,"persistedReferences":2,"catalogReadIndependent":true,
#  "catalogReads":1,"liveCanvasChanges":true,"openingCheckMs":[7,36,34,115,10,34,38,32,13,118,13,34],
#  "errors":[]}

The script still covers Escape-without-motion, synchronized leave/re-enter, and the new rapid leave/re-enter on both 图片 and 视频 composers. Python was not re-run; this change is TypeScript editor behavior only.

Left to CI

Official Release checks and the nightly browser-extended lane that originally reported the failure.

Evidence that it works

Provider verification

  • Real-provider calls are described honestly, or none were made

No live or paid provider calls were made.

Bilingual UI

  • Both locales are updated, or no user-facing copy changed

No user-facing strings changed.

…hinkFlowLab#394)

Escape still keeps the picker closed while the caret stays on the same
mention. A navigation key records that the caret has left, so a later
return reopens even when selectionchange never reports the outside position.
@github-actions github-actions Bot added area:assets Assets, library and reference inputs area:canvas Canvas, nodes and direct manipulation type:bug Something is broken labels Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:assets Assets, library and reference inputs area:canvas Canvas, nodes and direct manipulation type:bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] nightly: asset reference picker can stay closed when caret re-enters @ after Escape

1 participant