Skip to content

Fix project chat plan persistence#1546

Merged
simple-agent-manager[bot] merged 4 commits into
mainfrom
sam/fix-plan-persistence-project-w6yv5c
Jul 8, 2026
Merged

Fix project chat plan persistence#1546
simple-agent-manager[bot] merged 4 commits into
mainfrom
sam/fix-plan-persistence-project-w6yv5c

Conversation

@simple-agent-manager

@simple-agent-manager simple-agent-manager Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Recover project chat plans from durable role='plan' messages via the shared chat-agent state resolver.
  • Include plan identity in fallback poll fingerprints and hydrate plan state unconditionally, including lightweight activity verification responses.
  • Keep the CompletionDock plan pill visible when activity transitions to idle, with subdued idle styling.

Validation

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • Additional validation run: targeted API/web regressions, pnpm build, and Playwright visual audit at 375px and 1280px.
  • If this PR changes candidate selection for a sweep/cron/alarm loop (WHERE clause, status set, join, or equivalent), expected candidate volume and worst-case per-candidate cost are stated in the summary or validation notes (see .claude/rules/47-control-loop-io-budget.md). N/A: no sweep/cron/alarm loop candidate selection change.

Staging Verification (REQUIRED for all code changes — merge-blocking)

All checkboxes below are mandatory for any PR that changes runtime code (.ts, .tsx, .go, etc.). Write N/A: docs-only ONLY if the PR contains zero runtime code changes. See .claude/rules/13-staging-verification.md.

  • Staging deployment green — Skipped by explicit human-approved exception from Raphaël for this PR.
  • Live app verified via Playwright — Skipped by explicit human-approved exception from Raphaël for this PR.
  • Existing workflows confirmed working — Skipped by explicit human-approved exception from Raphaël for this PR.
  • New feature/fix verified on staging — Skipped by explicit human-approved exception from Raphaël for this PR.
  • Infrastructure verification completed — N/A: no infra changes.
  • Mobile and desktop verification notes added for UI changes.

Staging Verification Evidence

Human-approved exception: Raphaël explicitly authorized skipping the staging deployment gate for this PR. Local quality gates, targeted regression tests, full test/build gates, Playwright visual audit, and local specialist reviews passed. Per the exception, this PR should merge directly to main after CI passes, then Deploy Production must be monitored to completion and the fix verified on production.

UI Compliance Checklist (Required for UI changes)

  • Mobile-first layout verified
  • Accessibility checks completed
  • Shared UI components used or exception documented
  • Playwright visual audit run locally — mock data scenarios tested at mobile (375x667) and desktop (1280x800); no horizontal overflow; screenshots in .codex/tmp/playwright-screenshots/.

End-to-End Verification (Required for multi-component changes)

  • Data flow traced from user input to final outcome with code path citations (see .claude/rules/10-e2e-verification.md)
  • Capability test exercises the complete happy path across system boundaries
  • All spec/doc assumptions about existing behavior verified against code (not just "read the code")
  • If any gap exists between automated test coverage and full E2E, manual verification steps documented below

Data Flow Trace

Persisted plan rows are read by getLatestPersistedPlan() in apps/api/src/durable-objects/project-data/session-state.ts, exposed through ProjectData.getLatestPersistedPlan() and projectDataService.getLatestPersistedPlan(), then overlaid by resolveChatAgentState() in apps/api/src/routes/chat-agent-state.ts. The full chat detail route in apps/api/src/routes/chat.ts and lightweight state route both use that resolver. The web poll in apps/web/src/components/project-message-view/useSessionLifecycle.ts includes plan identity in the fingerprint and hydrates currentPlan; useActivityVerifyTimer.ts also forwards state snapshots; CompletionDock.tsx renders the plan pill whenever hasPlan is true.

Untested Gaps

The Durable Object worker regression test exists in apps/api/tests/workers/project-data-do.test.ts, but local pnpm --filter @simple-agent-manager/api test:workers -- tests/workers/project-data-do.test.ts could not complete because workerd repeatedly crashed with SIGSEGV during runtime startup in this environment. Covered locally by resolver/unit tests, full pnpm test, and Playwright visual audit.

Post-Mortem (Required for bug fix PRs)

What broke

Plans were durably persisted but project chat did not reliably show them after missed WebSocket broadcasts, reloads with stale state mirrors, or false-idle activity transitions.

Root cause

PR #1487 changed the poll fingerprint without including plan identity, so plan-only updates skipped hydration. Existing hydration only used truthy session_state.currentPlan and never reconstructed from durable role='plan' messages. The CompletionDock also hid the plan pill behind working && hasPlan.

Class of bug

Client-state recovery gap across WebSocket, fallback polling, and cached durable state mirrors.

Why it wasn't caught

Tests covered activity/message changes but not plan-only state changes, stale/missing plan mirrors, or idle plan-pill persistence.

Process fix included in this PR

Regression tests were added for plan-only poll rehydration, state-endpoint plan hydration, reload recovery from durable plan rows, and idle plan-pill visibility. No shared process documentation file was changed.

Post-mortem file

tasks/archive/2026-07-08-fix-plan-persistence-project-chat.md

Specialist Review Evidence (Required for agent-authored PRs)

  • All local reviewers completed and findings addressed before merge
  • If any reviewer did NOT complete: needs-human-review label added and merge deferred to human
Reviewer Status Outcome
task-completion-validator PASS Checklist, acceptance criteria, diff, and tests align; worker-pool caveat documented.
ui-ux-specialist PASS Always-visible idle plan pill selected; 375px and 1280px Playwright audit passed no-overflow checks.
cloudflare-specialist PASS DO helper uses parameterized SQLite query and no migration/config changes; local worker runtime SIGSEGV caveat documented.
test-engineer PASS Added targeted API/web/unit, worker DO, and Playwright coverage; full pnpm test passed.

Exceptions (If any)

  • Scope: Staging deployment and live staging verification for PR Fix project chat plan persistence #1546.
  • Rationale: Raphaël explicitly authorized skipping the staging deployment gate for this PR.
  • Expiration: This PR only; production deploy monitoring and production verification remain required after merge.

Agent Preflight (Required)

  • Preflight completed before code changes

Classification

  • external-api-change
  • cross-component-change
  • business-logic-change
  • public-surface-change
  • docs-sync-change
  • security-sensitive-change
  • ui-change
  • infra-change

External References

N/A: no external API or third-party documentation was needed; work was based on the supplied root-cause analysis and local repository code.

Codebase Impact Analysis

Affected paths: apps/api/src/durable-objects/project-data/*, apps/api/src/routes/chat-agent-state.ts, apps/api/src/services/project-data.ts, apps/web/src/components/project-message-view/*, API/web unit tests, and apps/web/tests/playwright/completion-dock-audit.spec.ts.

Documentation & Specs

N/A: no public docs or specs required updates; this is an internal bug fix with task evidence archived in tasks/archive/2026-07-08-fix-plan-persistence-project-chat.md.

Constitution & Risk Check

Checked no-hardcoded-values and test-coverage expectations. The only added fixed values are test fixtures and a cheap local hash for plan fingerprinting; runtime behavior uses existing API/state contracts. Primary risks were stale cached state, plan clearing, and UI idle visibility, all covered by targeted regressions and Playwright audit.

@codspeed-hq

codspeed-hq Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing sam/fix-plan-persistence-project-w6yv5c (a5c9038) with main (3107069)

Open in CodSpeed

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

@simple-agent-manager simple-agent-manager Bot merged commit b982381 into main Jul 8, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant