anomalyco / anomalyco/opencode

References to a deleted session outlive it: address bar, recent-tab pointer and persisted handoff

Open
#47,683 1 comment 0 reactions 1 assignee View on GitHub

@Brendonovich is already working on this.

Since Sep 6, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

Description

Deleting a session leaves three references behind, each pointing at something that no longer
exists. They share one cause, so they are filed together.

The deleted session stays in the address bar. In removeSessions
(packages/app/src/context/tabs.tsx) the current-tab check is gated on params.dir:

const currentHref =
  targetServer === server.key && params.dir && params.id ? tabHref({ ... }) : undefined

params.dir only exists on the legacy /:dir/session/:id route. On
/server/:serverKey/session/:id there is no directory, so currentHref stays undefined,
removedCurrent stays false, and the navigation to the next tab never runs. tabHref builds from
server and session id alone and does not need the directory.

The recent-tab pointer survives. It is only cleared when the removed session still had an open
tab (if (recent.key && removed.includes(recent.key))). The pointer is persisted separately and
outlives the tab, so deleting a session that had already been closed leaves it aimed at the deleted
id.

The persisted layout handoff survives. It carries a session id across a layout switch
(store.handoff.tabs in packages/app/src/context/layout.tsx) and nothing clears it on deletion,
so later starts try to restore a session that is gone.

Fallout. When the app then resolves that id, current() throws. The two effects that read it —
LegacyTargetSessionRedirect in packages/app/src/app.tsx and ResolvedTargetSessionRoute in
packages/app/src/pages/session.tsx — throw from inside an effect. Solid's ErrorBoundary only
catches throws during render, so this passes the scoped SessionRouteErrorBoundary (which would
show the "not found" page) and reaches the global one, replacing the whole window with "something
went wrong" for a chat that was merely deleted.

Plugins

None

OpenCode version

dev (ea2d59d7ca)

Steps to reproduce
  1. Open a session on /server/:serverKey/session/:id.
  2. Delete that session.
  3. The URL still points at it and the view keeps trying to load it.
  4. Restart the app — the persisted handoff restores the deleted session, and the global error
    boundary replaces the window.
Screenshot and/or share link

N/A

Operating System

Windows 11 (26200)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.