anomalyco / anomalyco/opencode

tui: "Invalid storage segment" crash when branch/channel name contains "/"

Open
#45,493 0 comments 0 reactions 1 assignee View on GitHub

@simonklee is already working on this.

Since Aug 27, 2026.

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

Description

Description

The TUI crashes immediately on startup with TypeError: Invalid storage segment: <channel> whenever the build's channel (the git branch name) contains a /. Common branch conventions like fix/..., feature/..., bugfix/... all trigger it.

Root cause is in packages/tui/src/context/storage.tsx. createStorage(root, channel) runs the channel through segment():

function segment(value: string) {
  if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(value) || value === "." || value === "..")
    throw new TypeError(`Invalid storage segment: ${value}`)
  return value
}

The regex rejects /, so a channel derived from a slash-containing branch name throws during StorageProvider initialization, before the TUI renders anything.

Suggested fix: sanitize the channel before segment() (e.g. replace / with -), or allow / in the segment regex. Branch names with slashes are ubiquitous, so the channel-as-segment path needs to tolerate them.

Plugins

@mohak34/opencode-notifier, @nick-vi/opencode-type-inject, oh-my-openagent, opencode-gemini-auth, opencode-openai-codex-auth, opencode-wakatime

OpenCode version

0.0.0-fix/v2-titlebarright-provider-202608261819 (channel: fix/v2-titlebarright-provider)

Steps to reproduce
  1. Build opencode from a branch whose name contains / (e.g. fix/v2-titlebarright-provider), so the channel becomes the branch name.
  2. Launch the TUI (opencode).
  3. It crashes at startup before rendering.

Minimal repro: git checkout -b x/y → build & run opencode.

Expected behavior

The TUI starts normally regardless of branch name.

Actual behavior
TypeError: Invalid storage segment: fix/v2-titlebarright-provider
    at PA (/usr/lib/root/chunk-0k3rjw2z.js:2692:2514)
    at YFt (/usr/lib/root/chunk-0k3rjw2z.js:2692:2623)
    at oQ (/usr/lib/root/chunk-0k3rjw2z.js:2692:3622)
    at Z (/usr/lib/root/chunk-kxae28wy.js:2:7204)
    at <anonymous> (/usr/lib/root/chunk-0k3rjw2z.js:2590:3395)
    at <anonymous> (/usr/lib/root/chunk-kxae28wy.js:2:14690)
    at pA (/usr/lib/root/chunk-kxae28wy.js:2:10199)
    at fe (/usr/lib/root/chunk-kxae28wy.js:2:9980)
    at E (/usr/lib/root/chunk-kxae28wy.js:2:4528)
    at xe (/usr/lib/root/chunk-kxae28wy.js:2:8496)
Operating System

macOS 25.6.0 (arm64)

Terminal

xterm-256color

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.