opencode icon indicating copy to clipboard operation
opencode copied to clipboard

How to unarchive in opencode-desktop

Open leavor opened this issue 9 months ago • 20 comments

Question

I accidentally clicked 'Archive' on a session in opencode-desktop. How can I find it and get it back?

Image

opencode-desktop version is v1.1.53

leavor avatar Feb 06 '26 01:02 leavor

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

  • #6680: [FEATURE]: view archived sessions on desktop - This is a feature request for the ability to view and unarchive archived sessions
  • #10815: Data loss due to session closure without confirmation - Related issue about session archival/closure, discusses the need for reversible operations

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

github-actions[bot] avatar Feb 06 '26 01:02 github-actions[bot]

To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

github-actions[bot] avatar Apr 07 '26 03:04 github-actions[bot]

create a new session and just give it this prompt "My archived OpenCode chat session (your session name) are missing from the sidebar. They are stored in the SQLite database at ~/.local/share/opencode/opencode.db in the session table. The column time_archived is set to a timestamp when a session is archived. To restore them, set time_archived = NULL. Please run a query to show me all archived sessions, ask me which one to restore, and then run the UPDATE query to fix it." Restart after the execution! The session will be recovered!

NashYang96 avatar Apr 29 '26 12:04 NashYang96

opencode export > session-export.json jq 'del(.info.time.archived)' session-export.json > session-unarchived.json opencode session delete opencode import session-unarchived.json opencode --session

devbijay avatar Apr 30 '26 19:04 devbijay

Well, it was a weird way to find out this issue after I accidently miss pressed the caps lock and stuff, and my sessions went disappeared, lol.

SawLay043 avatar Apr 30 '26 20:04 SawLay043

test

g19375592715-del avatar May 01 '26 05:05 g19375592715-del

on linux you can install sqlite3 cli and run sqlite3 ~/.local/share/opencode/opencode.db "SELECT id,title,slug,time_archived FROM session ORDER BY time_archived DESC LIMIT 1;" to get last archived session details- increase limit to get more sessions then run sqlite3 ~/.local/share/opencode/opencode.db "UPDATE session SET time_archived = NULL WHERE slug = 'PASTE_SLUG_HERE';" for the session you want to unarchive

SinnySupernova avatar May 12 '26 18:05 SinnySupernova

Just accidentally pressed "CTRL+Alt+Backspace" and my super massive conversation just got deleted. It says "Archive", but there's seemingly no way to view archived conversations and/or bring them back - which is quite misleading. And there really should be a confirmation modal for such an irreversible action.

TimChinye avatar May 18 '26 16:05 TimChinye

create a new session and just give it this prompt "My archived OpenCode chat session (your session name) are missing from the sidebar. They are stored in the SQLite database at ~/.local/share/opencode/opencode.db in the session table. The column time_archived is set to a timestamp when a session is archived. To restore them, set time_archived = NULL. Please run a query to show me all archived sessions, ask me which one to restore, and then run the UPDATE query to fix it." Restart after the execution! The session will be recovered!

Thanks Yang, Really helps me a lot.

zkxil avatar May 22 '26 01:05 zkxil

WHY the fuck is this topic opened since FEB.6???? How the fuck can a programm behave like this for over 5 months? Omfg.... can some one explain to me, how to edit the C:\Users\FreeRide23.local\share\opencode\opencode.db to reset the sessions??? I read 20 different approaches, no one works.... cause there are terms like "TUI" what NO ONE EXPLAINS..... How the fuck should a normal person understand ANY SHIT that is written here???? I dont have any fucking idea how to fucking open a database, or what to klick where to edit WHAT....

So can anyone fucking explain this shit to me? IN SIMPLE FUCKING TERMS????

This: "create a new session and just give it this prompt "My archived OpenCode chat session (your session name) are missing from the sidebar. They are stored in the SQLite database at ~/.local/share/opencode/opencode.db in the session table. The column time_archived is set to a timestamp when a session is archived. To restore them, set time_archived = NULL. Please run a query to show me all archived sessions, ask me which one to restore, and then run the UPDATE query to fix it." Restart after the execution! The session will be recovered!"

Did not work, because I DO NOT FUCKING KNOW THE NAME OF THE SESSION...... Also it does not work because it says i need to close the OpenCode software...

