Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/config/schema/tmux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ export const TmuxConfigSchema = z.object({
main_pane_min_width: z.number().min(40).default(120),
agent_pane_min_width: z.number().min(20).default(40),
isolation: TmuxIsolationSchema.default("session"),
/**
* Override the server URL used for health checks and pane spawning.
* Use this when opencode auto-detects the wrong IP (e.g., Tailscale).
* Example: "http://localhost:4096"
*/
server_url_override: z
.preprocess(
(val) => (val === "" || val === null ? undefined : val),
z.string().url().optional()
)
.optional(),
})

export type TmuxConfig = z.infer<typeof TmuxConfigSchema>
Expand Down
26 changes: 18 additions & 8 deletions src/features/tmux-subagent/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,27 @@ export class TmuxSessionManager {
this.deps = deps
const defaultPort = process.env.OPENCODE_PORT ?? "4096"
const fallbackUrl = `http://localhost:${defaultPort}`
try {
const raw = ctx.serverUrl?.toString()
if (raw) {
const parsed = new URL(raw)
if (tmuxConfig.server_url_override) {
try {
const parsed = new URL(tmuxConfig.server_url_override)
const port = parsed.port || (parsed.protocol === 'https:' ? '443' : '80')
this.serverUrl = port === '0' ? fallbackUrl : raw
} else {
this.serverUrl = port === '0' ? fallbackUrl : tmuxConfig.server_url_override
} catch {
this.serverUrl = fallbackUrl
}
} else {
try {
const raw = ctx.serverUrl?.toString()
if (raw) {
const parsed = new URL(raw)
const port = parsed.port || (parsed.protocol === 'https:' ? '443' : '80')
this.serverUrl = port === '0' ? fallbackUrl : raw
} else {
this.serverUrl = fallbackUrl
}
} catch {
this.serverUrl = fallbackUrl
}
} catch {
this.serverUrl = fallbackUrl
}
this.sourcePaneId = deps.getCurrentPaneId()
this.pollingManager = new TmuxPollingManager(
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
main_pane_min_width: pluginConfig.tmux?.main_pane_min_width ?? 120,
agent_pane_min_width: pluginConfig.tmux?.agent_pane_min_width ?? 40,
isolation: pluginConfig.tmux?.isolation ?? "session",
server_url_override: pluginConfig.tmux?.server_url_override,
}

const modelCacheState = createModelCacheState()
Expand Down
1 change: 1 addition & 0 deletions src/plugin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export type TmuxConfig = {
main_pane_min_width: number
agent_pane_min_width: number
isolation: "inline" | "window" | "session"
server_url_override?: string
}
Loading