You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pinned sessions still lost when multiple TUI instances write session.json (1.19.4) #59938
Still happening on 1.19.4: with two TUIs open, pinning a session in one TUI erases pins the other TUI made after the first one started. #44736 described this and was closed by the stale bot without a fix; #45117 fixes it and is still open.
createSession() in packages/tui/src/context/local.tsx reads session.json once and every save() writes the whole in-memory list. prune() on session.deleted also calls save() even when the deleted session was not pinned, so a delete in a stale TUI rewrites the file too.
OpenCode version
1.19.4 (also 1.18.31)
Steps to reproduce
Open TUI A and TUI B (same machine, same state dir).
In B, open the session list and pin a session (ctrl+f). session.json has it.
In A, pin a different session.
session.json now holds only A's pin.
Reproduced on linux-x64 1.18.31 and 1.19.4 with two opencode attach TUIs in tmux. Applying #45117's approach (each pin/unpin applied to the file's current contents) to those builds kept both pins.
Thanks for the detailed report and for testing the #45117 approach.
1.19.4 and 1.18.31 are OpenCode v1, which only gets fixes for critical bugs such as data loss of sessions, security problems or breakage with no workaround. Losing pins when two TUIs are open is a real bug, but it's limited to pin metadata and you can avoid it by using one TUI. So it's unlikely to be fixed in v1.
We'd encourage upgrading to v2 (@opencode/cli). From reading the code, v2's packages/tui/src/context/local.tsx still loads session.json once and rewrites the whole pin list on save and on session.deleted. So v2 may well behave the same way, and #45117 (which targets v2) is the relevant fix there.
Reproduced on v2.2.0 (@opencode/cli 2.2.0, linux-x64).
In v2 the session list only offers pin/unpin when session tabs are off (tabs auto turns them on unless HERDR_ENV=1), so both TUIs ran with HERDR_ENV=1:
opencode serve --hostname 127.0.0.1 --port 4599 with a fresh state dir, and three sessions in one project.
TUI A and TUI B: opencode --server http://127.0.0.1:4599 <project>.
In B, open the session list and press ctrl+f on one session. session.json is {"pinned":["<B's session>"]}.
In A, press ctrl+f on a different session. session.json is {"pinned":["<A's session>"]}; B's pin is gone.
Same createSession() code as v1, so #45117 is the fix here too.
Closing this as not planned, since it was reported on v1 (1.19.4 and 1.18.31) and no v2 reproduction has come in. v1 only gets critical fixes, and losing pins with two TUIs open is limited to pin metadata and can be avoided by using a single TUI.
The v2 code looks like it has the same pattern. #45117 is the open PR that would address it there. If you can reproduce this on v2 (2.x), please open a new issue with the version and steps and link this one. Thanks again for the clear report and for testing the fix approach.
Activity
opencodejr commentedon Oct 28, 2026
Thanks for the detailed report and for testing the #45117 approach.
1.19.4 and 1.18.31 are OpenCode v1, which only gets fixes for critical bugs such as data loss of sessions, security problems or breakage with no workaround. Losing pins when two TUIs are open is a real bug, but it's limited to pin metadata and you can avoid it by using one TUI. So it's unlikely to be fixed in v1.
We'd encourage upgrading to v2 (
@opencode/cli). From reading the code, v2'spackages/tui/src/context/local.tsxstill loadssession.jsononce and rewrites the whole pin list on save and onsession.deleted. So v2 may well behave the same way, and #45117 (which targets v2) is the relevant fix there.Related:
session.jsonwrites (EPERMon Windows)If you can reproduce this on v2 (2.x), or think it should count as critical, please reply here with the v2 version and we'll look again.
dexmercer commentedon Oct 28, 2026
Reproduced on v2.2.0 (
@opencode/cli2.2.0, linux-x64).In v2 the session list only offers pin/unpin when session tabs are off (tabs
autoturns them on unlessHERDR_ENV=1), so both TUIs ran withHERDR_ENV=1:opencode serve --hostname 127.0.0.1 --port 4599with a fresh state dir, and three sessions in one project.opencode --server http://127.0.0.1:4599 <project>.session.jsonis{"pinned":["<B's session>"]}.session.jsonis{"pinned":["<A's session>"]}; B's pin is gone.Same
createSession()code as v1, so #45117 is the fix here too.opencodejr commentedon Oct 29, 2026
Closing this as not planned, since it was reported on v1 (1.19.4 and 1.18.31) and no v2 reproduction has come in. v1 only gets critical fixes, and losing pins with two TUIs open is limited to pin metadata and can be avoided by using a single TUI.
The v2 code looks like it has the same pattern. #45117 is the open PR that would address it there. If you can reproduce this on v2 (2.x), please open a new issue with the version and steps and link this one. Thanks again for the clear report and for testing the fix approach.