Skip to content

--continue selects wrong session due to incorrect sort order in sync.tsx #5510

Closed

Description

@Brandtweary

Description

Sessions are sorted by ID string comparison (a.id.localeCompare(b.id)) but session IDs use descending timestamp encoding (newer sessions have lexicographically smaller IDs via Identifier.descending()). This causes --continue to select an old/stale session instead of the most recently updated one.

Root cause:
packages/opencode/src/cli/cmd/tui/context/sync.tsx:282
(x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id))

Fix:
Sort by timestamp instead:
(x.data ?? []).toSorted((a, b) => b.time.updated - a.time.updated)

OpenCode version

1.0.152 (built from source, dev branch)

Steps to reproduce

  1. Have multiple sessions (created over several hours/days)
  2. Run opencode --continue
  3. Observe that it opens an old session instead of the most recently updated one

Screenshot and/or share link

No response

Operating System

Pop!_OS 22.04 LTS

Terminal

Zed IDE integrated terminal

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 14, 2025
  2. github-actions commented on Dec 14, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. Brandtweary commented on Dec 14, 2025

    @Brandtweary
    Author

    Not the same as #4378, that's for concurrent situations. This occurs even if you have only one instance open at a time.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions