fix(coding): rehydrate selected conversation on foreground

This commit is contained in:
inman
2026-09-03 10:45:12 +08:00
parent 301c1496b0
commit 7aa118b2d3
6 changed files with 437 additions and 20 deletions

View File

@@ -0,0 +1,107 @@
# Task: Diagnose recurring Coding session stall
## Identity
- Task ID: 20260903-diagnose-recurring-stall-a83f5c21
- Mode: Feature
- Branch: codex/20260903-diagnose-recurring-stall-a83f5c21-diagnose-recurring-stall
- Worktree: /Users/inmanx/Documents/makelore-diagnose-recurring-stall-a83f5c21
- Base commit: 301c1496b0a3a1af3b9443a68a67de8dfea45749
- Owner: codex
- Status: Completed
## Scope
- Diagnose the recurring visible `处理中` state in the installed macOS app for
project `肉鸽2.0`, including the active Pi logical thread that began around
09:51 on 2026-09-03.
- Verify whether the installed artifact actually contains the previously integrated
terminal-settlement and Bash tool-bridge fixes.
- Correlate the screenshot with the installed Main log, persisted Conversation/Pi
session, target process state, and any active tool child before deciding whether
this is useful work, a tool wait, a Provider failure, or another settlement gap.
## Intent And Constraints
- Keep diagnosis-time live inspection read-only: do not abort the target run,
replay the accepted prompt, or mutate user project/session data. For the user's
later explicit launch request, replace the old installed process only by a
graceful quit after confirming the target had no remaining runtime/tool child;
do not force-kill it.
- Preserve ADR-006 target-only failure and no-replay semantics.
- Do not touch the occupied `main` worktree or its uncommitted packaging changes;
perform any source change only in this isolated worktree after evidence identifies
a concrete defect.
## Outcome
- Confirmed that this recurrence was not an active model or Bash wait. The target
Pi JSONL persisted an assistant terminal entry with `stopReason: "aborted"`
and `errorMessage: "Request was aborted"` at 09:52:24 local time. Electron
Main then completed the same Conversation with the intentional
`project_deactivated` reason at 09:52:33. The remaining Agent Server was idle
at 0% CPU with no tool child or network socket while Renderer still showed
`处理中`.
- Confirmed the installed app already contains the earlier Bash write-lease and
bounded terminal-settlement corrections. This incident instead repeated the
foreground recovery gap documented by task
`20260902-check-session-after-bash-fix-a6d12f39`: Renderer retained a cached
`live` Snapshot after Main had stopped the target, and selecting an already
selected Conversation skipped authoritative Snapshot hydration.
- Changed Conversation selection to always reconcile with Main. Existing live
state refreshes silently, while cold and invalidated targets keep their prior
loading/recovery behavior. Accepted or uncertain mutations are not replayed.
- Coding Chat now closes its old event stream on Main's `lifecycle:sleep`,
refreshes the selected Conversation when the window becomes visible or focused,
and refreshes a still-selected Conversation once when the programming view is
mounted or its project context changes. A project/Conversation selection key
prevents duplicate hydration caused by the selection render itself.
- Added store, Renderer, and Electron regressions that begin with a stale running
Snapshot and verify that foreground recovery displays the persisted aborted
terminal state without posting a prompt.
## Verification
- Correlated screenshot time, installed Main log, project registry, Conversation
metadata, target Pi JSONL, and live PID/process/socket state. The durable turn
ended before the visible timer continued; no running tool process remained.
- Installed `app.asar` contains `state_probe`, the bounded terminal-settlement
failure string, and `PROMPT_FAILED_AFTER_ACCEPTANCE`, confirming the prior fix
was packaged in the inspected app.
- Focused Vitest: `45 passed` across
`coding-conversations-store.test.tsx` and `coding-chat-panel.test.tsx`.
- Full Vitest: `1736 passed`, `3 skipped` across 213 test files, including the
single-worker pressure suite.
- Focused Electron E2E:
`foreground focus rehydrates a terminal Snapshot after lifecycle sleep` passed.
- TypeScript `tsc --noEmit`, scoped ESLint, production `build:vite`, and
`git diff --check` passed. Full `lint:check` passed with five pre-existing
warnings and zero errors.
- `check_project_docs.py` and task-aware `check_doc_drift.py` passed.
- The old installed app was gracefully quit after confirming no target Agent
Server or tool child remained. `pnpm run dev` then started the repaired
worktree successfully, with the Renderer on port 5173 and Electron using the
existing Makelore user-data directory.
## Follow-ups
- Integrate this feature branch after the occupied `main` packaging worktree is
available, then rebuild/reinstall the macOS artifact. The currently installed
`/Applications/Makelore.app` remains the older build; the repaired behavior is
available from this task worktree for development verification.
## Promotion Candidates
- Target: `README.md`, `20-architecture/data-flow.md`, and
`30-worklog/current-state.md` during Integration Mode.
Proposal: record the Renderer foreground rehydration contract: lifecycle sleep
closes the old Coding event stream, and view mount, project reselection,
visibility, or focus reconciles the selected Conversation from a Main-owned
Snapshot without replaying accepted mutations.
Evidence: focused store/Renderer tests, real IPC Electron E2E, and the two
installed-app stale-running incidents documented by this task and
`20260902-check-session-after-bash-fix-a6d12f39`.
Future impact: any new Coding navigation or lifecycle surface must preserve the
same terminal-state reconciliation and no-replay behavior.
Human confirmation: not required; this promotes implemented behavior without
changing ADR-006 ownership or product direction.