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
{{ message }}
Repository navigation
How to start a session via API and make its icon spin (currently does not spin) #54504
I create a session using opencode api post /api/session and gave it a prompt using opencode api post /api/session/<session_id>/prompt, when I load the session in the browser, it doesn't have a spinning icon, neither does it show "Working..." or "Thinking...", but it is working in the background because if I refresh the page, I see new information
The session ses_ed57cbb6bffes33ySg0dkNY1WZ is registered (exists in the API) and the prompt was accepted, but it never actually started running. That’s why the browser icon isn’t spinning.
Evidence from the API
GET /api/session/:id returns the session with no outcome, no time.idle — so it’s considered “active” but not completed.
Tokens went from ~6k output to ~11.6k output very quickly after creation, then stopped increasing (stayed at 11640 for >30 seconds). time.updated also hasn’t moved since ~215ms after creation.
GET /api/session/:id/messages and GET /api/session/:id/steps both return 404 Not Found. A running session that’s actually processing typically has steps/messages being created.
Evidence from logs
The first log entry for this SID is the prompt POST (POST /api/session/:id/prompt) at ~10:30:08. There’s no “session created” log for this SID in the tail we checked, but the session exists in the list.
After the prompt was posted, there are no errors logged for this SID, and no subsequent “run step/started/draining” or message-creation logs. The server did snapshot/git housekeeping around that time, but no agent execution started.
Why no spinner
The UI’s “working/spinning” indicator shows when the session is actively generating/streaming (assistant steps/messages in progress). This session is in a zombie state: created + prompt accepted, but execution never initialized properly. Since there are no active steps/messages being produced, there’s nothing to animate — so the icon appears static even though the API lists the session as “active”.
Bottom line
The script did the right thing (created session, posted prompt). The icon isn’t spinning because the opencode server never actually kicked off the run for that session after receiving the prompt. The prompt was queued but execution stalled before producing any steps/messages, so there’s no live activity to show as spinning.
Thanks for the report! I tried to reproduce this on v2.0.26 (on Linux) and couldn't:
I created a session with POST /api/session and sent a prompt with POST /api/session/<id>/prompt, using a model that takes a while to reply.
GET /api/session/active listed the session as running while it worked.
When I opened that session in the web UI, it showed Working and the stop button. This happened whether I opened the page before or after sending the prompt.
To narrow it down, could you share:
The exact output of opencode --version.
How you open it in the browser: opencode pair / the web UI served by opencode serve, or the desktop app? Which browser?
Whether you open the session page before or after sending the prompt, and whether you open it directly or from the session list. (The session list on the home screen doesn't show a spinner. Is that the spinner you mean?)
The exact opencode api commands you ran (with the request body), and the directory you ran them from compared with the project open in the browser.
While it's working, the output of opencode api get /api/session/active.
A screenshot of the page while it's working in the background.
You can reply here, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.
Possibly related: #52361 (the web app can miss live events and show stale session status until a refresh).
changed the title [-]Session created by API does not have a spinning icon[/-][+]How to start a session via API and make its icon spin (currently does not spin)[/+]on Oct 11, 2026
Thanks for the details! I tried again on v2.0.24, following your steps:
POST /api/session, then POST /api/session/<id>/prompt, using a model that streams its reply slowly for a couple of minutes.
After the prompt was sent, I opened the session directly with a URL built from the returned session ID: /server/<key>/session/<id>.
It worked as expected for me:
The session tab icon turned into the animated progress indicator (the small grid of dots).
The stop button showed in the composer.
The reply streamed in live without a refresh.
"Working" appears when no text has arrived yet. Once text is streaming, the text itself replaces it.
I tested on Linux with a simulated model, not on Windows with a real provider, so something in your setup may differ. To narrow it down, could you share:
A screenshot of the page while the session is working in the background. Do you see the stop button (■) in the composer, or a send button?
Which browser you use, and the exact URL shape you open (with the session ID redacted if you like).
Whether new text appears on its own while the page is open, or only after a refresh.
While it's working, the output of opencode api get /api/session/active.
Any errors in the browser's developer console (F12 → Console) when you open the page.
Possibly related: #52361 (the web app can miss live events and show stale session status until a refresh).
4) Exact opencode api commands I ran (and working dir)
I ran this from /home/dv1/repo-12/example.com/example/dev-tools/bash (the script's working context):
Create the session
opencode api post /api/session --data '{ "location": {"directory": "/home/dv1/code-server/projects/llm-example-project/current"}, "title": "Issue 2 - example-project", "model": {"providerID": "opencode", "id": "big-pickle"}}'
Response included the session ID (e.g. ses_ed57290e8ffe5IcFnwBnQOIPtH).
Send the initial prompt
opencode api post /api/session/<session_id>/prompt --data '{ "text": "Read the issue at https://example.com/example/example-project/issues/2 and implement it in this project. The project repository is https://example.com/example/example-project."}'
(Defensive) Poll for steps to start (added in the script)
foriin 1 2 3 4 5;do
opencode api get "/api/session/<session_id>/steps">/dev/null 2>&1&&break
sleep 1
[ "$i"-eq 3 ] && opencode api post "/api/session/<session_id>/prompt" --data "$PROMPT_PAYLOAD">/dev/null ||truedone
Comment on the Gitea issue (best-effort)
opencode api get "/api/session/<session_id>"# just to confirm state (optional)
but the actual base was opencode.dv1.example.com in my environment; the session ID is what matters. The project dire
ctory matches.
5) opencode api get /api/session/active output while it's "working"
For ses_ed57290e8ffe5IcFnwBnQOIPtH, while tokens were increasing but no steps/messages existed yet, there were no
active sessions reported:
$ opencode api get /api/session/active
{"data":[]}
The session exists in the full list with tokens increasing but no outcome, no time.idle, and no steps/messages cre
ated yet.
6) Screenshot/observation
No screenshot, but when loading the direct session URL immediately after posting the prompt, the top-level "working/sp
inning" indicator never animates even though tokens increase server-side. Execution can start (tokens increment) befor
e the first step/message is created; in that window /api/session/active returns empty and the UI doesn't show the sp
inner until the first step/message appears.
Thanks for the extra details! I tried again on v2.0.24, as close to your script as I could:
I created the session with POST /api/session using an explicit location.directory (a different git repo from the server's default directory) and a title, then sent the prompt.
I also ran your retry loop: poll /api/session/<id>/steps, then re-send the prompt about 3 s later.
After the prompt was sent, I opened the session directly at /server/<key>/session/<id>.
Each time the page showed the session as busy: the animated progress indicator on the tab, the stop button in the composer, and Working until the reply text started streaming in live.
Two things in your script and output stood out:
/api/session/<id>/steps doesn't exist, so it always returns 404 and your loop will always re-send the prompt. That leaves the prompt in the session twice. It didn't hide the busy state for me, but you probably want to drop that retry.
/api/session/active on v2.0.24 always returns an object keyed by session ID (e.g. {"data":{"ses_…":{"type":"running"}}}), never an array. The {"data":[]} you quoted suggests that output came from somewhere else, perhaps a different server or version. Could you run opencode --version and opencode api get /api/session/active again, against the same server your browser is connected to, while the session is working, and paste the raw output?
It would also help to have:
A screenshot of the session page while it's working, showing whether the stop button (■) or the send button is in the composer.
Whether new text appears on its own while the page is open, or only after a refresh.
Your browser, and whether opencode.<your domain> goes through a reverse proxy (nginx, Caddy, Cloudflare, …). Live updates are streamed over a long-lived connection that some proxies buffer or cut, which would make the page only update on refresh.
Possibly related: #52361 (the web app can miss live events and show stale session status until a refresh).
Thanks, that example helps! I think it explains what you're seeing.
--fork doesn't run the prompt in the session you pass with --session. It makes a copy of that session, with a new session ID, and runs the prompt in the copy (the flag's help text is "Fork the session when continuing"). So:
ses_edb34cacdffeG3f87tH2WIZD5b, the original, stays idle. When you open it in the browser, it correctly shows no progress indicator.
The work happens in the new forked session. Open that one and you should see the animated indicator, the stop button and "Working". It should appear in the web UI's session list, or you can get its ID from opencode session list or opencode api get /api/session.
If you want the run to happen in the original session and show up there, drop --fork:
opencode run "..." --model=opencode/big-pickle --session=ses_edb34cacdffeG3f87tH2WIZD5b
This matches what I saw earlier. When the prompt is sent to the same session that's open in the browser (with POST /api/session/<id>/prompt or without --fork), the busy state shows correctly on v2.0.24.
If you still see no indicator when opening the session that's actually running (the forked one, or the same session without --fork), please reply with its ID as shown in the browser URL, plus a screenshot, and we'll look again.
Thanks for sticking with this. Your opencode run --session=… example helped narrow it down, and I can now reproduce what you're seeing on v2.0.24.
It happens when two OpenCode server processes share the same session database:
opencode run (and, I believe, opencode api) talks to the background service, and that's where the turn actually runs.
The browser is connected to a different server process, e.g. an opencode serve you started yourself behind opencode.<your domain>.
Only the process running the turn knows the session is busy and sends live updates. The other one only sees what has been saved to the database. So the page shows no progress indicator, a send button instead of stop, and no live text, and a refresh shows the new content. That matches what you describe.
In my run, while the turn was streaming:
The background service's /api/session/active listed the session as running.
The opencode serve process returned {"data":{}}.
The page served by opencode serve looked like the screenshot below.
The script below reproduces it. On the latest dev (d21b079), the two processes still disagree about whether the session is running. I checked that through the API; I couldn't open the web UI from a source build.
To confirm this is your setup: what does the browser at opencode.<your domain> connect to (the background service, or an opencode serve you start yourself)? You can compare the two by running opencode api get /api/session/active and fetching /api/session/active from the server the browser uses, while a run is in progress.
Until this is addressed, a workaround is to send the work to the same server the browser uses, e.g. opencode run --server <that server's URL> --session=<id> "…". Or have the browser use the background service itself (opencode pair prints links for it).
Reproduction script (repro.sh)
#!/usr/bin/env bash# #54504: the web UI served by `opencode serve` shows no busy state for a session# that is running in the background service (via `opencode run --session` or# `opencode api post .../prompt`), because they are two separate server processes# sharing one database. Refreshing shows the new content; status/live events never arrive.## Needs: opencode (v2), bun, curl, jq. Uses a fake OpenAI-compatible model that streams for ~2 min.# Usage: OPENCODE=opencode ./repro.sh (or OPENCODE="bun ... packages/cli/src/index.ts" for a checkout)set -euo pipefail
OC=${OPENCODE:-opencode}
W=$(mktemp -d /tmp/oc54504.XXXX);export HOME=$W/home; mkdir -p $HOME$W/proj/.opencode
cd$W/proj && git init -q
cat >$W/fake-llm.ts <<'EOF'Bun.serve({ port: 7777, idleTimeout: 0, fetch() { const enc = new TextEncoder() return new Response(new ReadableStream({ async start(c) { const send = (o: unknown) => c.enqueue(enc.encode(`data: ${JSON.stringify(o)}\n\n`)) const base = { id: "x", object: "chat.completion.chunk", created: 0, model: "fake" } for (let i = 0; i < 120; i++) { send({ ...base, choices: [{ index: 0, delta: { role: "assistant", content: `word${i} ` }, finish_reason: null }] }); await Bun.sleep(1000) } send({ ...base, choices: [{ index: 0, delta: {}, finish_reason: "stop" }] }); c.enqueue(enc.encode("data: [DONE]\n\n")); c.close() } }), { headers: { "content-type": "text/event-stream" } })} })EOF
bun $W/fake-llm.ts & FAKE=$!
cat > .opencode/opencode.jsonc <<'EOF'{ "model": "fake/m", "snapshots": false, "permissions": [{ "action": "*", "resource": "*", "effect": "allow" }], "providers": { "fake": { "name": "Fake", "package": "@opencode-ai/ai/providers/openai/chat", "settings": { "apiKey": "k", "baseURL": "http://127.0.0.1:7777/v1" }, "models": { "m": { "name": "Fake", "capabilities": { "tools": true, "input": ["text"], "output": ["text"] }, "limit": { "context": 128000, "output": 16000 } } } } } }EOF# 1. The server the browser uses.$OC serve --port 4199 >$W/serve.log 2>&1& SERVE=$!
sleep 6; P=$(grep -o 'server password .*'$W/serve.log | awk '{print $3}'); U=http://127.0.0.1:4199
trap'kill $FAKE $SERVE 2>/dev/null || true' EXIT
# 2. A session, then a long run from the CLI (goes to the background service, a different process).
SID=$(curl -s -u opencode:$P -X POST -H 'content-type: application/json'$U/api/session -d '{"title":"run via cli"}'| jq -r .data.id)$OC run --session=$SID work-for-a-while >$W/run.log 2>&1&foriin$(seq 1 30);do [ -f$HOME/.local/state/opencode/service.json ] &&break; sleep 1;done; sleep 5
J=$HOME/.local/state/opencode/service.json
echo"background service $(jq -r .url $J) /api/session/active: $(curl -s -u opencode:$(jq -r .password $J)$(jq -r .url $J)/api/session/active)"echo"opencode serve $U /api/session/active: $(curl -s -u opencode:$P$U/api/session/active)"echo"Open $U (password $P) -> /server/$(printf %s "$U"| base64 | tr '+/''-_'| tr -d '=')/session/$SID : no spinner, send button instead of stop, no live text"
sleep 60
Closing as a duplicate of #55098: the spinner doesn't move because two server processes share one database, which #55098 tracks. Please follow that issue for updates and add any extra details there.
Activity
bilogic commentedon Oct 11, 2026
The session
ses_ed57cbb6bffes33ySg0dkNY1WZis registered (exists in the API) and the prompt was accepted, but it never actually started running. That’s why the browser icon isn’t spinning.Evidence from the API
GET /api/session/:idreturns the session with nooutcome, notime.idle— so it’s considered “active” but not completed.time.updatedalso hasn’t moved since ~215ms after creation.GET /api/session/:id/messagesandGET /api/session/:id/stepsboth return 404 Not Found. A running session that’s actually processing typically has steps/messages being created.Evidence from logs
POST /api/session/:id/prompt) at ~10:30:08. There’s no “session created” log for this SID in the tail we checked, but the session exists in the list.Why no spinner
The UI’s “working/spinning” indicator shows when the session is actively generating/streaming (assistant steps/messages in progress). This session is in a zombie state: created + prompt accepted, but execution never initialized properly. Since there are no active steps/messages being produced, there’s nothing to animate — so the icon appears static even though the API lists the session as “active”.
Bottom line
The script did the right thing (created session, posted prompt). The icon isn’t spinning because the opencode server never actually kicked off the run for that session after receiving the prompt. The prompt was queued but execution stalled before producing any steps/messages, so there’s no live activity to show as spinning.
opencode-agent commentedon Oct 11, 2026
Thanks for the report! I tried to reproduce this on v2.0.26 (on Linux) and couldn't:
POST /api/sessionand sent a prompt withPOST /api/session/<id>/prompt, using a model that takes a while to reply.GET /api/session/activelisted the session asrunningwhile it worked.To narrow it down, could you share:
opencode --version.opencode pair/ the web UI served byopencode serve, or the desktop app? Which browser?opencode apicommands you ran (with the request body), and the directory you ran them from compared with the project open in the browser.opencode api get /api/session/active.You can reply here, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.
Possibly related: #52361 (the web app can miss live events and show stale session status until a refresh).
[-]Session created by API does not have a spinning icon[/-][+]How to start a session via API and make its icon spin (currently does not spin)[/+]bilogic commentedon Oct 11, 2026
opencode-agent commentedon Oct 11, 2026
Thanks for the details! I tried again on v2.0.24, following your steps:
POST /api/session, thenPOST /api/session/<id>/prompt, using a model that streams its reply slowly for a couple of minutes./server/<key>/session/<id>.It worked as expected for me:
I tested on Linux with a simulated model, not on Windows with a real provider, so something in your setup may differ. To narrow it down, could you share:
opencode api get /api/session/active.Possibly related: #52361 (the web app can miss live events and show stale session status until a refresh).
bilogic commentedon Oct 11, 2026
4) Exact
opencode apicommands I ran (and working dir)I ran this from
/home/dv1/repo-12/example.com/example/dev-tools/bash(the script's working context):Response included the session ID (e.g.
ses_ed57290e8ffe5IcFnwBnQOIPtH).The browser URL I opened was:
but the actual base was
opencode.dv1.example.comin my environment; the session ID is what matters. The project directory matches.
5)
opencode api get /api/session/activeoutput while it's "working"For
ses_ed57290e8ffe5IcFnwBnQOIPtH, while tokens were increasing but no steps/messages existed yet, there were noactive sessions reported:
$ opencode api get /api/session/active {"data":[]}The session exists in the full list with tokens increasing but no
outcome, notime.idle, and no steps/messages created yet.
6) Screenshot/observation
No screenshot, but when loading the direct session URL immediately after posting the prompt, the top-level "working/sp
inning" indicator never animates even though tokens increase server-side. Execution can start (tokens increment) befor
e the first step/message is created; in that window
/api/session/activereturns empty and the UI doesn't show the spinner until the first step/message appears.
opencode-agent commentedon Oct 11, 2026
Thanks for the extra details! I tried again on v2.0.24, as close to your script as I could:
POST /api/sessionusing an explicitlocation.directory(a different git repo from the server's default directory) and a title, then sent the prompt./api/session/<id>/steps, then re-send the prompt about 3 s later./server/<key>/session/<id>.Each time the page showed the session as busy: the animated progress indicator on the tab, the stop button in the composer, and Working until the reply text started streaming in live.
Two things in your script and output stood out:
/api/session/<id>/stepsdoesn't exist, so it always returns 404 and your loop will always re-send the prompt. That leaves the prompt in the session twice. It didn't hide the busy state for me, but you probably want to drop that retry./api/session/activeon v2.0.24 always returns an object keyed by session ID (e.g.{"data":{"ses_…":{"type":"running"}}}), never an array. The{"data":[]}you quoted suggests that output came from somewhere else, perhaps a different server or version. Could you runopencode --versionandopencode api get /api/session/activeagain, against the same server your browser is connected to, while the session is working, and paste the raw output?It would also help to have:
opencode.<your domain>goes through a reverse proxy (nginx, Caddy, Cloudflare, …). Live updates are streamed over a long-lived connection that some proxies buffer or cut, which would make the page only update on refresh.Possibly related: #52361 (the web app can miss live events and show stale session status until a refresh).
opencode-agent commentedon Oct 11, 2026
Thanks, that example helps! I think it explains what you're seeing.
--forkdoesn't run the prompt in the session you pass with--session. It makes a copy of that session, with a new session ID, and runs the prompt in the copy (the flag's help text is "Fork the session when continuing"). So:ses_edb34cacdffeG3f87tH2WIZD5b, the original, stays idle. When you open it in the browser, it correctly shows no progress indicator.opencode session listoropencode api get /api/session.If you want the run to happen in the original session and show up there, drop
--fork:opencode run "..." --model=opencode/big-pickle --session=ses_edb34cacdffeG3f87tH2WIZD5bThis matches what I saw earlier. When the prompt is sent to the same session that's open in the browser (with
POST /api/session/<id>/promptor without--fork), the busy state shows correctly on v2.0.24.If you still see no indicator when opening the session that's actually running (the forked one, or the same session without
--fork), please reply with its ID as shown in the browser URL, plus a screenshot, and we'll look again.bilogic commentedon Oct 11, 2026
I get a session ID using
opencode api session.create --data '{}'Then run this
opencode-agent commentedon Oct 11, 2026
Thanks for sticking with this. Your
opencode run --session=…example helped narrow it down, and I can now reproduce what you're seeing on v2.0.24.It happens when two OpenCode server processes share the same session database:
opencode run(and, I believe,opencode api) talks to the background service, and that's where the turn actually runs.opencode serveyou started yourself behindopencode.<your domain>.In my run, while the turn was streaming:
/api/session/activelisted the session as running.opencode serveprocess returned{"data":{}}.opencode servelooked like the screenshot below.The script below reproduces it. On the latest
dev(d21b079), the two processes still disagree about whether the session is running. I checked that through the API; I couldn't open the web UI from a source build.To confirm this is your setup: what does the browser at
opencode.<your domain>connect to (the background service, or anopencode serveyou start yourself)? You can compare the two by runningopencode api get /api/session/activeand fetching/api/session/activefrom the server the browser uses, while a run is in progress.Until this is addressed, a workaround is to send the work to the same server the browser uses, e.g.
opencode run --server <that server's URL> --session=<id> "…". Or have the browser use the background service itself (opencode pairprints links for it).Reproduction script (repro.sh)
Run it:
bash repro.shneriousy commentedon Nov 23, 2026
Closing as a duplicate of #55098: the spinner doesn't move because two server processes share one database, which #55098 tracks. Please follow that issue for updates and add any extra details there.