Skip to content

fix(core): clear share_url on unshare in session projector (#32912)#33232

Open
fancive wants to merge 1 commit into
anomalyco:devfrom
fancive:fix/unshare-tui-state
Open

fix(core): clear share_url on unshare in session projector (#32912)#33232
fancive wants to merge 1 commit into
anomalyco:devfrom
fancive:fix/unshare-tui-state

Conversation

@fancive

@fancive fancive commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #32912

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

After /unshare, the share link reappears in the TUI. The root cause is in the session projector, not the TUI: sessionRow() in packages/core/src/session/projector.ts builds share_url: info.share?.url, which is undefined once a session is unshared. Drizzle skips undefined fields on UPDATE, so the share_url column keeps its old value. Session.get() reads it straight back from the DB, and the next patch() (from touch / setTitle / setSummary) reloads current.share from that stale row and re-publishes a session.updated event carrying the old URL — so the link comes back in the UI.

The fix coalesces to null (share_url: info.share?.url ?? null), matching the sibling revert: info.revert ?? null a few lines below, so the UPDATE emits SET share_url = NULL and the share is cleared from the row. The TUI command and the server unshare handler were already correct.

How did you verify your code works?

Added a Session.setShare regression test in packages/opencode/test/session/session.test.ts: share → unshare → an unrelated later patch (setTitle), asserting get().share stays undefined. It fails before the fix (the persisted row still holds the stale share_url, so the get immediately after unshare returns it) and passes after. The full session.test.ts suite is green (8 pass), and bun turbo typecheck for @opencode-ai/core + opencode and oxlint on the changed files are clean.

Screenshots / recordings

N/A — internal state/persistence fix; the only visible effect is the share link correctly disappearing after /unshare.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…#32912)

The session projector's sessionRow() wrote `share_url: info.share?.url`,
which is `undefined` after a session is unshared. Drizzle skips
`undefined` fields on UPDATE, so the column kept its old value: get()
reads it back from the DB, and the next patch (touch/setTitle/...)
reloads current.share from that stale row and re-publishes a
session.updated event carrying the old url, making the share link
reappear in the TUI after /unshare.

Coalesce to null (matching the sibling `revert: info.revert ?? null`)
so the UPDATE emits `SET share_url = NULL` and the share is cleared
persistently. The TUI/command/server unshare handlers were already
correct.

Add a Session.setShare regression test: share -> unshare -> an
unrelated later patch, asserting the share stays cleared.

Fixes anomalyco#32912

Claude-Session: https://claude.ai/code/session_01444Qm3LDDrcHSy1HtETM6G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/unshare does not remove share link from TUI display

1 participant