fix(copilot): fix state message sent on move to background#871
fix(copilot): fix state message sent on move to background#871
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Greptile Summary
This PR fixes a bug in the copilot system where tools moved to background execution were sending incorrect state messages to the agent. The changes span across multiple components in the copilot architecture to ensure proper state communication and message handling.
The core issue was in the tool confirmation component (tool-confirmation.tsx) where the "Move to background" action was incorrectly mapped to 'rejected' state instead of 'background' state. This caused the agent to receive the wrong message about tool execution status.
The fix includes several coordinated changes:
-
State mapping correction: Fixed the ternary operator logic to properly map 'background' action to 'background' state for both
toolStateanduiStatevariables -
Enhanced notification system: Added
executionStartTimeparameter to notification functions (notification-utils.ts) to provide temporal context when tools are moved to background, improving the default message generation -
Workflow execution tracking: Updated the RunWorkflowTool (
run-workflow.ts) to capture and store execution timestamps in the context, enabling background notifications to include when execution started -
Frontend integration: Modified the inline tool call component (
inline-tool-call.tsx) to pass execution start time to the backend notification system -
API payload simplification: Streamlined the notification API structure by consolidating multiple fields (toolName, toolState, stateMessage) into a single message field
The changes also include extensive debug logging in Redis operations (confirm/route.ts and methods/route.ts) to track message handling and identify potential issues with state persistence and retrieval.
This fix ensures that when users move long-running tools to background execution, the copilot agent receives accurate status messages with proper temporal context, improving the overall user experience for background task management.
Confidence score: 4/5
- This PR addresses a clear bug with a focused solution and minimal risk of introducing new issues
- Score reflects well-structured changes across multiple coordinated components with logical flow
- Pay close attention to the notification system changes and Redis logging additions for potential performance impact
6 files reviewed, no comments
* Initial fix * Add execution start time to message * Lint
…ing and styling (#872) * fix(copilot-ui): added user scrolling, fixed code block, fixed code copying and styling * use console logger instead of console * fix(copilot): make chat history non-interfering (#869) * Add basic personalizatoin * Make chat history non-interfering * Always personalize * improvement(copilot): add subblock enums to block metadata (#870) * Add subblock enums to metadata * Update apps/sim/lib/copilot/tools/server-tools/blocks/get-blocks-metadata.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix(copilot): fix state message sent on move to background (#871) * Initial fix * Add execution start time to message * Lint * autofocus on new tab open --------- Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
* Initial fix * Add execution start time to message * Lint
…ing and styling (#872) * fix(copilot-ui): added user scrolling, fixed code block, fixed code copying and styling * use console logger instead of console * fix(copilot): make chat history non-interfering (#869) * Add basic personalizatoin * Make chat history non-interfering * Always personalize * improvement(copilot): add subblock enums to block metadata (#870) * Add subblock enums to metadata * Update apps/sim/lib/copilot/tools/server-tools/blocks/get-blocks-metadata.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix(copilot): fix state message sent on move to background (#871) * Initial fix * Add execution start time to message * Lint * autofocus on new tab open --------- Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
* Initial fix * Add execution start time to message * Lint
…ing and styling (#872) * fix(copilot-ui): added user scrolling, fixed code block, fixed code copying and styling * use console logger instead of console * fix(copilot): make chat history non-interfering (#869) * Add basic personalizatoin * Make chat history non-interfering * Always personalize * improvement(copilot): add subblock enums to block metadata (#870) * Add subblock enums to metadata * Update apps/sim/lib/copilot/tools/server-tools/blocks/get-blocks-metadata.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix(copilot): fix state message sent on move to background (#871) * Initial fix * Add execution start time to message * Lint * autofocus on new tab open --------- Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…ai#871) * Initial fix * Add execution start time to message * Lint
…ing and styling (simstudioai#872) * fix(copilot-ui): added user scrolling, fixed code block, fixed code copying and styling * use console logger instead of console * fix(copilot): make chat history non-interfering (simstudioai#869) * Add basic personalizatoin * Make chat history non-interfering * Always personalize * improvement(copilot): add subblock enums to block metadata (simstudioai#870) * Add subblock enums to metadata * Update apps/sim/lib/copilot/tools/server-tools/blocks/get-blocks-metadata.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix(copilot): fix state message sent on move to background (simstudioai#871) * Initial fix * Add execution start time to message * Lint * autofocus on new tab open --------- Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Summary
Ensures the correct message is sent to the agent when a tool is moved to the background
Type of Change
Testing
Manual
Checklist