anomalyco / anomalyco/opencode
Clearing time.archived silently fails, so archived sessions cannot be restored
@nexxeln is already working on this.
Since Sep 7, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Clearing time.archived on a session returns HTTP 200 and does nothing, so a session can be archived but never restored. Two independent defects sit on that path, and either one alone is enough to make it unreachable — which is why adding an "Unarchive" button doesn't fix it.
1. packages/core/src/session/projector.ts
time_archived: info.time.archived,
This passes undefined when the timestamp is being cleared. Drizzle omits undefined keys from .set(), so that means "leave this column alone", not "set NULL". The row keeps its previous value.
2. The session update handler (server/routes/instance/httpapi/handlers/session.ts)
if (ctx.payload.time?.archived !== undefined) {
yield* session.setArchived(...)
}
A client clearing the field sends {"time":{}}, because JSON.stringify drops undefined-valued properties. So the guard short-circuits and setArchived is never called.
Steps to reproduce
Against a local opencode serve:
# archive
curl -X PATCH localhost:4096/session/$SID -H 'content-type: application/json' \
-H "x-opencode-directory: $PWD" -d '{"time":{"archived":1700000000000}}'
# -> time.archived = 1700000000000
# attempt to clear
curl -X PATCH localhost:4096/session/$SID -H 'content-type: application/json' \
-H "x-opencode-directory: $PWD" -d '{"time":{}}'
# -> 200 OK, but time.archived is still 1700000000000
Note ArchivedTimestamp is Schema.Finite and deliberately accepts 0 and negative values for legacy compatibility, so a truthiness check on archived is also incorrect — a session stored with 0 reads as active.
OpenCode version
dev @ 1b937c8 (also present in every version with the current projector)
Operating System
macOS 15 (server-side bug, not platform specific)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.