fix(core): clear share_url on unshare in session projector (#32912)#33232
Open
fancive wants to merge 1 commit into
Open
fix(core): clear share_url on unshare in session projector (#32912)#33232fancive wants to merge 1 commit into
fancive wants to merge 1 commit into
Conversation
…#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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #32912
Type of change
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()inpackages/core/src/session/projector.tsbuildsshare_url: info.share?.url, which isundefinedonce a session is unshared. Drizzle skipsundefinedfields on UPDATE, so theshare_urlcolumn keeps its old value.Session.get()reads it straight back from the DB, and the nextpatch()(fromtouch/setTitle/setSummary) reloadscurrent.sharefrom that stale row and re-publishes asession.updatedevent 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 siblingrevert: info.revert ?? nulla few lines below, so the UPDATE emitsSET share_url = NULLand 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.setShareregression test inpackages/opencode/test/session/session.test.ts: share → unshare → an unrelated later patch (setTitle), assertingget().sharestaysundefined. It fails before the fix (the persisted row still holds the staleshare_url, so the get immediately after unshare returns it) and passes after. The fullsession.test.tssuite is green (8 pass), andbun turbo typecheckfor@opencode-ai/core+opencodeandoxlinton 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