Skip to content

[Fix] oclite TUI hangs - SDK needs in-process server connection #134

Description

@randomm

Problem

oclite TUI hangs after bootstrap - no prompt appears.

Symptom: Process hangs after snapshot cleanup log, TUI never renders.

Root Cause: useSDKEvents.ts creates SDK client connecting to http://localhost:4096, but no server is started in entry.ts.

Blocking code: useSDKEvents.ts:23

const events = await sdk.event.subscribe() // Hangs forever - no server

Solution

Use in-process SDK connection (like worker.ts does) instead of HTTP.

Modify useSDKEvents.ts:

import { Server } from "@/server/server"

// In-process fetch function
const fetchFn = async (input: RequestInfo | URL, init?: RequestInit) => {
  const request = new Request(input, init)
  return Server.App().fetch(request)
}

const sdk = createOpencodeClient({
  baseUrl: "http://opencode.internal",
  fetch: fetchFn,
  signal: abortController.signal,
})

Files

  • packages/opencode/src/cli/ink/hooks/useSDKEvents.ts (lines 14-16, 23)

Reference

  • packages/opencode/src/cli/cmd/tui/worker.ts - shows correct in-process pattern

Acceptance Criteria

  • TUI renders immediately after bootstrap
  • Input prompt appears
  • Event subscription works
  • No HTTP server needed for standalone binary

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions