Opencode Sessions

Even though opencode limits the visible sessions listed in the TUI modal (when pressing ctrl+x l, typing /sessions, or using ctrl+p and selecting Sessions), you can still bring up older sessions by using opencode session list. From there you can use opencode -s <sess_id> to bring up that session again. Or you can use opencode export <sess_id> to export it to a file (though I’ve found it can be a bit finicky (sometimes it does output the whole session)).

❯ SESSION=$(oc session list | tail -1 | cut -d ' ' -f 1)
❯ opencode export $SESSION > /tmp/$SESSION.json
❯ cat /tmp/$SESSION.json | jq '.messages | .[].parts | .[].text | select(. | length > 0)'

Pretty handy.