Skip to content

fix(app): refresh Home sessions across servers - #63859

Open
limjonathan wants to merge 1 commit into
anomalyco:devfrom
limjonathan:fix-home-cross-process-refresh
Open

limjonathan wants to merge 1 commit into
anomalyco:devfrom
limjonathan:fix-home-cross-process-refresh

Conversation

@limjonathan

@limjonathan limjonathan commented Nov 13, 2026 •

Copy link
Copy Markdown

Closes #55098

Summary

  • Refresh the active Home session index every 30 seconds.
  • This covers sessions created by another server process sharing the same database, where the process-local event bus cannot deliver session.created.
  • Preserve the existing cached list while the refresh runs.

Verification

  • Reproduced the stale-list behavior through the current process-local event architecture.
  • Added a deterministic Playwright regression using the browser clock and an externally added session.
  • Home E2E: 20 passed.
  • App typecheck: passed.
  • Full repository typecheck: 35 tasks passed.

#62298 and #60233 were reproduced against current dev and are already covered by existing fixes, so this PR does not duplicate them.


Added by the opencode bot (AI-generated).

Related: #45549

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 72 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

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

The fix works. The new regression test fails on the base (no refresh request is ever sent) and passes with this PR. App unit tests for home/sessions and tsc -b pass. I did not run the real two-server desktop setup.

Public API: unchanged.

Two concerns, both inline: the interval refreshes even when the list is fresh or the window is hidden, and the test sets up its own request mocking instead of using the shared harness.

Related: #45549

)
}

const refreshTimer = setInterval(() => {

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.

Each tick fetches up to 500 root sessions (loadHomeSessionIndex), and this fires every 30s whatever state the list is in:

  • It ignores target.stale, so a tick right after a fresh load still refetches.
  • It keeps running while the window or tab is hidden or the desktop app is minimized, as long as Home is mounted, which means continuous background polling against local and remote servers.

Could you only dispatch when target.stale is true and document.visibilityState === "visible"? Refreshing on window focus / visibilitychange would then cover the "I come back and it's stale" case at once. shell/titlebar/recent-sessions.tsx already does this, and it would also cover what #55301 proposes.

await expect(row(page, "Already listed")).toBeVisible()
await expect(row(page, added.title)).toHaveCount(0)

await page.route(/\/api\/session\?/, async (route) => {

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.

packages/app/e2e/AGENTS.md asks specs not to write their own routing. mockWorkspace returns the same sessions array that the mock server's GET /api/session handler reads on every request. So this could be just workspace.sessions.push(added) before fastForward, without the custom page.route, the currentSession import or the listRequests counter. Asserting that the row appears is enough.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop: session list does not update when another server sharing the database creates a session

1 participant