Skip to content

Pinned sessions still lost when multiple TUI instances write session.json (1.19.4) #59938

Closed as not planned

Description

@dexmercer

Description

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

  1. Open TUI A and TUI B (same machine, same state dir).
  2. In B, open the session list and pin a session (ctrl+f). session.json has it.
  3. In A, pin a different session.
  4. 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.

Operating System

macOS (darwin-arm64) and Ubuntu 24.04 (linux-x64)

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    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.

    Related:

    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.

  2. dexmercer commented on Oct 28, 2026

    @dexmercer
    Author

    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:

    1. opencode serve --hostname 127.0.0.1 --port 4599 with a fresh state dir, and three sessions in one project.
    2. TUI A and TUI B: opencode --server http://127.0.0.1:4599 <project>.
    3. In B, open the session list and press ctrl+f on one session. session.json is {"pinned":["<B's session>"]}.
    4. 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.

  3. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions