fix(web): file-chip first-click jump#67
Merged
Merged
Conversation
Scott reported first click on a thread file-chip often does not jump to the ref viewer; second click works. Root causes: 1. Chips relied entirely on the browser firing hashchange. When the current hash already equals the chip href (e.g. after closing the viewer and clicking the same chip again), hashchange does NOT fire, so routeFromHash never runs. 2. Unresolved [[ref:xxx]] tokens render as <span class=file-chip-missing> with no href; a background refresh repaints them ~150ms later, but the very first user click hits the dead span. Fix: capture-phase document click listener for .file-chip / .file-chip-ref / .file-chip-missing — preventDefault and either set the hash or call routeFromHash directly when hash is already on target. For missing chips, await a forced loadRefIndex(true) and retry resolve before toasting. No behavior change for Cmd/Ctrl/Shift-click (preserves new-tab etc.) and for star (.file-chip-fav) clicks (existing handler still wins).
🤖 bot-review (comment-only · phase 1)Diff: Red-line checks:
Phase 1: this bot leaves comments only. Auto-approve will be enabled per-path after 1–2 weeks of clean runs. Promotion plan: judy PR #42 follow-up. |
Scott 2026-06-09: typo like @name produced a red 'Unknown agent id' failure chip. Filter unknown ids at the router (forge_employees.is_employee) so misspelled mentions are dropped silently instead of dispatching a worker that's guaranteed to fail. - post_router.enqueue_if_needed: after self-/reserved-mention dedupe, drop any key for which is_employee() is False. Defensive try/except falls back to dispatch on registry errors. - tests/conftest.py + test_post_router.py: router fixture now stubs is_employee=True so existing synthetic-id tests still cover dispatch; added two new tests for the drop path (mixed known+unknown, and all unknown -> False). Test: pytest -q (all green).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scott 反馈:thread 里第一次点 file-chip 经常跳转失败,第二次才行。
根因
hashchange来触发routeFromHash。当location.hash已经等于 chip 的href(例如从 viewer 返回 thread 后再点同一个 chip),hashchange根本不 fire → 路由不跑 → chip 看上去像死的。[[ref:xxx]]渲染成<span class=file-chip-missing>(没有 href),scheduleRefIndexRefresh大概 150ms 后才重绘成<a>,第一次点正好命中那个死 span。修法
document上挂一个 capture-phase click 委托:.file-chip-ref/.file-chip/.file-chip-missing→preventDefault。window.__forgeRouteFromHash()强制走路由。await loadRefIndex(true)强刷一遍 refs,再resolveChipFromRefs(target);命中就跳,不命中 toast 提示。Cmd/Ctrl/Shift-click(新标签页等浏览器默认)和.file-chip-fav(⭐ 收藏按钮)原有行为。验证(请 scott 拉一下 main 上 rebase 后试)
[[ref:xxx]](灰色Cmd+clickchip → 浏览器照常处理(新标签语义保留)。