Move pending approval derivation and thread visit tracking to shared session logic#16
Move pending approval derivation and thread visit tracking to shared session logic#16juliusmarminge merged 2 commits intomainfrom
Conversation
- Moved pending-approval extraction to `session-logic` and reused it in `Sidebar` status rendering - Added `lastVisitedAt` threading persistence through schema, types, hydrate/serialize paths, and tests - Updated sidebar thread pills for completed/approval states and pulsing working status - Marked active thread visits and completion visibility timestamps on selection and `turn/completed` - Co-authored-by: codex <codex@users.noreply.github.com>
|
Caution Review failedThe pull request is closed. WalkthroughAdds thread visit-time tracking, moves pending-approval derivation into session-logic as a shared exported function, and replaces Sidebar's status label with a pill-based status UI; updates store and persistence to surface and persist Changes
Sequence Diagram(s)sequenceDiagram
participant Provider as Provider (events)
participant Store as Store (state)
participant Session as session-logic
participant UI as Sidebar / ChatView
Provider->>Store: append events to thread.events
Store->>Session: expose thread.events (derive)
Session->>Session: derivePendingApprovals(events)
Session-->>Store: pending approvals (derived)
Store->>UI: expose pendingApprovalByThreadId and thread data
UI->>UI: render ThreadStatusPill / pending approvals list
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Greptile OverviewGreptile SummaryMoved pending approval derivation logic from
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Sidebar
participant Store
participant Thread
participant SessionLogic
User->>Sidebar: Select thread
Sidebar->>Store: SET_ACTIVE_THREAD
Store->>Thread: Update lastVisitedAt (current timestamp)
User->>ChatView: Send message / Turn starts
ChatView->>Store: APPLY_EVENT (turn/started)
Store->>Thread: Add event, update session status
Note over Thread,SessionLogic: During turn execution
ChatView->>Store: APPLY_EVENT (approval request)
Store->>Thread: Add approval request event
Sidebar->>SessionLogic: derivePendingApprovals(thread.events)
SessionLogic-->>Sidebar: Returns pending approvals
Sidebar->>Sidebar: Show "Awaiting response" pill
User->>ChatView: Approve/Deny action
ChatView->>Store: APPLY_EVENT (decision)
Store->>Thread: Add decision event
Note over Thread,SessionLogic: Turn completes
ChatView->>Store: APPLY_EVENT (turn/completed)
Store->>Thread: Update latestTurnCompletedAt
Store->>Thread: Update lastVisitedAt (active thread only)
Sidebar->>SessionLogic: derivePendingApprovals(thread.events)
SessionLogic->>SessionLogic: Clear pending on turn/completed
SessionLogic-->>Sidebar: Returns empty array
Sidebar->>Sidebar: Check hasUnseenCompletion
Note over Sidebar: completedAt > lastVisitedAt
Sidebar->>Sidebar: Show "Completed" pill (if inactive)
User->>Sidebar: Select thread again
Sidebar->>Store: SET_ACTIVE_THREAD
Store->>Thread: Update lastVisitedAt
Sidebar->>Sidebar: Hide "Completed" pill
Last reviewed commit: 1b7abe5 |
Move pending approval derivation to
|
Summary
ChatViewinto sharedapps/web/src/session-logic.tsand added a dedicatedPendingApprovaltype.derivePendingApprovalstests to cover request, decision, and turn-completion clearing behavior.lastVisitedAtto thread persistence (persistenceSchema.ts) and threaded it through hydration/serialization round-trip.Working,Connecting,Completed,Awaiting response) and derive completion visibility fromlatestTurnCompletedAtvslastVisitedAt.ChatViewand switched to derived session-logic path.Testing
apps/web/src/session-logic.test.tsforderivePendingApprovals.apps/web/src/persistenceSchema.test.tsforlastVisitedAthydration/persistence.apps/web/src/store.test.tsfor active-thread visit updates and completion-seen timestamps.Summary by CodeRabbit
New Features
Bug Fixes
Refactor