fix(app): stabilize todo dock visibility#381
Conversation
📝 WalkthroughWalkthroughThis PR introduces fallback session todo selection and improves session-transition handling in the todo dock. A new ChangesSession Todo Selection with Fallback
Sequence DiagramsequenceDiagram
participant User
participant SessionPage as Session Page
participant ComposerState as Composer State
participant SelectTodos as selectSessionTodos
participant StatusSummary as Status Summary
participant Backend as Backend/Messages
User->>SessionPage: Navigate to session
SessionPage->>ComposerState: Init with sessionID + fallbackSessionID
Note over ComposerState: Check active session
ComposerState->>SelectTodos: selectSessionTodos(active session)
SelectTodos->>Backend: Fetch active backend todos
alt Active has backend todos
SelectTodos-->>ComposerState: Return backend todos
else Active backend empty
SelectTodos->>Backend: Extract from active message parts
alt Message parts have todos
SelectTodos-->>ComposerState: Return message-derived todos
else Active parts empty
SelectTodos->>Backend: Fetch fallback session parts
SelectTodos-->>ComposerState: Return fallback-derived todos
end
end
ComposerState->>StatusSummary: Pass todos()
StatusSummary->>User: Render todo progress
Note over ComposerState: Track sessionsWithActiveTodos
ComposerState->>ComposerState: Gate dock hide when<br/>session changed + todos exist
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 7/10 reviews remaining, refill in 15 minutes and 33 seconds. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/app/src/pages/session/session-todos.test.ts (1)
53-61: ⚡ Quick winAdd a fallback-backend precedence test case.
You validate fallback parts, but not the branch where
fallback.backendis non-empty. Adding that assertion locks down the full selection order and protects this bugfix path from regressions.Proposed test addition
describe("selectSessionTodos", () => { + test("prefers fallback backend todos over fallback parts todos", () => { + const fallbackParts = [ + toolPart("todowrite", completedState({ input: { todos: [todo("from fallback parts", "in_progress")] } })), + ] + + expect( + selectSessionTodos({ + backend: [], + parts: [], + fallback: { + backend: [todo("from fallback backend", "pending")], + parts: fallbackParts, + }, + }), + ).toEqual([todo("from fallback backend", "pending")]) + }) + test("falls back to a secondary session source when the primary source is empty", () => {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/app/src/pages/session/session-todos.test.ts` around lines 53 - 61, Add a test variant to cover the fallback.backend precedence: the current test only exercises fallback.parts, so create an additional assertion calling selectSessionTodos with backend: [], parts: [], and fallback: { backend: [ /* a backend todo source */ ], parts: [...] } and assert the returned todos come from fallback.backend instead of fallback.parts; reference the existing helpers and symbols (selectSessionTodos, toolPart, completedState, todo) to construct the fallback.backend item so the test pins the correct selection order.packages/app/src/pages/session/session-todos.ts (1)
13-16: ⚡ Quick winDrop the
as Todo[]casts to keep type drift visible.These assertions hide future schema mismatches. Returning
extractTodos(...)directly keeps compile-time checks honest without changing runtime behavior.Type-safety cleanup
const fromParts = extractTodos(input.parts) - if (fromParts.length > 0) return fromParts as Todo[] + if (fromParts.length > 0) return fromParts if (input.fallback?.backend && input.fallback.backend.length > 0) return input.fallback.backend - return extractTodos(input.fallback?.parts ?? []) as Todo[] + return extractTodos(input.fallback?.parts ?? [])🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/app/src/pages/session/session-todos.ts` around lines 13 - 16, The code currently forces types with casts like "fromParts as Todo[]" and "extractTodos(...) as Todo[]", which masks schema mismatches; remove the "as Todo[]" assertions so functions/variables (fromParts, input.fallback.backend, extractTodos, Todo) retain their inferred types and let the compiler surface mismatches; update the return lines in session-todos.ts to return fromParts, input.fallback.backend, and extractTodos(...) directly (no casts) and run typecheck to fix any resulting type errors by adjusting upstream types or signatures instead of reintroducing assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/app/src/pages/session/session-todos.test.ts`:
- Around line 53-61: Add a test variant to cover the fallback.backend
precedence: the current test only exercises fallback.parts, so create an
additional assertion calling selectSessionTodos with backend: [], parts: [], and
fallback: { backend: [ /* a backend todo source */ ], parts: [...] } and assert
the returned todos come from fallback.backend instead of fallback.parts;
reference the existing helpers and symbols (selectSessionTodos, toolPart,
completedState, todo) to construct the fallback.backend item so the test pins
the correct selection order.
In `@packages/app/src/pages/session/session-todos.ts`:
- Around line 13-16: The code currently forces types with casts like "fromParts
as Todo[]" and "extractTodos(...) as Todo[]", which masks schema mismatches;
remove the "as Todo[]" assertions so functions/variables (fromParts,
input.fallback.backend, extractTodos, Todo) retain their inferred types and let
the compiler surface mismatches; update the return lines in session-todos.ts to
return fromParts, input.fallback.backend, and extractTodos(...) directly (no
casts) and run typecheck to fix any resulting type errors by adjusting upstream
types or signatures instead of reintroducing assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2d356e4a-7609-4c84-96a6-8c04b47cf223
📒 Files selected for processing (6)
packages/app/e2e/session/session-composer-dock.spec.tspackages/app/src/components/session/session-status-summary.tsxpackages/app/src/pages/session.tsxpackages/app/src/pages/session/composer/session-composer-state.tspackages/app/src/pages/session/session-todos.test.tspackages/app/src/pages/session/session-todos.ts
There was a problem hiding this comment.
Code Review
This pull request enhances the session todo selection logic by introducing a prioritized selection mechanism that falls back to message-derived parts and secondary session IDs when primary backend data is unavailable. It also refines the behavior of the todo dock to ensure it remains hidden when landing on completed sessions and correctly manages state during session transitions. New E2E and unit tests have been added to verify these improvements. I have no feedback to provide as no review comments were present.
Summary
todowritetool parts while preventing historical completed todo lists from flashing on session switch.Why
The status panel and bottom todo dock were reading different todo sources. In real sessions, the status panel could show
todowriteprogress while the composer dock stayed hidden. Completed historical sessions could also briefly show the dock for several seconds after navigation.Related Issue
No linked issue; found during local todo dock testing.
Human Review Status
Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.
Review Focus
Please focus on the todo source priority in
selectSessionTodosand the composer dock visibility rules around active vs. terminal todo lists.Risk Notes
Low-to-medium UI behavior risk: this changes which todo source drives the status panel and composer dock. No data, permission, dependency, migration, updater, or packaging changes.
How To Verify
Screenshots or Recordings
Not attached. The visible behavior is covered by focused todo dock e2e tests; final manual visual confirmation should be done during human review if needed.
Checklist
dev, and my PR title and commit messages use Conventional Commits in EnglishSummary by CodeRabbit
New Features
Improvements
Tests