Skip to content

fix: validate serverUrl port before tmux pane spawn (fixes #2729)#2761

Merged
code-yeongyu merged 1 commit intodevfrom
fix/issue-2729
Mar 23, 2026
Merged

fix: validate serverUrl port before tmux pane spawn (fixes #2729)#2761
code-yeongyu merged 1 commit intodevfrom
fix/issue-2729

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Mar 23, 2026

Problem

When using serve+attach mode, ctx.serverUrl can contain http://127.0.0.1:0/ (port 0), causing tmux pane spawn to fail.

Fix

Add port validation in src/features/tmux-subagent/manager.ts — if port is 0 or invalid, fall back to default port lookup.

Fixes #2729

Automated fix by Sisyphus (oh-my-opencode)


Summary by cubic

Validate the server URL port before spawning the tmux pane to prevent failures when serve+attach sets port 0; if invalid, fall back to the default port from OPENCODE_PORT or 4096. Fixes #2729.

  • Bug Fixes
    • Parse ctx.serverUrl and treat port "0" as invalid; use a computed fallbackUrl.
    • Added a unit test to ensure the fallback is used when port 0 is provided.

Written for commit 0810e37. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Confidence score: 4/5

  • This PR is likely safe to merge, with minimal risk: the only flagged item is a low-to-moderate test fragility issue (4/10) rather than a production behavior bug.
  • In src/features/tmux-subagent/manager.test.ts, an assertion hard-codes fallback port 4096, so tests can fail when OPENCODE_PORT is set, creating avoidable CI instability.
  • Pay close attention to src/features/tmux-subagent/manager.test.ts - make the port assertion environment-aware to avoid brittle failures.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/features/tmux-subagent/manager.test.ts">

<violation number="1" location="src/features/tmux-subagent/manager.test.ts:250">
P2: The test assertion is brittle because it assumes the fallback port is always 4096. It will fail if `OPENCODE_PORT` is set in the environment.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

const manager = new TmuxSessionManager(ctx, config, mockTmuxDeps)

// then
expect((manager as any).serverUrl).toBe('http://localhost:4096')
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The test assertion is brittle because it assumes the fallback port is always 4096. It will fail if OPENCODE_PORT is set in the environment.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/features/tmux-subagent/manager.test.ts, line 250:

<comment>The test assertion is brittle because it assumes the fallback port is always 4096. It will fail if `OPENCODE_PORT` is set in the environment.</comment>

<file context>
@@ -226,6 +226,29 @@ describe('TmuxSessionManager', () => {
+      const manager = new TmuxSessionManager(ctx, config, mockTmuxDeps)
+
+      // then
+      expect((manager as any).serverUrl).toBe('http://localhost:4096')
+    })
   })
</file context>
Suggested change
expect((manager as any).serverUrl).toBe('http://localhost:4096')
const expectedPort = process.env.OPENCODE_PORT ?? '4096'
expect((manager as any).serverUrl).toBe(`http://localhost:${expectedPort}`)
Fix with Cubic

@code-yeongyu code-yeongyu merged commit 0e483d2 into dev Mar 23, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the fix/issue-2729 branch March 23, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant