Repository navigation
Conversation
…#31073) Closes anomalyco#31073 After the first hydration, `sync.session.sync()` short-circuits via `fullSyncedSessions`, so updates produced by another opencode client / remote runner / `opencode serve` never reach this TUI unless they arrive over the local SSE stream. Add an opt-in `force` option to `sync.session.sync()` that bypasses the once-only cache while still de-duping in-flight calls, and add a bounded polling effect in the session route that re-syncs the active session while its status is `working` or `compacting`. The interval is configurable via the new `external_sync_interval_ms` tui.json key (default 2000ms, range 0-60000, 0 disables). The poll is cleaned up on route change, idle transition, and unmount.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
How quickly can we expect this to be available in a release? |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #31073
Type of change
What does this PR do?
After the first successful hydration of a session,
sync.session.sync()short-circuits via afullSyncedSessionsset, so updates produced by another opencode client, a remote agent, oropencode serverunning the same session never reach this TUI unless they happen to land on its own SSE stream. The session view stays frozen until the user navigates away and back.The fix:
force?: booleanoption tosync.session.sync()(packages/tui/src/context/sync.tsx) that bypasses the once-only cache while still de-duping concurrent in-flight calls viasyncingSessions. Default behavior is unchanged for every existing caller.external_sync_interval_mskey (packages/tui/src/config/index.tsx, range 0-60000, default 2000, 0 disables) so the polling cadence is configurable intui.json.createEffectin the session route (packages/tui/src/routes/session/index.tsx) that pollssync.session.sync(id, { force: true })at the configured interval only while the session's status isworkingorcompacting, and usesonCleanupto clear the interval on route change, idle transition, and unmount.Why it works: the
forceflag lets the polling effect re-fetch the active session's state on a timer, bypassing the once-only cache that previously madesync.session.sync()a no-op forever after first hydration. The poll is bounded — it only runs while a session is being driven (working/compacting) and stops the moment the session goes idle, the route changes, or the interval is set to0. When the SSE stream is healthy the local store already has the latest data and the reconcile is incremental, so the poll is effectively a no-op. It exists purely as a safety net for external writers and dropped events.How did you verify your code works?
bun testinpackages/tui: 190 pass, 1 skip, 0 fail (full suite, no regressions)bun test test/cli/cmd/tui/sync.test.tsx test/config.test.tsx: 15 pass, 0 fail (4 new sync tests + 3 new config tests)bun run typecheckinpackages/tui: cleanbun typecheckinpackages/opencode: cleanThe 4 new tests in
test/cli/cmd/tui/sync.test.tsxcover the regression directly:sync(id)call is a no-op (cache hit)sync(id, { force: true })issues a new round of fetchesforce: truecalls share a single underlying fetch (de-dup)message.updatedSSE event still issues 4 fetches instead of 0Screenshots / recordings
Not applicable. The bug requires two opencode clients (or one client +
opencode serve) writing to the same session, and the fix is invisible to a single TUI running standalone — a screenshot of one TUI cannot show the regression or the fix in action. The change is verified by the 4 new automated tests above.Checklist