Getting stuck at 'Running commands' > Shell > undefined #3605

Open
opened 2026-02-16 17:40:50 -05:00 by yindo · 12 comments
Owner

Originally created by @badrul on GitHub (Dec 16, 2025).

Originally assigned to: @adamdotdevin on GitHub.

Image

Application hangs indefinitely at the shell execution stage with an undefined reference.

Environment:

OS: Windows 10
OpenCode Version: 1.0.164
Console: cmder

Originally created by @badrul on GitHub (Dec 16, 2025). Originally assigned to: @adamdotdevin on GitHub. <img width="726" height="545" alt="Image" src="https://github.com/user-attachments/assets/dbb065fe-7f99-4cb1-80b1-b315022c0351" /> Application hangs indefinitely at the shell execution stage with an undefined reference. Environment: OS: Windows 10 OpenCode Version: 1.0.164 Console: cmder
yindo added the bugweb labels 2026-02-16 17:40:50 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 16, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #4239: TUI hangs when shell outputs massive log
  • #2940: OpenCode just hangs randomly after receiving instructions
  • #3273: MCP client failing makes opencode hang
  • #4061: Session hangs after file write tool execution with massive latency spike

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 16, 2025): This issue might be a duplicate of existing issues. Please check: - #4239: TUI hangs when shell outputs massive log - #2940: OpenCode just hangs randomly after receiving instructions - #3273: MCP client failing makes opencode hang - #4061: Session hangs after file write tool execution with massive latency spike Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Dec 16, 2025):

/oc any idea what could be causing this? look at what shell the packages/desktop uses for the pty ajd figure out what could result in this

@rekram1-node commented on GitHub (Dec 16, 2025): /oc any idea what could be causing this? look at what shell the packages/desktop uses for the pty ajd figure out what could result in this
Author
Owner

@opencode-agent[bot] commented on GitHub (Dec 16, 2025):

Now I have a complete picture. Let me summarize the findings:


Analysis: "Running commands > Shell > undefined" Issue

Root Cause

The issue is not directly related to the PTY shell detection in the desktop package. Instead, this appears to be related to how the bash tool renders in the UI when props.input.description is undefined.

Looking at the UI component in packages/ui/src/components/message-part.tsx lines 426-431:

<BasicTool
  icon="console"
  trigger={{
    title: "Shell",
    subtitle: props.input.description,
  }}
>

The subtitle is set to props.input.description. When the LLM calls the bash tool without providing the description parameter, this value is undefined.

In basic-tool.tsx line 51-60, there's a <Show when={trigger().subtitle}> check that should hide it when falsy. However, if the description is the literal string "undefined" (which can happen during JSON serialization/deserialization), it would still display.

Potential Causes

  1. The model is sending the literal string "undefined" as the description parameter instead of omitting it or sending null.

  2. JSON serialization issue: When tool inputs are serialized/deserialized, undefined values might be converted to the string "undefined".

  3. Windows-specific issue: On Windows with cmder, there may be something unusual about how the environment or tool inputs are being processed.

Shell Detection on Windows

The shell detection in packages/opencode/src/shell/shell.ts is actually robust and should never return undefined:

function fallback() {
  if (process.platform === "win32") {
    if (Flag.OPENCODE_GIT_BASH_PATH) return Flag.OPENCODE_GIT_BASH_PATH
    const git = Bun.which("git")
    if (git) {
      const bash = path.join(git, "..", "..", "bin", "bash.exe")
      if (Bun.file(bash).size) return bash  // ⚠️ Potential issue here
    }
    return process.env.COMSPEC || "cmd.exe"  // Always has fallback
  }
  // ...
}

One edge case: Bun.file(bash).size is async but is being used synchronously. This could return a Promise object that's truthy but not a valid shell path. However, this wouldn't produce the string "undefined".

Recommendation

The issue is most likely that the bash tool's description parameter is being displayed as the literal string "undefined". The fix would be to add defensive handling in the UI:

subtitle: props.input.description || undefined,

This ensures that falsy strings like empty string or the string "undefined" aren't displayed.

New%20session%20-%202025-12-17T02%3A14%3A08.920Z
opencode session  |  github run

