Skip to content

fix(copilot): fix state message sent on move to background#871

Merged
Sg312 merged 3 commits intostagingfrom
fix/copilot-move-to-background
Aug 5, 2025
Merged

fix(copilot): fix state message sent on move to background#871
Sg312 merged 3 commits intostagingfrom
fix/copilot-move-to-background

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Aug 5, 2025

Summary

Ensures the correct message is sent to the agent when a tool is moved to the background

Type of Change

  • Bug fix

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Aug 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2025 2:23am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Aug 5, 2025 2:23am

@vercel vercel bot temporarily deployed to Preview – docs August 5, 2025 02:17 Inactive
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. State mapping correction: Fixed the ternary operator logic to properly map 'background' action to 'background' state for both toolState and uiState variables

  2. Enhanced notification system: Added executionStartTime parameter to notification functions (notification-utils.ts) to provide temporal context when tools are moved to background, improving the default message generation

  3. 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

  4. Frontend integration: Modified the inline tool call component (inline-tool-call.tsx) to pass execution start time to the backend notification system

  5. 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

Edit Code Review Bot Settings | Greptile

@Sg312 Sg312 merged commit 221a473 into staging Aug 5, 2025
5 checks passed
waleedlatif1 pushed a commit that referenced this pull request Aug 5, 2025
* Initial fix

* Add execution start time to message

* Lint
waleedlatif1 added a commit that referenced this pull request Aug 5, 2025
…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>
waleedlatif1 pushed a commit that referenced this pull request Aug 5, 2025
* Initial fix

* Add execution start time to message

* Lint
waleedlatif1 added a commit that referenced this pull request Aug 5, 2025
…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>
@waleedlatif1 waleedlatif1 deleted the fix/copilot-move-to-background branch August 6, 2025 00:22
waleedlatif1 pushed a commit that referenced this pull request Aug 6, 2025
* Initial fix

* Add execution start time to message

* Lint
waleedlatif1 added a commit that referenced this pull request Aug 6, 2025
…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>
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…ai#871)

* Initial fix

* Add execution start time to message

* Lint
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant