Skip to content

fix(mothership): skip the 30s workflow pickup wait when no chat view is reading - #10148

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/client-tool-no-editor-grace
Nov 18, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/client-tool-no-editor-grace

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Client-routed workflow tools (run_workflow, run_block, run_from_block, run_workflow_until_block) waited a fixed 30s for a chat view to claim them before the server ran them, even when nothing was reading the turn's stream (tab closed, user on another chat or page). Roughly a third of client-routed workflow calls hit this wait and then ran server-side anyway.
  • Dispatch now asks whether a chat view is reading the turn: the send's own response still attached (in-process), or a reader re-attached through the reconnect route. Each reconnect attachment holds its own member in a per-stream sorted set (mothership_stream:<streamId>:viewers, scored by when it lapses, refreshed every 3s, 10s TTL); release removes it, and each refresh drops lapsed members.
  • No view: the grace drops to 5s. Presence is read again when that ends, and a view that re-attached meanwhile (a reload) gets the rest of the full 30s. A present view keeps the full 30s. An unknown (no Redis, failed read, legs without the signal) counts as present.
  • Claim arbitration is unchanged: a view that shows up late still gets the existing benign 409, and the run is never doubled. Client and server runs both execute through the same server executor; a server run only loses the live canvas progress.

Type of Change

  • Bug fix

Testing

  • handlers.test.ts: no view → server claims at 5s; view present → not claimed before 30s; view re-attaching during the short grace → not claimed before 30s. The first and third fail on the code they fix.
  • 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 (real Redis): attached reader visible after its hold resolves, untouched stream not, another attached reader keeps a stream counted, a released reader stops counting at once and never re-marks.
  • Ran those plus workflow-client-fallback.test.ts and app/api/copilot/chat/stream/route.test.ts locally; 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)

…is reading

A client-routed workflow tool waited 30s for a chat view to pick it up before the
server ran it, even when no view was reading the turn's stream at all (tab closed,
user on another chat or page). Dispatch now checks whether the send's own response
is still attached or a reconnected reader holds a short-lived Redis mark; with
neither, it waits only 5s for a view that is re-attaching. A present view keeps
the full grace, and an unknown (no Redis, failed read) counts as present.
@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 4:54am 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 shortens workflow pickup waits when no chat view is reading and tracks reconnected readers across servers.

  • Workflow calls reach the server sooner when no chat view is reading.

No new actionable issues found. waleedlatif1 kept the pickup tests as intentional timing unit tests, with reader behavior covered separately against real Redis. Greptile withdrew the earlier testing finding.

Reviews (4) · Last reviewed commit: "fix(mothership): clear a reader's mark 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 10 files

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

Turn on auto-fix | Re-trigger cubic

…fore its first event

Each reconnect attachment now holds its own entry in a per-stream sorted set,
removed on release, so leaving stops counting at once instead of lingering until
the TTL. The route awaits the first mark before reading, and the Redis suite
skips when no test Redis is configured locally.
@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 10 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 aa94b0e into staging Nov 18, 2026
81 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/client-tool-no-editor-grace branch November 18, 2026 05:14
@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 10 files

Confidence score: 5/5

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

Re-trigger cubic

This branch was previously deployed

1 inactive deployment
Preview — 234b10d8 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