Desktop 2.0.18: /compact slash command missing after update
Description
Manual compaction through /compact worked in the previously installed OpenCode Desktop version. After updating to 2.0.18, /compact is missing from the slash-command menu. Other expected slash commands are still available.
Expected: /compact remains available to manually compact the current conversation, as it was before the update.
Actual: The command cannot be found in the desktop slash-command menu, so manual compaction cannot be triggered through that menu.
This is a regression in previously working desktop functionality. The exact last working version has not been confirmed.
Plugins
No response
OpenCode version
2.0.18 (Desktop)
Steps to reproduce
- Update OpenCode Desktop to 2.0.18.
- Open a conversation and type
/in the chat input to display the slash-command menu. - Look for
/compact. - Observe that
/compactis missing while other expected slash commands are present.
Screenshot and/or share link
No response
Operating System
No response
Terminal
Not applicable — OpenCode Desktop.
This issue might be a duplicate of an existing issue. Please check:
- #31636:
/compactwas reported missing from Desktop command autocomplete after an update.
After fiddling with the open session to re-confirm I used it before, the command is now available. This may be an intermittent bug.
Happened again on 2.0.20. The bug seems intermittent.
After opening a new tab and returning to the old one, the command was available again.
I also ran into this today on both the desktop app and the CLI. Occasionally the /compact command goes missing, switching tabs sometimes fixes it.
Version: 2.1.1 (desktop and CLI)
Thanks for the report and the follow-ups about when it happens. I couldn't reproduce this here because my sandbox can't run the desktop app, so a maintainer with OpenCode Desktop will need to look at it.
From the code, /compact only shows when the current session has at least one loaded user message that hasn't been reverted. /undo and /fork use the same check. If the session's messages aren't loaded yet when a tab is restored or switched back to, all three would be missing until something reloads them, which would fit switching tabs bringing it back. That's only a guess for now.
Next time it happens, these would help:
- Are
/undoand/forkmissing at the same moment as/compact? - Did it start right after opening the app, restoring a tab, or switching tabs?
- Your operating system.
Related:
- #54279: session commands, including
/compact, are missing on a new session until the first message is sent. That's a different case from yours, since your session already has messages.
Reproduced on the Web UI (server connection) with opencode 2.2.4 — and this time the companion commands can be confirmed: in the affected session, /undo and /fork are missing at the same moment as /compact. Typing /co offered only /connect and /reload.
The behavior is consistent within a session but differs between sessions: once affected, the session stays affected; not every session is affected. So far only seen in long-running sessions, which fits the "messages not loaded vs. whole history" theory — these sessions have a long history that is (partially?) not loaded in the browser.
Additional data point: the gap is specific to the web/desktop suggestions — the same build (2.2.4) always lists /compact in the TUI, including in long-running sessions.
Screenshot of the affected state: https://github.com/anomalyco/opencode/issues/60841 (opened as a likely duplicate and pointing here).
Reproducing on the Web UI as well, with the exact tab-switch workaround — cross-referencing here since #61246 is being treated as a duplicate of this issue.
Setup
- opencode 2.2.0 (channel latest), server + Web UI in a browser (mobile Chrome on Android; the app is served from a local Termux node server on the same device).
- The "Session / Changes / More" tab strip is the web/desktop mobile layout, so this is definitely the Web UI and not the TUI.
What happens
- Work in an existing session and let the assistant finish a turn completely — the run has ended, nothing is in flight, no pending permission or question.
- Type
/compact: the slash menu reports no matching commands. It stays missing even after typing the full command name, not just a prefix. - Press Enter anyway:
/compactis sent to the model as ordinary chat text instead of invoking the command. Compaction does not run, and a stray user message is appended to the session — so the failure is silent rather than just a UI annoyance.
Workaround
Changing the top tab from Session to Changes or More and then back to Session makes /compact reappear in the menu, with the same prompt content and no other state change (no /reload, no message sent). That fits the "session view re-mounted → messages reloaded" theory.
On the /undo and /fork question
I could not confirm whether those two are missing from the slash menu at the same moment — I only tried /compact while it was broken. What I can confirm is that the per-message UI still works when the bug is present: the revert (undo) button and the Fork button under individual messages remain available and functional. So if /undo and /fork are affected at all, it looks limited to the slash-command registry/autocomplete rather than to the underlying message-loading state. I'll check the slash menu for all three next time it happens and follow up here.
Frequency Intermittent per session, but the tab-switch workaround worked every time it occurred; not tied to a specific project or workspace. I cannot yet say whether session/history length matters — next time it happens I'll note the message count in the affected session.
Deterministic reproduction and root cause for the "loaded user messages" theory
I hit this consistently in a long session, and traced it to a specific client-side condition. In this case it is deterministic, not intermittent, and it does not need a tab switch to reproduce.
Environment
- OpenCode Desktop 2.2.5 (server 2.2.5), Windows 11 10.0.26200 x64
- Session with a long single turn: more than 50 messages between the last two user prompts (many assistant/tool steps)
Reproduction
- Open a session whose newest message page (default 50 messages) contains only one user message.
- Stage an undo on that user message (revert), so
session.revert.messageIDpoints at it. - Type
/in the composer. /compactis missing, together with/undoand/fork(all three share the same predicate).
Cause
In the Desktop app the command is registered as:
sessionCommand({
id: "session.compact",
slash: "compact",
disabled: !actions.session.identity.params.id || actions.session.history.visibleUserMessages().length === 0,
onSelect: compact,
})
and the slash suggestions drop disabled entries:
command.options.filter((item) => !item.disabled && !item.id.startsWith("suggested.") && item.slash)
visibleUserMessages is:
export function selectVisibleSessionUserMessages(messages, revertMessageID) {
if (!revertMessageID) return messages
return messages.filter((message) => message.id < revertMessageID)
}
Two details combine:
messages()is the loaded page, not the full history (the client default page is 50 messages).- With a staged revert, every loaded user message with
id >= revertMessageIDis filtered out.
In my session, the last 50 loaded messages contained exactly one user message, and it was the revert target. Result: visibleUserMessages().length === 0, so /compact, /undo and /fork are filtered out of the slash menu. All older user messages are on the previous page and are not loaded while the transcript stays pinned to the bottom.
This is the deterministic version of the hypothesis in https://github.com/anomalyco/opencode/issues/51638#issuecomment-6459957309.
Expected
An existing session with a long history keeps /compact available even with a staged revert. The predicate should use the full session history, not the loaded page (or a staged revert should not count as "no history").
Actual
The command silently disappears from the slash menu. Typing the full /compact sends it to the model as ordinary chat text instead of invoking the command.
Workarounds
- Run
/redo(clears the staged revert; same asDELETE /api/session/{id}/revert). - Scroll up until an older user message is loaded.
- Call the API directly:
POST /api/session/{id}/compactwith{}.
Related
#54279 is the same predicate on a draft session, where there are no user messages at all.
Diagnostics
- opencode 2.2.5, Desktop, Windows 11 10.0.26200 x64.
- Local plugins: engram, model-variants, opencode-review-transport, skill-registry, telemetry-runtime. The command is core, not plugin-registered.
Deterministic reproduction and root cause for the "loaded user messages" theory
I hit this consistently in a long session, and traced it to a specific client-side condition. In this case it is deterministic, not intermittent, and it does not need a tab switch to reproduce.
Environment
- OpenCode Desktop 2.2.5 (server 2.2.5), Windows 11 10.0.26200 x64
- Session with a long single turn: more than 50 messages between the last two user prompts (many assistant/tool steps)
Reproduction
- Open a session whose newest message page (default 50 messages) contains only one user message.
- Stage an undo on that user message (revert), so
session.revert.messageIDpoints at it.- Type
/in the composer./compactis missing, together with/undoand/fork(all three share the same predicate).Cause
In the Desktop app the command is registered as:
sessionCommand({ id: "session.compact", slash: "compact", disabled: !actions.session.identity.params.id || actions.session.history.visibleUserMessages().length === 0, onSelect: compact, }) and the slash suggestions drop disabled entries:
command.options.filter((item) => !item.disabled && !item.id.startsWith("suggested.") && item.slash)
visibleUserMessagesis:export function selectVisibleSessionUserMessages(messages, revertMessageID) { if (!revertMessageID) return messages return messages.filter((message) => message.id < revertMessageID) } Two details combine:
messages()is the loaded page, not the full history (the client default page is 50 messages).- With a staged revert, every loaded user message with
id >= revertMessageIDis filtered out.In my session, the last 50 loaded messages contained exactly one user message, and it was the revert target. Result:
visibleUserMessages().length === 0, so/compact,/undoand/forkare filtered out of the slash menu. All older user messages are on the previous page and are not loaded while the transcript stays pinned to the bottom.This is the deterministic version of the hypothesis in #51638 (comment).
Expected
An existing session with a long history keeps
/compactavailable even with a staged revert. The predicate should use the full session history, not the loaded page (or a staged revert should not count as "no history").Actual
The command silently disappears from the slash menu. Typing the full
/compactsends it to the model as ordinary chat text instead of invoking the command.Workarounds
- Run
/redo(clears the staged revert; same asDELETE /api/session/{id}/revert).- Scroll up until an older user message is loaded.
- Call the API directly:
POST /api/session/{id}/compactwith{}.Related
#54279 is the same predicate on a draft session, where there are no user messages at all.
Diagnostics
- opencode 2.2.5, Desktop, Windows 11 10.0.26200 x64.
- Local plugins: engram, model-variants, opencode-review-transport, skill-registry, telemetry-runtime. The command is core, not plugin-registered.
ACtually found with help of the Ai. I hope it helps.
作为OpenCode的用户,你可以在AI里找到确切问题之后,顺着该对话,让AI进行一个修改,并提交一个RP上去。但请确认该RP一定要正确,并进行review。
Nocturn-Z @.***> 于 2026年11月4日周三 11:48写道:
Nocturn-Z left a comment (anomalyco/opencode#51638) https://github.com/anomalyco/opencode/issues/51638#issuecomment-6622004619
Deterministic reproduction and root cause for the "loaded user messages" theory
I hit this consistently in a long session, and traced it to a specific client-side condition. In this case it is deterministic, not intermittent, and it does not need a tab switch to reproduce. Environment
- OpenCode Desktop 2.2.5 (server 2.2.5), Windows 11 10.0.26200 x64
- Session with a long single turn: more than 50 messages between the last two user prompts (many assistant/tool steps)
Reproduction
- Open a session whose newest message page (default 50 messages) contains only one user message.
- Stage an undo on that user message (revert), so session.revert.messageID points at it.
- Type / in the composer.
- /compact is missing, together with /undo and /fork (all three share the same predicate).
Cause
In the Desktop app the command is registered as:
sessionCommand({ id: "session.compact", slash: "compact", disabled: !actions.session.identity.params.id || actions.session.history.visibleUserMessages().length === 0, onSelect: compact, }) and the slash suggestions drop disabled entries:
command.options.filter((item) => !item.disabled && !item.id.startsWith("suggested.") && item.slash) visibleUserMessages is:
export function selectVisibleSessionUserMessages(messages, revertMessageID) { if (!revertMessageID) return messages return messages.filter((message) => message.id < revertMessageID) } Two details combine:
- messages() is the loaded page, not the full history (the client default page is 50 messages).
- With a staged revert, every loaded user message with id >= revertMessageID is filtered out.
In my session, the last 50 loaded messages contained exactly one user message, and it was the revert target. Result: visibleUserMessages().length === 0, so /compact, /undo and /fork are filtered out of the slash menu. All older user messages are on the previous page and are not loaded while the transcript stays pinned to the bottom.
This is the deterministic version of the hypothesis in #51638 (comment) https://github.com/anomalyco/opencode/issues/51638#issuecomment-6459957309 . Expected
An existing session with a long history keeps /compact available even with a staged revert. The predicate should use the full session history, not the loaded page (or a staged revert should not count as "no history"). Actual
The command silently disappears from the slash menu. Typing the full /compact sends it to the model as ordinary chat text instead of invoking the command. Workarounds
- Run /redo (clears the staged revert; same as DELETE /api/session/{id}/revert).
- Scroll up until an older user message is loaded.
- Call the API directly: POST /api/session/{id}/compact with {}.
Related
#54279 https://github.com/anomalyco/opencode/issues/54279 is the same predicate on a draft session, where there are no user messages at all. Diagnostics
- opencode 2.2.5, Desktop, Windows 11 10.0.26200 x64.
- Local plugins: engram, model-variants, opencode-review-transport, skill-registry, telemetry-runtime. The command is core, not plugin-registered.
ACtually found with help of the Ai. I hope it helps.
— Reply to this email directly, view it on GitHub https://github.com/anomalyco/opencode/issues/51638?email_source=notifications&email_token=B2CQZAZPPEXVSD26ZDCWLU35XKRHDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMNRSGIYDANBWGE42M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6622004619, or unsubscribe https://github.com/notifications/unsubscribe-auth/B2CQZA2PKDE6YM3X5XG4KD35XKRHDAVCNFSNUABFKJSXA33TNF2G64TZHM4TONJXGM2DGMJZHNEXG43VMU5TKNRQGE2TQMZSGY32C5QC . You are receiving this because you commented.Message ID: @.***>
Also reproducing this on 2.2.7 running in service mode.
/compact was missing from the slash-command menu in a long-running session.
Interesting data point: after I triggered a compaction once via the API
(POST /api/session/<id>/compact), the command came back immediately.
My guess is that the API call injected a message into the session, which forced
the TUI to reload the session's messages — and that's exactly the condition
@opencodejr described ("at least one loaded user message"). So it looks like
anything that refreshes the message list heals the menu, while a stale/unloaded
list keeps /compact, /undo and /fork hidden.
Workaround so far: poke the session with one API call and the command reappears.
Still happening in the Web UI on 2.4.1. The check described above is unchanged there, and it is easy to hit: the app loads only the newest 20 messages of a session (40 with the "compact" timeline preset, runtime.tsx#L216), and each model step is its own message, so one reply with ~20 tool calls is enough to push the last user prompt out of the loaded page.
Two things that point to a simple fix:
- The TUI has no such check. Its
session.compactcommand (routes/session/index.tsx#L1103-L1126) is always offered, callssession.compactand shows any error as a toast. That is why the same build always lists/compactin the TUI, as mentioned above. - The server already handles "nothing to compact". A manual compaction with no history is recorded as a failed compaction with
compaction.unavailable/ "Nothing to compact yet" (compaction.ts#L122, covered by the "explains when manual compaction has no history" test inpackages/core/test/session-runner.test.ts).
So the client-side visibleUserMessages().length === 0 condition on /compact (use-session-commands.tsx#L540) doesn't guard against anything the server doesn't already handle. Because it only sees the loaded page (minus anything at or after a staged revert), and the slash menu drops disabled commands (composer/model.ts#L275), it hides /compact in exactly the long sessions where it's needed.
Suggested fix: keep only the "a session is open" part of the condition for /compact, as the TUI does, and let the server's "Nothing to compact yet" show up for an empty session. /fork uses the same condition (#L555), but it does need a message to fork from, so it would need a different fix (for example, a check that also counts older pages that haven't been loaded).
Confirming this is still reproducible on OpenCode Desktop 2.4.2 (bundled server 2.4.2), Windows 11 Pro 10.0.26300 x64. The CLI 2.3.2 TUI in the same project always offers /compact.
This matches the root cause traced in comment 6621944146 and the follow-up in comment 7141662502: the desktop command is registered with disabled: !session.identity.params.id || visibleUserMessages().length === 0, and the slash menu drops disabled entries.
Additional data point: /compact is missing from the desktop composer even though the server supports POST /api/session/{sessionID}/compact and already handles the "nothing to compact yet" case. The client-side check therefore isn't guarding anything the server doesn't handle — it only hides the command. I also verified there was no custom command or compaction config override on my machine; the behavior is entirely from the built-in command's disabled predicate.
I had opened #66832 with the local inspection details; that report is closed as a duplicate of this issue.