Skip to content

web: deleted session still appears in home list after browser back navigation #49419

Closed

Description

@moodysalem

Summary

Deleting a session in the web UI leaves the deleted session visible in the home session list when navigating back. The list appears stale until a hard reload or until the TanStack query goes stale/refetches.

Environment

  • opencode version: 2.0.3
  • OS: Linux 7.2.3-arch1-3 (linux x64)
  • Terminal: TERM=xterm-256color
  • Shell: /usr/bin/fish
  • Install/channel: latest
  • Active plugins: local MCPs configured (claude, chrome, dune, ekubo, workspace-mcp, vfat, v12, ekubo_wallet, alchemy, rentcast); no UI plugin overriding sessions

Reproduction

  1. Open web UI, open a session from the home list.
  2. Delete that session from the session view.
  3. Hit browser back to return to the home session list.
  4. The just-deleted session is still listed. Clicking it fails/errors instead of showing not-found.

Expected Behavior

After delete, back-navigation to the home list should not show the deleted session. If a stale ID is visited directly, the UI should show a graceful “session not found” state and drop the reference, not a global error or a ghost row.

Actual Behavior

Deleted session persists in the home list on back navigation. Likely cache is not invalidated on the delete path, so the stale entry renders until refetch.

Additional Context

Code pointers from anomalyco/opencode@dev:

  • packages/app/src/pages/session/timeline/message-timeline.tsx:817 — deleteSession removes from sync().data.session, evicts, and calls notifySessionTabsRemoved, but unlike the archive path it never calls serverSync().homeSessions.remove(...).
  • Compare archive path: packages/app/src/pages/session/session-archive.ts:61 and packages/app/src/pages/home/home-sessions-controller.tsx:229 both call homeSessions().remove(session.id).
  • Home list query in packages/app/src/pages/home/home-sessions-controller.tsx:61 uses staleTime: 30_000 with refetchOnMount: true; browser back may restore without remount/refetch, exposing the stale index entry. createHomeSessionIndexCache.remove exists in packages/app/src/context/global-sync/home-session-index.ts:121.
  • Related but distinct: References to a deleted session outlive it: address bar, recent-tab pointer and persisted handoff #47683 covers deleted-session refs outliving deletion (address bar gated on params.dir in packages/app/src/context/tabs.tsx:310, recent-tab pointer, persisted handoff, global ErrorBoundary). Deleting a session is slow/hangs, leaves ghost sessions, and can freeze the whole app #42538 covers slow/hung deletion with ghost sessions on desktop. This issue is specifically the home-list stale entry on back navigation after a successful delete.

Suggested fix: reduce staleTime significantly in packages/app/src/pages/home/home-sessions-controller.tsx:78 (currently 30_000) — e.g. to 0–5_000 — plus refetchOnWindowFocus / pageshow refetch so back navigation cannot render a 30s-stale list. Showing a brief loading state is better than showing a stale list with a ghost deleted session. Also call homeSessions.remove() on the delete path (see below) so the entry is gone even before refetch.

Workaround: hard reload the home page after deleting.

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I reproduced this with the web app's v2.0.3 code. I opened a session from Home, deleted it from the session view, then pressed browser Back to Home. The deleted session was still listed.

    With the same steps on the latest dev (950111f), the deleted session no longer shows on Home. That holds when deleting from the session header menu or the command palette, and also when the session list loads slowly. So this looks already fixed, and the fix should be in an upcoming release.

    Related: #47683 covers other references to deleted sessions that outlive the delete. One example is browser Back first reopening the deleted session's own URL, which I still saw on dev.

    The bot will close this issue in 1 day unless you reply that it still happens, for example on a newer release.

  2. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    Closing this as completed, since there was no reply in the last day. With the web app's 2.0.3 code, a session deleted from the session view was still listed on Home after browser Back. On the latest dev (950111f) it no longer appears, so this is most likely fixed, and the fix should be in an upcoming release.

    If it still happens on a newer version, please comment here or open a new issue with the version and steps. Browser Back first reopening the deleted session's own page is tracked separately in #47683.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions