anomalyco / anomalyco/opencode

Clearing time.archived silently fails, so archived sessions cannot be restored

Open
#47,849 1 comment 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.