@opencode-agent[bot] commented on GitHub (Dec 16, 2025): Now I have a complete picture. Let me summarize the findings: --- ## Analysis: "Running commands > Shell > undefined" Issue ### Root Cause The issue is **not directly related to the PTY shell detection** in the desktop package. Instead, this appears to be related to how the **bash tool** renders in the UI when `props.input.description` is `undefined`. Looking at the UI component in `packages/ui/src/components/message-part.tsx` lines 426-431: ```tsx <BasicTool icon="console" trigger={{ title: "Shell", subtitle: props.input.description, }} > ``` The `subtitle` is set to `props.input.description`. When the LLM calls the bash tool **without providing the `description` parameter**, this value is `undefined`. In `basic-tool.tsx` line 51-60, there's a `<Show when={trigger().subtitle}>` check that should hide it when falsy. However, if the description is the **literal string** `"undefined"` (which can happen during JSON serialization/deserialization), it would still display. ### Potential Causes 1. **The model is sending the literal string `"undefined"`** as the description parameter instead of omitting it or sending `null`. 2. **JSON serialization issue**: When tool inputs are serialized/deserialized, `undefined` values might be converted to the string `"undefined"`. 3. **Windows-specific issue**: On Windows with cmder, there may be something unusual about how the environment or tool inputs are being processed. ### Shell Detection on Windows The shell detection in `packages/opencode/src/shell/shell.ts` is actually **robust** and should never return `undefined`: ```typescript function fallback() { if (process.platform === "win32") { if (Flag.OPENCODE_GIT_BASH_PATH) return Flag.OPENCODE_GIT_BASH_PATH const git = Bun.which("git") if (git) { const bash = path.join(git, "..", "..", "bin", "bash.exe") if (Bun.file(bash).size) return bash // ⚠️ Potential issue here } return process.env.COMSPEC || "cmd.exe" // Always has fallback } // ... } ``` **One edge case**: `Bun.file(bash).size` is async but is being used synchronously. This could return a `Promise` object that's truthy but not a valid shell path. However, this wouldn't produce the string "undefined". ### Recommendation The issue is most likely that the **bash tool's `description` parameter is being displayed as the literal string "undefined"**. The fix would be to add defensive handling in the UI: ```tsx subtitle: props.input.description || undefined, ``` This ensures that falsy strings like empty string or the string "undefined" aren't displayed. <a href="https://opencode.ai/s/a85DDtQg"><img width="200" alt="New%20session%20-%202025-12-17T02%3A14%3A08.920Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI1LTEyLTE3VDAyOjE0OjA4LjkyMFo=.png?model=opencode/claude-opus-4-5&version=1.0.164&id=a85DDtQg" /></a> [opencode session](https://opencode.ai/s/a85DDtQg)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/20289278711)
Author
Owner

@badrul commented on GitHub (Dec 16, 2025):

running with --print-logs, i get these:

