anomalyco / anomalyco/opencode

[macOS] attach takes seconds to connect and render first TUI frame after serve is ready

Open
#48,051 3 comments 0 reactions 1 assignee View on GitHub

@kommander is already working on this.

Since Sep 9, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

On macOS, opencode attach has a repeatable multi-second gap after the server is already healthy and a session has already been created. The gap is visible before the first usable TUI frame, independent of the model's first reply.

Environment

  • OpenCode 1.18.25 (/opt/homebrew/bin/opencode)
  • macOS 26.5.1, Apple Silicon Mac Studio
  • opencode serve bound to loopback, then a separate pty running opencode attach <url> --session <id>
  • The host used an isolated OpenCode XDG home and set OPENCODE_DISABLE_PROJECT_CONFIG=true for its task-home; no owner process or profile was used.

Measurement

The host clicked New task, submitted a prompt, waited for GET /global/health = 200, observed the task-home session from GET /session, then spawned the exact attach command. attach connected is the attach PID's loopback TCP connection to the serve port. TUI first frame is the first visible xterm instance after the attach instance changed and the OpenCode status bar was rendered. Times below are cumulative from the New task click; t7 is reported separately from the OpenCode message ledger.

Profile attach spawn attach TCP connected TUI first frame spawn→connected connected→first frame t0→t5
Cold: fresh host profile + fresh OpenCode XDG home 2.448s 5.598s 9.880s 3.150s 4.282s 9.880s
Warm: same profile after app restart, OpenCode cache present 2.336s 5.573s 9.257s 3.237s 3.684s 9.257s
Hot: same app process, second new task 2.191s 6.435s 10.271s 4.244s 3.836s 10.271s

The host-side preceding milestones were similarly stable: HTTP ready at 1.871–2.025s, session observed at 2.180–2.432s, and attach spawn at 2.191–2.448s. The first prompt reached the OpenCode session at 2.396–2.672s. First replies completed at 11.379–17.801s and are intentionally not included in the TUI startup claim.

Questions

Please profile the two attach-side intervals:

  1. attach process spawn → first TCP connection to the healthy serve;
  2. TCP connection → first rendered/interactive TUI frame.

In particular, can startup work such as external plugin loading, provider/model discovery, models.dev fetch, update checks, terminal capability queries, or replay be identified and deferred?

Flag probe

OpenCode 1.18.25 exposes attach --pure (run without external plugins), but no attach-specific provider/update skip flag. In an isolated serve --pure + attach --pure pty with OPENCODE_DISABLE_AUTOUPDATE=true and OPENCODE_DISABLE_MODELS_FETCH=true, the first pty output arrived 5.232s after attach spawn. This is a first-output probe, not a substitute for the full TUI table above; it shows the pure path still has a multi-second attach startup.

Related: #14965 (slow startup), #31463 (cold npm plugin resolution), #31006 (--pure plugin startup workaround), #37060 (attach TUI init hang on Windows).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.