Skip to content

fix(copilot): reopen the chat when its delete fails, unless another chat took its place - #10480

Merged
waleedlatif1 merged 4 commits into
stagingfrom
fix/copilot-delete-restore-selection
Nov 28, 2026
Merged

waleedlatif1 merged 4 commits into
stagingfrom
fix/copilot-delete-restore-selection

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Since fix(copilot): block duplicate chat deletes and leave the open chat first #10476 the panel deselects the open chat before deleting it. If the delete then failed, the chat stayed in history but was no longer shown. On failure the panel now reopens it, but only when the workflow still has no selection, so a chat the user opened or created in the meantime is never replaced. That condition is what separates this from the unconditional restore dropped in fix(copilot): block duplicate chat deletes and leave the open chat first #10476.
  • useCopilotChatSelection exposes peekChatId(), which reads the workflow's current selection from the cache. A mutation callback needs it because its closure holds the selection from when the delete started.
  • The auto-select latch stays set. Once a selection is restored, auto-select doesn't run anyway, and normally the latch was already set when the list first arrived.

Type of Change

  • Bug fix

Testing

  • biome on the changed files; type-check and the rest of the gate run in CI
  • No unit test: the behavior is a mutation onError branch in the panel, and a test would only mock React Query and restate the condition

Checklist

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

…hat took its place

The panel leaves the open chat before deleting it. A failed delete now reopens it, but only
if the workflow still has no selection, so a chat opened or started in the meantime is kept.
@vercel

vercel Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 28, 2026 12:34pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no new actionable issue was found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issue was found.

Summary

The PR reopens an open chat when deletion fails, without replacing another selected chat or an active conversation.

  • The panel restores a failed chat deletion only when no newer conversation has taken its place.
  • The delete hook treats an already-missing Copilot chat as successfully deleted.

No new actionable issues were found. The earlier threads were unnumbered and were not reposted. This review checked code; it did not run the app.

Reviews (4) · Last reviewed commit: "fix(copilot): guard the delete restore o..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

…e delete

An empty selection doesn't prove the panel is idle: a message sent from the empty panel has no
chat id until its POST returns. Count select, new-chat and send actions instead, and reopen the
chat only if none happened while the delete was pending.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

The route returns 404 only when another request deleted the chat between its lookup and its
delete. Treat that like success, so the draft is pruned, the list refreshes, and the panel never
reopens a chat that no longer exists.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 2 files

Confidence score: 4/5

  • In panel.tsx, the failure-restore check only counts panel actions, so a send from the terminal or a block’s “ask copilot” action during deletion can be missed. Include sends from the mothership event handler in the check.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx">

<violation number="1" location="apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx:417">
P2: The failure-restore check only counts panel actions, so a send from the mothership event handler (terminal or block "ask copilot" actions) made while the delete is in flight is not counted. If that send creates a new chat and the delete then fails, the restore replaces the new chat with the deleted one. Check the live selection in the query cache as well as the counter, or bump `copilotChatActionsRef` in the mothership handler before `copilotSendMessage`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

…tion count

A count of panel actions misses selections that land later (a new chat whose create returns after
the delete) and sends that don't go through the panel's handlers. Restore only when the workflow
still has no selection and the panel holds no transcript and no send in flight.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 3c2f25e into staging Nov 28, 2026
83 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/copilot-delete-restore-selection branch November 28, 2026 12:41

This branch was previously deployed

1 inactive deployment
Preview — 8c8c735b Deployed Nov 28, 2026 by vercel[bot]
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