ERROR 2025-12-17T02:09:45 +151ms service=acp-command promise={} reason=NotFoundError Unhandled rejection
ERROR 2025-12-17T02:09:45 +1ms service=default e=NotFoundError rejection
INFO 2025-12-17T02:09:46 +461ms service=bus type=session.updated publishing
INFO 2025-12-17T02:09:46 +2ms service=bus type=session.diff publishing
ERROR 2025-12-17T02:09:47 +1013ms service=acp-command promise={} reason=NotFoundError Unhandled rejection
ERROR 2025-12-17T02:09:47 +0ms service=default e=NotFoundError rejection
INFO 2025-12-17T02:09:53 +6233ms service=session.summary title=Checking Current Status title
INFO 2025-12-17T02:09:53 +1ms service=bus type=message.updated publishing
ERROR 2025-12-17T02:09:54 +1005ms service=acp-command promise={} reason=NotFoundError Unhandled rejection
ERROR 2025-12-17T02:09:54 +0ms service=default e=NotFoundError rejection
INFO 2025-12-17T02:10:02 +8317ms service=snapshot hash=3745f8b408349c5a1ab621d58ef9f5f0642b16c1
cwd=C:[project path] git=C:[user path].local\share\opencode\snapshot\c5b6b9820d4608b7746befe7c7b05d559b3e8f05 tracking
INFO 2025-12-17T02:10:02 +3ms service=bus type=message.part.updated publishing
INFO 2025-12-17T02:10:02 +5ms service=bus type=message.part.updated publishing
ERROR 2025-12-17T02:10:03 +1002ms service=acp-command promise={} reason=NotFoundError Unhandled rejection
ERROR 2025-12-17T02:10:03 +0ms service=default e=NotFoundError rejection
INFO 2025-12-17T02:10:04 +978ms service=bus type=message.part.updated publishing
INFO 2025-12-17T02:10:05 +331ms service=bus type=message.part.updated publishing
INFO 2025-12-17T02:10:05 +8ms service=bus type=message.part.updated publishing
INFO 2025-12-17T02:10:05 +29ms service=permission sessionID=ses_4d84b8842ffedJ5Fi5cf25T3wS messageID=msg_b2a120e73002idlMUkP93KoBoH toolCallID=call_d4906847513741d9b6c3011e pattern=["git status *"] asking
INFO 2025-12-17T02:10:05 +1ms service=bus type=permission.updated publishing
ERROR 2025-12-17T02:10:05 +646ms service=acp-command promise={} reason=NotFoundError Unhandled rejection
ERROR 2025-12-17T02:10:05 +1ms service=default e=NotFoundError rejection
INFO 2025-12-17T02:10:05 +7ms service=bus type=message.part.updated publishing
INFO 2025-12-17T02:10:05 +2ms service=bus type=message.part.updated publishing
ERROR 2025-12-17T02:10:06 +1005ms service=acp-command promise={} reason=NotFoundError Unhandled rejection
ERROR 2025-12-17T02:10:06 +1ms service=default e=NotFoundError rejection

@badrul commented on GitHub (Dec 16, 2025): running with --print-logs, i get these: ERROR 2025-12-17T02:09:45 +151ms service=acp-command promise={} reason=NotFoundError Unhandled rejection ERROR 2025-12-17T02:09:45 +1ms service=default e=NotFoundError rejection INFO 2025-12-17T02:09:46 +461ms service=bus type=session.updated publishing INFO 2025-12-17T02:09:46 +2ms service=bus type=session.diff publishing ERROR 2025-12-17T02:09:47 +1013ms service=acp-command promise={} reason=NotFoundError Unhandled rejection ERROR 2025-12-17T02:09:47 +0ms service=default e=NotFoundError rejection INFO 2025-12-17T02:09:53 +6233ms service=session.summary title=Checking Current Status title INFO 2025-12-17T02:09:53 +1ms service=bus type=message.updated publishing ERROR 2025-12-17T02:09:54 +1005ms service=acp-command promise={} reason=NotFoundError Unhandled rejection ERROR 2025-12-17T02:09:54 +0ms service=default e=NotFoundError rejection INFO 2025-12-17T02:10:02 +8317ms service=snapshot hash=3745f8b408349c5a1ab621d58ef9f5f0642b16c1 cwd=C:\[project path] git=C:\[user path]\.local\share\opencode\snapshot\c5b6b9820d4608b7746befe7c7b05d559b3e8f05 tracking INFO 2025-12-17T02:10:02 +3ms service=bus type=message.part.updated publishing INFO 2025-12-17T02:10:02 +5ms service=bus type=message.part.updated publishing ERROR 2025-12-17T02:10:03 +1002ms service=acp-command promise={} reason=NotFoundError Unhandled rejection ERROR 2025-12-17T02:10:03 +0ms service=default e=NotFoundError rejection INFO 2025-12-17T02:10:04 +978ms service=bus type=message.part.updated publishing INFO 2025-12-17T02:10:05 +331ms service=bus type=message.part.updated publishing INFO 2025-12-17T02:10:05 +8ms service=bus type=message.part.updated publishing INFO 2025-12-17T02:10:05 +29ms service=permission sessionID=ses_4d84b8842ffedJ5Fi5cf25T3wS messageID=msg_b2a120e73002idlMUkP93KoBoH toolCallID=call_d4906847513741d9b6c3011e pattern=["git status *"] asking INFO 2025-12-17T02:10:05 +1ms service=bus type=permission.updated publishing ERROR 2025-12-17T02:10:05 +646ms service=acp-command promise={} reason=NotFoundError Unhandled rejection ERROR 2025-12-17T02:10:05 +1ms service=default e=NotFoundError rejection INFO 2025-12-17T02:10:05 +7ms service=bus type=message.part.updated publishing INFO 2025-12-17T02:10:05 +2ms service=bus type=message.part.updated publishing ERROR 2025-12-17T02:10:06 +1005ms service=acp-command promise={} reason=NotFoundError Unhandled rejection ERROR 2025-12-17T02:10:06 +1ms service=default e=NotFoundError rejection
Author
Owner

