Skip to content

fix(mothership): drop queued tab adds the server already removed - #9050

Merged
waleedlatif1 merged 7 commits into
stagingfrom
fix/stale-resource-tabs
Oct 15, 2026
Merged

waleedlatif1 merged 7 commits into
stagingfrom
fix/stale-resource-tabs

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A server-applied remove effect (e.g. the agent deleting a file) cleared the tab locally but left the client's queued or failed add for that resource in the persistence queue. The next flush re-posted it and hydration re-projected the tab, so the deleted resource went out as an open tab on every later message
  • A server remove effect now discards that queued or failed add, both live and when it arrives through a reconnect replay. The server already removed the resource, so no client delete is sent
  • Active-tab resolution logs a missing resource at info and a revoked one at warn instead of error. Other failures still log at error, and the model receives the same context as before
  • Known residual: an add whose POST is already in flight when the remove effect arrives keeps today's behavior (narrow, pre-existing window). Closing it client-side would add new client/server ordering hazards, so it's left out of this change

Type of Change

  • Bug fix

Testing

  • use-chat DOM regression tests: a failed add followed by a server remove effect, delivered live and via a reconnect replay. Before the fix the add is re-posted, the tab comes back and the deleted id is sent as an attachment; after the fix none of that happens
  • process-contents test covering info/warn/error per failure class

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)

A server-applied remove effect cleared the tab locally but left the client's queued add for the same resource in the persistence queue, so the next flush re-posted it and hydration re-projected the tab. The deleted resource then went out as an open tab on every later message. The remove effect now discards that pending add (the server already removed it, so no client delete is sent).

Active-tab resolution now logs a missing resource at info and a revoked one at warn instead of error; other failures still log at error.
@vercel

vercel Bot commented Oct 14, 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 Oct 15, 2026 12:08am UTC

Request Review

@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 8 files

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

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/resources/client-persistence-queue.ts
@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge within its stated scope.

Summary

The PR drops queued or failed resource adds when a server removal arrives, live or through reconnect replay.

  • Server removals clear queued tab adds before they can restore a resource.
  • Active-tab lookup failures log at a level that matches the failure.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Server removal arrives live or through replay] --> B[Find queued writes in chat and provisional scopes]
  B --> C{User removal or write already running?}
  C -->|Yes| D[Leave existing bookkeeping unchanged]
  C -->|No| E[Drop queued or failed add]
  E --> F[Later flush cannot retry that add]
Loading

Reviews (4) · Last reviewed commit: "fix(mothership): scope stale-tab fix to ..." · Reviewed by Greptile

Comment thread apps/sim/lib/mothership/resources/client-persistence-queue.ts
Comment thread apps/sim/app/workspace/[workspaceId]/home/hooks/stream/handle-resource-event.ts Outdated
… tabs

An add already in flight when the server's removal arrives can commit after it, so the queue now schedules a compensating delete ordered after that write settles. Queued or failed adds are still dropped with no delete.

Recovered remove effects (replay or deferred batch) now discard the queued add too; previously the recovery path returned before the discard ran.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

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

All reported issues were addressed across 8 files

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

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptileai review

Comment thread apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts Outdated
An upsert effect means the server stored the resource again, so a client delete still waiting behind an in-flight add must not run. The queue drops that removal the same way a newer add does; nothing is written since the server already holds the resource.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

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

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

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

All reported issues were addressed across 8 files

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

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/resources/client-persistence-queue.ts Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/home/hooks/stream/handle-resource-event.ts Outdated
Drops the in-flight compensating delete and the restore cancel path: each added a new client/server ordering hazard. A server remove effect, live or on recovery, now only discards a queued or failed client add for that resource; a write already in flight is left untouched.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

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

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@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 8 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 29158c6 into staging Oct 15, 2026
54 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/stale-resource-tabs branch October 15, 2026 00:28

This branch was previously deployed

1 inactive deployment
Preview — 8bd8c38c Deployed Oct 15, 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