Renaming chat sessions not working
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
- Open chat sessions:
ctrl+x l - Rename:
ctrl+r - Submit:
Enter - Open chat session and it shows the old name
Screenshot and/or share link
No response
Operating System
Ubuntu 22.04
Terminal
Ghostty
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.
Are you sure this is still an issue?
https://github.com/user-attachments/assets/e7fcb7d4-c073-4f05-a9e6-3b6ea291e857
can't replicate
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/storageto~/context/opencode/storage
I'm working on a PR to fix this.
@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!
Yeah we don't sync across instances rn we should fix that