I found this one: https://github.com/OllyJohnston/OpenCode-Archive-Session-Manager

So you realy mean, i should install: Python Opencode TUI and then follow 20 steps of shit, just to install a FEATURE that should have been there 5 month ago????

So your fix for a problem, is a installation process of its own????

WHY THE FUCK can no one in this dev community ADD the CODE that is written ALLREADY here: https://github.com/anomalyco/opencode/issues/24153 ????

WHO THE FUCK IS IN CHARGE OF THIS???? What ASS we need TO KICK to MAKE THIS FUCKING HAPPEN????????

I realy love the open source community, but you fucking guys are missing the abilit to MAKE DECISIONS and MAKE IT HAPPEN!!!! FOR FUCK SAKE WHO IS IN CHARGE OF THIS SHIT?????

FreeRide23 avatar May 23 '26 20:05 FreeRide23

@FreeRide23 on Windows I suggest this:

  1. download a simple GUI like sqlite-gui
  2. open C:\Users\<YOURUSER>\.local\share\opencode\opencode.db (yes, I know it's unnatural, should be under C:\Users\<YOURUSER>\AppData\Roaming\opencode, sic)
  3. find the session e.g.
SELECT id, title, slug, time_archived
FROM session
ORDER BY time_archived DESC
LIMIT 1;

to get last archived session details (copy-paste then press Execute) 4. save the value of the slug cell (right-click, Copy cell) 5. un-archive executing another command

UPDATE session
SET time_archived = NULL
WHERE slug = 'PASTE_COPIED_SLUG_HERE';
  1. close and reopen Opencode Desktop

at least it worked for me thanks @SinnySupernova for the tip

giuliov avatar May 24 '26 07:05 giuliov

SELECT id, title, slug, time_archived FROM session ORDER BY time_archived DESC LIMIT 1; to get last archived session details (copy-paste then press Execute) 4. save the value of the slug cell (right-click, Copy cell) 5. un-archive executing another command

UPDATE session SET time_archived = NULL WHERE slug = 'PASTE_COPIED_SLUG_HERE'; 6. close and reopen Opencode Desktop

DUDE! THX! That works! Finaly a good explanation!

Ok, what i was missing (a friend helped me then) was the following information:

You say "find the session e.g." and then post the SQL execution parameters.... I told you, i dont know shit about databases....

So what i was missing, was the information, Open the *.db with the SQL Lite viewer, then you see the Database, on the tab "database structure, Browse Data, Edit Pragmas, execute SQL" press the execute SQL tab. Then paste the code: SELECT id, title, slug, time_archived FROM session ORDER BY time_archived DESC LIMIT 1;

Then press > run Now you find your the slug you need, the slug is showed below the execution window, copy the slug name and paste it into the other command:

found slug: jolly-forest

UPDATE session SET time_archived = NULL WHERE slug = 'PASTE_COPIED_SLUG_HERE';

=

UPDATE session SET time_archived = NULL WHERE slug = 'jolly-forest';

Repeat it as often as you need (i needed to do it two times).

This works!

THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Fuck that shit, make that user interface work.... please, for fuck sake....

I dont know if this programm is run by a dev community or a vibe coding community i realy dont care.... All i see are endless treads, with different approaches, and it needs me to get fucking angry, to get a answer that helps.... I see https://github.com/OllyJohnston/OpenCode-Archive-Session-Manager this and just get angry, because a simple explanation (that is now given) would solve all the problems.... and all the problems would not even exist, if the suggestion of the implementation of this bugfix would WORK in TIME.....

So who ever is in charge of this shit here, get your shit together, for fuck sake.....

FreeRide23 avatar May 24 '26 10:05 FreeRide23

https://github.com/OllyJohnston/OpenCode-Archive-Session-Manager

This worked! In TUI not the desktop version. FYI.

it is unbelievable that such a shitty issue just needed an entire repo for providing a solid solution.

GitBruced avatar Jun 07 '26 17:06 GitBruced

This: "create a new session and just give it this prompt "My archived OpenCode chat session (your session name) are missing from the sidebar. They are stored in the SQLite database at ~/.local/share/opencode/opencode.db in the session table. The column time_archived is set to a timestamp when a session is archived. To restore them, set time_archived = NULL. Please run a query to show me all archived sessions, ask me which one to restore, and then run the UPDATE query to fix it." Restart after the execution! The session will be recovered!"

Did not work, because I DO NOT FUCKING KNOW THE NAME OF THE SESSION...... Also it does not work because it says i need to close the OpenCode software...

Then just use a generic prompt "My archived OpenCode chat sessions are missing from the sidebar. They are stored ..." It will give you all of them, and you will be able to choose which ones to restore (you can select one, a few or all).

It worked for me!

galenfontaise avatar Jun 22 '26 18:06 galenfontaise

trash app by trash devs. you can tell when people don't dogfood.

planetzalex avatar Jul 09 '26 07:07 planetzalex

@galenfontaise Similar prompt worked for me as well! This is the exact request I used in a new session:

The OpenCode chat session we were just working on — I hadn't submitted my lengthy reply yet! — is missing from the sidebar; it was accidentally archived. Archived sessions are stored in the SQLite database at ~/.local/share/opencode/opencode.db in the session table. The column time_archived is set to a timestamp when a session is archived. To restore them, set time_archived = NULL. Please run a query to show me all archived sessions, ask me which one to restore, and then run the UPDATE query to fix it.

...I had to restart OpenCode Desktop before the restored session reappeared, and the un-submitted text didn't initially show up. I asked in the restoration session to restore text as well, and it claimed it wasn't possible. But when I went back to the restored session, there was all the un-submitted text I'd been working on. Immediately copied it to a text editor with deletion protection, finished drafting, and submitted. All seems to be working as expected.

System: MacOS 26.5.1 Model: Claude Opus 4.7 High (via OpenCode Zen)

Total cost of the restoration session was $0.21. Really hope the developers can add an archive view in the GUI so we don't have to go through vibe coding our way back from an accidental deletion! I definitely removed the archive keyboard shortcut — it's far too close to existing text editing shortcuts in MacOS, and without restoration options built-in to the app, at the very least I don't think the shortcut should be enabled by default!

And no, OpenCode is not trash software by trash devs; I very much appreciate all the work that goes into open source development, and I'm very glad for options like OpenCode! Even if occasionally it gives me a fright. 😬

jeinselen avatar Jul 10 '26 03:07 jeinselen

Fork a new session from the archive one using OpenCode CLI directly

21hook avatar Aug 08 '26 04:08 21hook

How to Restore Archived Chats in OpenCode If you accidentally archived a chat and can't find it anywhere — don't worry, your data is not deleted. OpenCode stores all sessions in a SQLite database, and archiving simply sets a timestamp in the time_archived column. The chat data is still there, just hidden from the UI.

The Problem OpenCode currently has no built-in way to list or restore archived sessions. So when you hit that archive button by mistake, there's no obvious way to get it back. Now enter the following prompt on any chat page:

The Fix
Here's a prompt you can paste directly into OpenCode to restore all your archived chats:

My opencode chats disappeared after I accidentally archived them. Please restore them from the SQLite database.

1. Connect to the database at ~/.local/share/opencode/opencode.db using Python's sqlite3 module
2. List all archived sessions by running: SELECT id, title, datetime(time_created/1000, 'unixepoch', 'localtime') as created, datetime(time_archived/1000, 'unixepoch', 'localtime') as archived FROM session WHERE time_archived IS NOT NULL ORDER BY time_archived DESC;
3. Show me the list of archived sessions with their titles and dates
4. Restore all of them by setting time_archived = NULL
5. Verify the restoration was successful

Important: Do not delete anything. Only unarchive by setting time_archived to NULL.

That's all. Now restart OpenCode.

ni3dre avatar Aug 19 '26 04:08 ni3dre

This worked for me: My archived OpenCode chat sessions are missing from the sidebar. They are stored in the SQLite database at ~/.local/share/opencode/opencode.db in the session table. The column time_archived is set to a timestamp when a session is archived. To restore them, set time_archived = NULL. Please run a query to show me all archived sessions, ask me which one to restore, and then run the UPDATE query to fix it

When he asked me which session I wanted to restore, I said "restore all of them" and voilà!

Also, don't forget to remove the shortcut in Settings > Shortcuts > Archive session, just click on the keys binding and press delete.

Image

fabiovaldez avatar Sep 03 '26 20:09 fabiovaldez

@GrumpyEqualTrue Try the table session_v2

clover-yan avatar Nov 12 '26 02:11 clover-yan