状态:已由 V4 find 链路实现,本文保留为历史实施计划。 当前行为见 Task Find Dialog,当前代码入口是
packages/ui/src/v4/useConversationTimelineFind.ts与packages/ui/src/quickpick/TaskFindDialog.tsx; 下文ChatView/useConversationFindHighlights路径已删除。For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Allow repeated previous/next/Enter/Shift+Enter navigation to re-center a single search match in both conversation content and file-change diffs.
Architecture: Keep query and active index as selection state, and add independent monotonically increasing navigation request ids for conversation and file-change scopes. Explicit navigation events increment the appropriate id; useConversationFindHighlights includes the id in its effect and scroll dedupe key, while GitPane also re-runs virtual-row positioning for a repeated file-change request.
Tech Stack: React 19, TypeScript, Vitest, Electron/WebdriverIO E2E.
desktop-continuous and mobile web-remote-replayable boundaries; navigation ids remain renderer-local.@/ imports and Chinese bug-cause comments.pnpm --filter @zcode/desktop typecheck:e2e, pnpm typecheck, and pnpm lint before completion.Files:
packages/ui/test/conversationFindSearch.test.tsInterfaces:
Produces: failing proof that repeated navigation must create a distinct scroll request even when the index stays 0.
[x] Step 1: Write the failing navigation test
Assert previous, next, Enter, and Shift+Enter resolve to the shared directions, and that a single match wraps to index 0 for both directions while still producing a navigation request.
Assert the highlight scroll key changes when only navigationRequestId changes. The repository Vitest environment does not include jsdom, so this pure test keeps the RED focused on the missing behavior instead of failing on an unavailable test environment.
Run:
pnpm exec vitest run packages/ui/test/conversationFindSearch.test.ts
Expected: FAIL because TaskFindDialog has no explicit navigation callbacks and the highlight hook has no navigation request id.
Files:
packages/ui/src/App.tsxpackages/ui/src/quickpick/TaskFindDialog.tsxpackages/ui/src/ChatView/useConversationFindHighlights.tspackages/ui/src/ChatView/ChatViewConversation.tsxpackages/ui/src/ChatView.tsxpackages/ui/src/ChatView/types.tspackages/ui/src/GitPane.tsxpackages/ui/src/app-shell/types.tspackages/ui/src/app-shell/WorkspaceShellLayout.tsxpackages/ui/src/app-shell/AnimatedSidePanePanel.tsxInterfaces:
conversationFindNavigationRequestId: number, fileChangeFindNavigationRequestId: number.onConversationFindNavigate(query: string, activeIndex: number) and onFileChangeFindNavigate(query: string, activeIndex: number).Consumes: navigationRequestId?: number in useConversationFindHighlights.
[x] Step 1: Add explicit dialog navigation callbacks
Keep on*FindChange for query/scope synchronization. Route only moveSelection() through the new on*FindNavigate callbacks so buttons and keyboard share one event path.
Use functional updates:
setConversationFindNavigationRequestId((requestId) => requestId + 1);
setFileChangeFindNavigationRequestId((requestId) => requestId + 1);
Each navigation handler also updates query/index. Reset ids is unnecessary because they are transient monotonic counters scoped to the mounted App.
Pass the conversation id through WorkspaceShellLayout -> ChatView -> ChatViewConversation -> useConversationFindHighlights. Pass the file id through WorkspaceShellLayout -> AnimatedSidePanePanel -> GitPane -> useConversationFindHighlights and include it in the Git virtual-row positioning effect dependencies.
Use:
const scrollKey = `${normalizedQuery}:${resolvedActiveIndex}:${ranges.length}:${navigationRequestId}`;
and add navigationRequestId to the effect dependency list. Keep mutation-driven calls deduped within one request id.
Run the Task 1 Vitest command. Expected: all tests pass.
Files:
packages/desktop/test/e2e/conversation-session/presentation/manual-review/pending/conversation-session-chat-find-refocus.test.tsInterfaces:
window.__zcodeSessionStoreE2E bridge.Produces: CFR pending manual-review evidence for catalog CF01; no provider requests.
[x] Step 1: Write the E2E reproduction
Use the WDIO-only Zustand store bridge to create a completed task with one long assistant message containing E2E_CHAT_FIND_REFOCUS_NEEDLE. Open Cmd/Ctrl+F, search the marker, scroll away, then verify next, previous, Enter, and Shift+Enter each return the same marker to the viewport center while the counter remains 1/1.
[x] Step 2: Run the case
ZCODE_E2E_MANUAL_REVIEW=1 pnpm --filter @zcode/desktop test:e2e -- --spec './test/e2e/conversation-session/presentation/manual-review/pending/conversation-session-chat-find-refocus.test.ts'
Expected: PASS after Task 2. The spec stays pending until human review; do not promote it automatically.
Files:
Review all modified files above.
[x] Step 1: Run focused and required verification
pnpm exec vitest run packages/ui/test/conversationFindSearch.test.ts
pnpm --filter @zcode/desktop typecheck:e2e
pnpm typecheck
pnpm lint
git diff --check
[x] Step 2: Review diff and repository state
Confirm no unrelated tracked files or the pre-existing untracked .agents/skills/zcode-rum-crash-triage/ are staged.
[x] Step 3: Commit implementation
git add packages/ui/src packages/ui/test/conversationFindSearch.test.ts packages/ui/test/chatViewConversation.test.ts packages/ui/test/gitPaneVirtualList.test.ts packages/ui/test/linuxDesktopTitlebarOverlay.test.ts packages/desktop/test/e2e/conversation-session/presentation/manual-review/pending/conversation-session-chat-find-refocus.test.ts docs/superpowers/plans/2026-07-10-chat-find-refocus.md
git commit -m "fix(ui): refocus repeated chat find navigation"
Files:
packages/ui/src/quickpick/taskFindNavigationState.tspackages/ui/test/taskFindNavigationState.test.tspackages/ui/src/App.tsxpackages/ui/src/quickpick/conversationFindSearch.tspackages/ui/src/quickpick/TaskFindDialog.tsxpackages/ui/test/conversationFindSearch.test.tspackages/ui/test/taskFindDialogNavigation.test.tsInterfaces:
TaskFindNavigationState with query, activeIndex, and navigationRequestId.changeTaskFindSelection(state, query, activeIndex) that preserves the request id.navigateTaskFindSelection(state, query, activeIndex) that increments the request id even when the index is unchanged.Renames: createConversationFindNavigationRequest to resolveConversationFindNavigationSelection, because the dialog helper does not create the complete request identity.
[x] Step 1: Write failing state-transition and dialog tests
Assert that two consecutive same-index navigations produce request ids 1 and 2, ordinary query/index changes preserve the current id, ArrowUp/ArrowDown enter the real dialog navigate callback, and every keyboard navigation entry is ignored when total === 0.
[x] Step 2: Run tests to verify RED
pnpm exec vitest run packages/ui/test/taskFindNavigationState.test.ts packages/ui/test/taskFindDialogNavigation.test.ts
Expected: FAIL because the App-owned transition helper does not exist, Arrow keys are not covered by the component helper, and zero-match keyboard navigation still invokes on*FindNavigate.
Use two independent TaskFindNavigationState objects in App. Keep match counts separate. Route ordinary change through changeTaskFindSelection, route explicit navigation through navigateTaskFindSelection, and make TaskFindDialog.moveSelection return before creating a request when activeFindState.total === 0.
Run the Task 5 Vitest command. Expected: all tests pass.
Files:
packages/desktop/test/e2e/conversation-session/presentation/manual-review/pending/conversation-session-chat-find-refocus.test.tsdocs/testing/conversation-session-e2e-coverage-matrix.mdInterfaces:
CFR pending case and window.__zcodeSessionStoreE2E conversation injection.Produces: manual-review evidence for both accepted catalog cases CF01 and CF02 without promotion or replay fixture admission.
[x] Step 1: Extend the pending E2E with CF02
Initialize Git in DEFAULT_WORKSPACE, commit an empty baseline plain-text file, then add 1,300 lines with one E2E_FILE_CHANGE_FIND_REFOCUS_NEEDLE near the start so GitPane uses its light-DOM plain-text fallback while retaining a long scroll region. Switch the open find dialog to file-change scope, wait for 1/1, scroll the expanded diff away, and verify previous/next/Enter/Shift+Enter each re-center the same marker.
Keep CF01/CF02 status planned, record that CFR now provides pending manual-review evidence for both scopes, and continue to state that no formal replay fixture, Docker admission, or CI promotion exists.
[x] Step 3: Run the pending case
ZCODE_E2E_MANUAL_REVIEW=1 pnpm --filter @zcode/desktop test:e2e -- --spec './test/e2e/conversation-session/presentation/manual-review/pending/conversation-session-chat-find-refocus.test.ts'
Expected: both conversation and file-change scenarios pass. Keep the spec under manual-review/pending/ until a human explicitly approves promotion.
[x] Step 4: Run final gates and commit
pnpm exec vitest run packages/ui/test/conversationFindSearch.test.ts packages/ui/test/taskFindNavigationState.test.ts packages/ui/test/taskFindDialogNavigation.test.ts packages/ui/test/chatViewConversation.test.ts packages/ui/test/gitPaneVirtualList.test.ts packages/ui/test/linuxDesktopTitlebarOverlay.test.ts
pnpm --filter @zcode/desktop typecheck:e2e
pnpm typecheck
pnpm lint
git diff --check
git add docs/superpowers/plans/2026-07-10-chat-find-refocus.md docs/testing/conversation-session-e2e-coverage-matrix.md packages/ui/src/App.tsx packages/ui/src/quickpick/conversationFindSearch.ts packages/ui/src/quickpick/taskFindNavigationState.ts packages/ui/src/quickpick/TaskFindDialog.tsx packages/ui/test/conversationFindSearch.test.ts packages/ui/test/taskFindNavigationState.test.ts packages/ui/test/taskFindDialogNavigation.test.ts packages/desktop/test/e2e/conversation-session/presentation/manual-review/pending/conversation-session-chat-find-refocus.test.ts
git commit -m "fix(ui): align chat find navigation edge cases"
Files:
packages/ui/test/webRemoteControlMobileShell.test.tspackages/ui/test/workspaceShellRemoteMobileLayout.test.tspackages/ui/src/WebRemoteControlMobileShell.tsxpackages/ui/src/app-shell/WorkspaceShellLayout.tsxInterfaces:
chatOverlay?: ReactNode to WebRemoteControlMobileShell.chatContent inside the existing inert / aria-hidden mobile chat surface.Renders: chatOverlay as a sibling layer with data-mobile-chat-overlay="true", z-40, and pointer events restored for its child content.
[x] Step 1: Write failing mobile DOM and WorkspaceShell integration tests
In webRemoteControlMobileShell.test.ts, pass a real input/button subtree as chatOverlay while isSidePaneOpen=true. Assert the marker is present inside data-mobile-chat-overlay, absent from the serialized <main inert> content, and rendered after the inert main. In workspaceShellRemoteMobileLayout.test.ts, teach only the test double to render a chatOverlay prop, open taskFindDialogProps, and assert the find placeholder is supplied through that prop rather than chatContent.
[x] Step 2: Run the two tests to verify RED
pnpm exec vitest run packages/ui/test/webRemoteControlMobileShell.test.ts packages/ui/test/workspaceShellRemoteMobileLayout.test.ts
Expected: FAIL because WebRemoteControlMobileShell has no chatOverlay slot and WorkspaceShellLayout still places renderChatFindDialog() inside mobile chatContent.
Add the optional prop and render it inside the mobile content wrapper, after the side-pane overlay:
{chatOverlay ? (
<div
className="pointer-events-none absolute inset-0 z-40"
data-mobile-chat-overlay="true"
>
<div className="pointer-events-auto">{chatOverlay}</div>
</div>
) : null}
For the dedicated mobile branch in WorkspaceShellLayout, remove renderChatFindDialog() from chatContent and pass chatOverlay={renderChatFindDialog()} to WebRemoteControlMobileShell. Do not change the desktop conversation-panel render site or weaken mobile inert.
Run the Task 7 Vitest command. Expected: both files pass.
Files:
packages/ui/test/taskFindDialogNavigation.test.tspackages/ui/src/quickpick/TaskFindDialog.tsxInterfaces:
Adds: event.defaultPrevented === true prevents the window listener from closing find.
[x] Step 1: Write failing Escape priority tests
Extend the minimal window event target in taskFindDialogNavigation.test.ts so tests dispatch the real effect-installed keydown handler. Assert a pre-cancelled Escape leaves onOpenChange untouched, while an unhandled Escape calls onOpenChange(false) and becomes default-prevented.
[x] Step 2: Run the dialog test to verify RED
pnpm exec vitest run packages/ui/test/taskFindDialogNavigation.test.ts
Expected: the pre-cancelled Escape test fails because the current window listener closes find without checking defaultPrevented.
[x] Step 3: Add the minimal Escape guard
if (event.defaultPrevented || event.key !== "Escape") {
return;
}
Keep the existing preventDefault() and onOpenChange(false) calls for an unhandled Escape.
Run the Task 8 Vitest command. Expected: all dialog navigation and Escape cases pass.
Files:
docs/conversation-session-case-catalog.mddocs/testing/conversation-session-e2e-coverage-matrix.mdInterfaces:
Preserves: CFR under manual-review/pending; no promotion, replay fixture, Docker admission, or CI claim.
[x] Step 1: Update catalog and matrix scope
State that mobile Web reuses the same navigation behavior but needs a distinct DOM composition assertion because its side pane is an overlay with an inert chat surface. Record component/integration coverage honestly and keep CF01/CF02 planned.
[x] Step 2: Run focused and required verification
pnpm exec vitest run packages/ui/test/webRemoteControlMobileShell.test.ts packages/ui/test/workspaceShellRemoteMobileLayout.test.ts packages/ui/test/taskFindDialogNavigation.test.ts packages/ui/test/taskFindNavigationState.test.ts packages/ui/test/conversationFindSearch.test.ts packages/ui/test/chatViewConversation.test.ts packages/ui/test/gitPaneVirtualList.test.ts
ZCODE_GIT_BINARY=/usr/bin/git ZCODE_E2E_MANUAL_REVIEW=1 pnpm --filter @zcode/desktop test:e2e -- --spec './test/e2e/conversation-session/presentation/manual-review/pending/conversation-session-chat-find-refocus.test.ts'
pnpm --filter @zcode/desktop typecheck:e2e
pnpm typecheck
pnpm lint
git diff --check
Expected: all focused tests and the pending desktop case pass; lint reports zero errors. The desktop pending case remains evidence for desktop scrolling, not a mobile replayable E2E claim.
[x] Step 3: Commit and push the review follow-up
git add packages/ui/src/WebRemoteControlMobileShell.tsx packages/ui/src/app-shell/WorkspaceShellLayout.tsx packages/ui/src/quickpick/TaskFindDialog.tsx packages/ui/test/webRemoteControlMobileShell.test.ts packages/ui/test/workspaceShellRemoteMobileLayout.test.ts packages/ui/test/taskFindDialogNavigation.test.ts docs/conversation-session-case-catalog.md docs/testing/conversation-session-e2e-coverage-matrix.md docs/superpowers/plans/2026-07-10-chat-find-refocus.md
git commit -m "fix(ui): keep mobile task find interactive"
git push