fix(resource): fix resource view disappearing on ats#4103
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 03c7b94. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR fixes two related symptoms in the Confidence Score: 5/5Safe to merge — targeted, minimal fix that closes the spurious removeResource call path without introducing new state invariants. Single-line insertion that correctly exploits the existing ref-before-effect pattern. All edge cases behave correctly. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant UI as UserInput (handleSubmit)
participant CTX as useContextManagement
participant EFFECT as selectedContexts effect
participant HOME as home.tsx (handleContextRemove)
participant CHAT as use-chat.ts (removeResource)
U->>UI: Press Enter / click Send
UI->>CTX: clearContexts()
Note over UI,CTX: BUG (before fix): prevSelectedContextsRef still=[workflowCtx]
CTX-->>EFFECT: selectedContexts becomes []
EFFECT->>EFFECT: prev=[workflowCtx], curr=[], removed=[workflowCtx]
EFFECT->>HOME: onContextRemove(workflowCtx)
HOME->>CHAT: removeResource('workflow', id)
CHAT-->>UI: panel collapses / icon gone
Note over UI,CTX: FIX: prevSelectedContextsRef.current=[] BEFORE clearContexts()
UI->>UI: prevSelectedContextsRef.current = []
UI->>CTX: clearContexts()
CTX-->>EFFECT: selectedContexts becomes []
EFFECT->>EFFECT: prev=[], curr=[], removed=[] — nothing to do
Note over UI,CHAT: Resource stays in panel, icon stays visible
Reviews (1): Last reviewed commit: "fix(resource): fix resource view disappe..." | Re-trigger Greptile |
Summary
Atting a resource, then sending the message would cause the resource to disappear from the right temporarily. Also the symbol for the icon didn't show up until the chat streaming began.
Changed icon rendering to be persisted earlier and cleared resource context to prevent removing resource.
Type of Change
Testing
Checklist
Screenshots/Videos