@rekram1-node commented on GitHub (Dec 16, 2025):

hm need to figure out that not found error looks like cause

@rekram1-node commented on GitHub (Dec 16, 2025): hm need to figure out that not found error looks like cause
Author
Owner

@wolfie82 commented on GitHub (Dec 23, 2025):

I took the desktop app for a spin and ran into this error as well. Agent runs shell command that presents undefined then just continues to spin indefinitely.

@wolfie82 commented on GitHub (Dec 23, 2025): I took the desktop app for a spin and ran into this error as well. Agent runs shell command that presents `undefined` then just continues to spin indefinitely.
Author
Owner

@rekram1-node commented on GitHub (Dec 23, 2025):

can u share a session w me?

@rekram1-node commented on GitHub (Dec 23, 2025): can u share a session w me?
Author
Owner

@wolfie82 commented on GitHub (Dec 23, 2025):

I'm trying to replicate it, but I think it could be from continuing a session that was first started via cli, then opening it in desktop. Off 1.0.193, running a session from start on desktop, I haven't been able to make it fail.

@wolfie82 commented on GitHub (Dec 23, 2025): I'm trying to replicate it, but I think it could be from continuing a session that was first started via cli, then opening it in desktop. Off 1.0.193, running a session from start on desktop, I haven't been able to make it fail.
Author
Owner

@wolfie82 commented on GitHub (Dec 23, 2025):

I'm trying to replicate it, but I think it could be from continuing a session that was first started via cli, then opening it in desktop. Off 1.0.193, running a session from start on desktop, I haven't been able to make it fail.

Spoke too soon. Unfortunately, I can't share this particular session.

@wolfie82 commented on GitHub (Dec 23, 2025): > I'm trying to replicate it, but I think it could be from continuing a session that was first started via cli, then opening it in desktop. Off 1.0.193, running a session from start on desktop, I haven't been able to make it fail. Spoke too soon. Unfortunately, I can't share this particular session.
Author
Owner

@aldaw commented on GitHub (Dec 24, 2025):

I have the same Problem, it was a newly fresh created session in open code.
The problem accrued after the first update today to V1.0.195 (MacOS).
Not my biggest want but it is no big deal for me to share the session with a developer.

@aldaw commented on GitHub (Dec 24, 2025): I have the same Problem, it was a newly fresh created session in open code. The problem accrued after the first update today to V1.0.195 (MacOS). Not my biggest want but it is no big deal for me to share the session with a developer.
Author
Owner

@aldaw commented on GitHub (Dec 25, 2025):

It is strange, even when I make a new session inside the project the error persists.
Only when I make a new project it behaves normal again.
@rekram1-node how can I send you the Session Link? The Discord Link in your bio is expired.
Or should I send to @adamdotdevin since he is assigned now?

@aldaw commented on GitHub (Dec 25, 2025): It is strange, even when I make a new session inside the project the error persists. Only when I make a new project it behaves normal again. @rekram1-node how can I send you the Session Link? The Discord Link in your bio is expired. Or should I send to @adamdotdevin since he is assigned now?
Author
Owner

@aldaw commented on GitHub (Dec 25, 2025):

Anyone encountered any kind of work around?

I am kinda stuck with my work, I already got used to OpenCode with in just a day, that I rather wait until it is fixed.
But I can't also wait weeks or indefinitely :P Thanks by the way for all contributors initiators, for every invested second!

@aldaw commented on GitHub (Dec 25, 2025): Anyone encountered any kind of work around? I am kinda stuck with my work, I already got used to OpenCode with in just a day, that I rather wait until it is fixed. But I can't also wait weeks or indefinitely :P Thanks by the way for all contributors initiators, for every invested second!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3605