You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The plugin API accepts archived in session.update, but the call succeeds without changing the session's archive state. The equivalent HTTP API call works.
I understand the archive is only used for the desktop and mobile apps at the moment, but I would like to expose it and set it via the plugin interface.
Thanks for the clear report. I reproduced this on 2.2.5, and it still happens on the latest dev (69269e4).
Steps: a plugin in .opencode/plugins/ creates a session, calls ctx.session.update({ sessionID, archived: true }), then reads the session back.
time.archived is still unset afterwards, and no error is raised.
A title update through the same ctx.session.update call does apply.
Archiving the same session through the HTTP API (PATCH /api/session/:sessionID with {"archived":true}) works.
The script below reproduces it against a release or a source checkout.
In the code, the plugin host's session.update (packages/core/src/plugin/host.ts) handles title, metadata and permissions, but has no archive/unarchive branch like the HTTP handler has. So archived: false is ignored too. I couldn't test that case from a plugin, because a plugin can't archive a session first.
Related: #61036 (your fix PR, which was auto-closed because it didn't link an issue) and #51468 (an earlier case where plugin session.update dropped metadata).
Reproduction script (repro.sh)
#!/usr/bin/env bash# Reproduces #61038: plugin ctx.session.update({ archived }) is silently ignored.# Usage: bash repro.sh -> uses `opencode` from PATH (e.g. @opencode/[email protected])# OC_DEV=/path/to/repo bash repro.sh -> runs the CLI from a source checkoutset -euo pipefail
WORK=$(mktemp -d /tmp/opencode/archive-repro.XXXX)
PROJ=$WORK/proj
mkdir -p "$PROJ/.opencode/plugins""$WORK/home"export HOME=$WORK/home XDG_CONFIG_HOME=$WORK/home/c XDG_DATA_HOME=$WORK/home/d XDG_STATE_HOME=$WORK/home/s XDG_CACHE_HOME=$WORK/home/k
export REPRO_OUT=$WORK/plugin.log
if [ -n"${OC_DEV:-}" ];then# Start a server from the checkout (its bunfig preload only applies inside the repo), then point the CLI at it.
PORT=${PORT:-47123}export OPENCODE_PASSWORD=repro-password
(cd "$OC_DEV/packages/cli"&& bun --conditions=browser src/index.ts serve --port "$PORT">"$WORK/server.log"2>&1&)
foriin$(seq 1 60);do grep -q "server listening""$WORK/server.log">/dev/null 2>&1&&break; sleep 1;doneoc() { bun --conditions=browser --preload="$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js""$OC_DEV/packages/cli/src/index.ts" --server "http://127.0.0.1:$PORT""$@"; }
PLUGIN_VERSION=latest
elseoc() { opencode "$@"; }
PLUGIN_VERSION=$(opencode --version | sed 's/^opencode v//')ficd"$PROJ"
git init -q
cat > .opencode/plugins/archive-repro.ts <<'EOF'import { Plugin } from "@opencode/plugin"import { appendFileSync } from "node:fs"const log = (...a: unknown[]) => appendFileSync(process.env.REPRO_OUT!, a.map((x) => (typeof x === "string" ? x : JSON.stringify(x))).join(" ") + "\n")export default Plugin.define({ id: "archive-repro", setup: async (ctx) => { setTimeout(async () => { try { const s = await ctx.session.create() log("created", s.id, "time.archived =", (await ctx.session.get({ sessionID: s.id })).time.archived ?? null) await ctx.session.update({ sessionID: s.id, archived: true }) log("after update({archived:true}) time.archived =", (await ctx.session.get({ sessionID: s.id })).time.archived ?? null) await ctx.session.update({ sessionID: s.id, title: "renamed-by-plugin" }) log("after update({title}) title =", (await ctx.session.get({ sessionID: s.id })).title) } catch (e) { log("error", String(e)) } }, 500) },})EOF
bun add -d "@opencode/plugin@$PLUGIN_VERSION">/dev/null 2>&1# Any request for this directory loads the project's plugins; retry until the plugin has logged.foriin$(seq 1 20);do
oc session list >/dev/null 2>&1||true
sleep 3
grep -q "after update({title})\|error""$REPRO_OUT"2>/dev/null &&breakdone
cat "$REPRO_OUT"if [ -n"${OC_DEV:-}" ];then pkill -f "src/index.ts serve --port $PORT"||true;else oc service stop >/dev/null 2>&1||true;fi
Activity
opencodejr commentedon Nov 1, 2026
Thanks for the clear report. I reproduced this on 2.2.5, and it still happens on the latest
dev(69269e4).Steps: a plugin in
.opencode/plugins/creates a session, callsctx.session.update({ sessionID, archived: true }), then reads the session back.time.archivedis still unset afterwards, and no error is raised.titleupdate through the samectx.session.updatecall does apply.PATCH /api/session/:sessionIDwith{"archived":true}) works.The script below reproduces it against a release or a source checkout.
In the code, the plugin host's
session.update(packages/core/src/plugin/host.ts) handlestitle,metadataandpermissions, but has no archive/unarchive branch like the HTTP handler has. Soarchived: falseis ignored too. I couldn't test that case from a plugin, because a plugin can't archive a session first.Related: #61036 (your fix PR, which was auto-closed because it didn't link an issue) and #51468 (an earlier case where plugin
session.updatedroppedmetadata).Reproduction script (repro.sh)
Run it:
bash repro.sh