Skip to content

fix(sessions): Stop cloud task watcher restart loop#2661

Merged
charlesvien merged 1 commit into
mainfrom
fix/cloud-task-watcher-restart-loop
Jun 13, 2026
Merged

fix(sessions): Stop cloud task watcher restart loop#2661
charlesvien merged 1 commit into
mainfrom
fix/cloud-task-watcher-restart-loop

Conversation

@charlesvien

@charlesvien charlesvien commented Jun 13, 2026

Copy link
Copy Markdown
Member

Problem

Sitting on a finished (terminal) cloud task spins the cloud-task watcher in a tight start/stop loop (~2x/sec): the terminal snapshot tears the watcher down and rewrites session.configOptions, which re-fires the useSessionConnection reconcile effect, which re-subscribes and re-bootstraps. The result is console spam and a full log-history refetch every cycle.

Changes

  1. Guard watchCloudTask to skip re-watching a terminal run already hydrated in the store
  2. First open still fetches the snapshot once; new runs and live (non-terminal) runs are unaffected
  3. Add regression tests: skip when terminal + hydrated, still watch when terminal-not-hydrated or in-progress

How did you test this?

Manually

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@charlesvien charlesvien changed the title stop cloud task watcher restart loop fix(sessions): Stop cloud task watcher restart loop Jun 13, 2026
@charlesvien charlesvien marked this pull request as ready for review June 13, 2026 17:24

charlesvien commented Jun 13, 2026

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown

React Doctor could not complete this scan.

No React dependency found in /tmp/react-doctor-baseline-6ZDVVp/package.json. Add "react" to dependencies (or peerDependencies) and re-run.

Reviewed by React Doctor for commit 019e28f.

@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jun 13, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jun 13, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Focused bug fix with good test coverage — adds a targeted guard to break a restart loop without changing any existing code paths or contracts.

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/ui/src/features/sessions/sessionServiceHost.test.ts:946-1015
**Prefer parameterised tests for the three new cases**

The three new `it` blocks test the same function with only the session fields and expected call assertions varying. Per the team's style preference, these should be written as `it.each`. Additionally, the `events` array on the first mock (`[{ type: "acp_message", ... }]`) is absent from the other two mocks and isn't checked by the guard — it's a superfluous part that makes the cases look non-parallel.

Reviews (1): Last reviewed commit: "stop cloud task watcher restart loop" | Re-trigger Greptile

Comment thread packages/ui/src/features/sessions/sessionServiceHost.test.ts Outdated
@charlesvien charlesvien force-pushed the fix/cloud-task-watcher-restart-loop branch from be60e34 to 019e28f Compare June 13, 2026 21:26
@github-actions github-actions Bot dismissed their stale review June 13, 2026 21:26

New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Targeted bug fix with clear intent and good test coverage. The guard is correctly scoped to the no-existing-watcher path, all three guard conditions are necessary and correct, and the tests cover the full boundary space including the "not yet hydrated" and "different run" cases that must continue to watch.

@charlesvien charlesvien merged commit a293d6e into main Jun 13, 2026
24 checks passed
@charlesvien charlesvien deleted the fix/cloud-task-watcher-restart-loop branch June 13, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant