opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Renaming chat sessions not working

Open ranjanjayapal opened this issue 2 weeks ago • 3 comments

Description

Not able to rename chat sessions in 1.0.152. Dialog for renaming shows up and allows for renaming, but reverts back the the default name after submitting.

OpenCode version

1.0.152

Steps to reproduce

  1. Open chat sessions: ctrl+x l
  2. Rename: ctrl+r
  3. Submit: Enter
  4. Open chat session and it shows the old name

Screenshot and/or share link

No response

Operating System

Ubuntu 22.04

Terminal

Ghostty

ranjanjayapal avatar Dec 13 '25 22:12 ranjanjayapal

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

  • #3779: Session rename (via /rename or /session + ctrl-r) not working

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

github-actions[bot] avatar Dec 13 '25 22:12 github-actions[bot]

Are you sure this is still an issue?

https://github.com/user-attachments/assets/e7fcb7d4-c073-4f05-a9e6-3b6ea291e857

can't replicate

rekram1-node avatar Dec 14 '25 04:12 rekram1-node

Additional Diagnosis

I've investigated this issue and found the root cause:

The rename DOES work at the backend level

The JSON files in storage are correctly updated. For example:

{
  "id": "ses_4e3a579daffeoAdHvBK3FdvzlE",
  "title": "Debugging rename function in opencode",  // ✅ Updated correctly
  ...
}

The problem is in the UI sync mechanism

The issue is in packages/opencode/src/cli/cmd/tui/context/sync.tsx:

case "session.updated": {
  const result = Binary.search(store.session, event.properties.info.id, (s) => s.id)
  if (result.found) {
    setStore("session", result.index, reconcile(event.properties.info))
    break
  }
  // If not found, it tries to insert at the wrong index
  setStore(
    "session",
    produce((draft) => {
      draft.splice(result.index, 0, event.properties.info)
    }),
  )
  break
}

The Binary.search may fail to find the session if the session array in the store is not sorted in the same order that Binary.search expects (by ID string comparison).

Workaround

Close the session list (Escape) and reopen it (Ctrl+X L) - the renamed title will appear since it's already persisted.

Environment

  • OpenCode version: 1.0.152
  • OS: macOS
  • Storage: Using symlink from ~/.local/share/opencode/storage to ~/context/opencode/storage

I'm working on a PR to fix this.

cedefrespo avatar Dec 14 '25 10:12 cedefrespo

@rekram1-node This seems to be working now. It probably was pulling the name from a cached index for me instead of the new name given. Once all opencode instances were restarted, it seems to have been fixed. Thank you!

ranjanjayapal avatar Dec 14 '25 14:12 ranjanjayapal

Yeah we don't sync across instances rn we should fix that

rekram1-node avatar Dec 14 '25 17:12 rekram1-node