Skip to content

fix(mothership): extend the workflow pickup grace for a view that re-attaches during it - #10152

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/workflow-pickup-reattach-grace
Nov 18, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/workflow-pickup-reattach-grace

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up to fix(mothership): skip the 30s workflow pickup wait when no chat view is reading #10148. Reader presence was read once at dispatch, so a reload (the send's response drops, the view re-attaches about two seconds later) still got the 5s no-view grace. Its execute POST could then arrive after the server's claim: a benign 409, but the canvas lost live progress.
  • Presence is now read again when the short grace ends. A view attached by then gets the rest of the full 30s; otherwise the server claims as before. One extra ZCOUNT, only on turns that started with no view.
  • Each reader refresh now runs ZREMRANGEBYSCORE key -inf <now> in the same MULTI, so entries left by a crashed instance don't linger while another reader keeps the key alive.

Type of Change

  • Bug fix

Testing

  • handlers.test.ts: a view that re-attaches during the short grace is not claimed before 30s (fails on the code before this change).
  • start.test.ts: the send counts as viewed while its response is attached and defers to reader presence once it disconnects (fails if the in-process signal is inverted).
  • viewer.integration.ts against real Redis, plus workflow-client-fallback.test.ts and app/api/copilot/chat/stream/route.test.ts; biome on changed files. Full type-check and audits left to CI.

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)

…attaches during it

A reload drops the send's response, so a call dispatched right then got the 5s
grace even though the view re-attaches about two seconds later. Presence is now
read again when the short grace ends, and a view attached by then gets the rest
of the full grace. A reader's refresh also drops lapsed entries, and the send's
in-process attachment signal is covered by a test.
@vercel

vercel Bot commented Nov 18, 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 18, 2026 5:31am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

This PR gives a reconnected chat view the remaining workflow pickup time and removes expired reader records.

  • Reattached chat views get the rest of the workflow pickup grace.
  • Live reader refreshes clear expired chat-view entries.

The previously reported slow-check delay is fixed. No new actionable issues were found.

Reviews (2) · Last reviewed commit: "fix(mothership): never hold a finished w..." · 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 5 files

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

Turn on auto-fix | Re-trigger cubic

…ension check

The presence re-check at the end of the short grace now races the browser's
result, so a run that finishes or a Stop during a slow read returns at once, and
the time the check took comes out of the extension.
@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 18, 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 6 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 7f28e95 into staging Nov 18, 2026
81 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/workflow-pickup-reattach-grace branch November 18, 2026 05:58

This branch was previously deployed

1 inactive deployment
Preview — b5dd83fe Deployed Nov 18, 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