Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
📝 WalkthroughWalkthroughThe IPC handler for ChangesDefensive IPC Handler for Agent Chat Event History
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested labels
🚥 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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@copilot review but do not make fixes |
|
Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
a17fbe9 to
1c62034
Compare
|
Rebased on latest main and addressed Greptile review by adding coverage for a truthy agentChatService without getChatEventHistory. Re-ran the focused IPC test and desktop typecheck; both pass. |
1c62034 to
5cba84c
Compare
5cba84c to
9725264
Compare
Fixes ADE-56
Summary
Describe the change.
What Changed
Key files and behaviors.
Validation
How you tested.
Risks
Anything to watch.
Linked Linear issues
Summary by CodeRabbit
Bug Fixes
Tests
Greptile Summary
Guards the
agentChatGetEventHistoryIPC handler against a nullagentChatService, which occurs in runtime-backed mode where the service isn't instantiated. Instead of callingensureAgentChatContext()(which throws), the handler now callsgetCtx()directly and returns an empty history snapshot when the service is absent or lacks the method.registerIpc.ts: ReplacesensureAgentChatContext()withgetCtx()+ a two-condition guard (!service || typeof service.getChatEventHistory !== "function"), consistent with the existing pattern inagentChatReadTranscript.runtimeBridge.test.ts: Adds tests for null service, service missing the method (duck-type branch), and the successful forwarding path — full branch coverage for the new guard.Confidence Score: 5/5
Safe to merge — the change adds a well-tested null guard that prevents a crash in runtime-backed mode and is consistent with the existing pattern used by the adjacent
agentChatReadTranscripthandler.The guard logic is straightforward, the change is isolated to a single handler, all three new code paths have direct unit-test coverage, and the implementation mirrors an existing pattern in the same file.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[IPC: agentChatGetEventHistory] --> B[getCtx] B --> C{sessionId valid?} C -- No --> D[return empty snapshot\nsessionId: ''] C -- Yes --> E{service present AND\ngetChatEventHistory is function?} E -- No --> F[return empty snapshot\nsessionId: trimmed] E -- Yes --> G{maxEvents valid\nfinite positive number?} G -- No --> H[maxEvents = undefined] G -- Yes --> I[maxEvents = rawMaxEvents] H --> J[service.getChatEventHistory\nsessionId, undefined] I --> K[service.getChatEventHistory\nsessionId, maxEvents]Comments Outside Diff (1)
apps/desktop/src/main/services/ipc/registerIpc.ts, line 671 (link)AppContexttype doesn't reflect nullableagentChatServicemain.tsexplicitly setsagentChatService: nullfor the runtime-backed context (line 4304), so the field is null at runtime in that mode. However,AppContextstill declares it asReturnType<typeof createAgentChatService>— non-optional, non-nullable. As a result, TypeScript won't flag any future call sites that access the service without a null guard, meaning the pattern this PR protects against can silently recur. Updating the type toReturnType<typeof createAgentChatService> | null(matching the treatment of other nullable services likedevToolsService) would make the type system enforce the guard everywhere.Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (4): Last reviewed commit: "fix: guard chat event history IPC servic..." | Re-trigger Greptile