GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — api: /api/command returns an empty list for a location the server has not seen · Issue #63145 · anomalyco/opencode

api: /api/command returns an empty list for a location the server has not seen #63145

New issue
Copy link
New issue
Copy link
Open
Open
api: /api/command returns an empty list for a location the server has not seen#63145
Copy link
Labels
reproduced

Description

@Halconmza
Halconmza
opened on Nov 10, 2026
Issue body actions

Description

GET /api/command returns an empty list the first time a location is queried, and only includes the commands from ~/.config/opencode/commands/ about three seconds later. A client that reads the catalog once when a session starts gets an empty slash-command menu and never refreshes it.

Plugins

Two local plugins in ~/.config/opencode/plugins/ (Orca status hooks). The behaviour reproduces with them disabled.

OpenCode version

2.2.5, latest channel, pnpm global install (Windows).

Steps to reproduce

  1. Put some commands in ~/.config/opencode/commands/ (16 Markdown files in my case).
  2. OPENCODE_PASSWORD=secret opencode serve --port 4015
  3. Create any directory the server has not opened yet, e.g. %TEMP%\fresh.
  4. Query it repeatedly, about one second apart:
opencode api get "/api/command?location[directory]=<that dir>" --server http://127.0.0.1:4015

Result:

t+0s:  0 ->
t+1s:  3 -> init,review,goal
t+3s: 19 -> init,review,goal,speckit.analyze,...,speckit.taskstoissues   (the 16 file commands appear)

Expected: the call waits for that location's catalog, or at least always returns the commands that do not depend on the location (built-ins and the global commands directory).

Actual: empty first, built-ins only on the next call, complete only after a few seconds.

Impact

Orca opens one chat per worktree and reads the catalog when the session starts. On a new worktree that read is [], so the / menu shows none of the generated /speckit.* commands for the rest of that chat. Sessions in an already-opened location are fine, which is why it only fails on new worktrees.

Additional context

On a long-running server I also saw deleting a file from ~/.config/opencode/commands/ drop all file-based commands from the catalog (back to just the 3 built-ins) for every location, until the next write in that directory restored all 16. Writing to that directory seems to be what triggers the catalog to be built.

Workaround: read /api/command for a location once or twice right after it is created, before any client reads it.

Operating System

Windows 11, 10.0.26300, x64.

Terminal

Orca-managed terminal, TERM=xterm-256color, commands issued from PowerShell 5.1 over cmd.exe.

Activity

  1. opencodejr commented on Nov 10, 2026

    @opencodejr
    opencodejrBot
    on Nov 10, 2026
    Contributor
    More actions

    Thanks for the detailed report. I was able to reproduce this.

    I put 16 command files in ~/.config/opencode/commands/, started opencode serve and queried /api/command for a newly created directory once a second:

    • 2.2.5: the first call returned only the 3 built-ins (init,review,goal). From the next call, about a second later, all 19 were there.
    • Latest dev (17c95db): the first call returned {"data":[]}, and the full list appeared a second later.

    It was a little faster here on Linux than the ~3s you saw, but the behaviour is the same: the first read for a new location comes back before that location's commands are loaded. The script below reproduces it.

    I did not test the second part (deleting a command file dropping all file commands). It looks closely related to #54545. Other related issues: #54192 (the same new-location race for MCP endpoints) and #49982.

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Reproduce #63145: GET /api/command on a never-seen location returns [] / built-ins only at first.
    # Usage: ./repro.sh            (uses `opencode` from PATH)
    #        OC="bun ... packages/cli/src/index.ts" ./repro.sh   (run from source)
    set -u
    OC=${OC:-opencode}
    PORT=${PORT:-4015}
    export HOME=$(mktemp -d /tmp/opencode/home.XXXX)
    export XDG_CONFIG_HOME=$HOME/.config XDG_DATA_HOME=$HOME/.local/share XDG_STATE_HOME=$HOME/.local/state XDG_CACHE_HOME=$HOME/.cache
    mkdir -p "$HOME/.config/opencode/commands"
    for i in $(seq 1 16); do
      printf -- '---\ndescription: test command %s\n---\nSay hello %s\n' "$i" "$i" > "$HOME/.config/opencode/commands/speckit.c$i.md"
    done
    export OPENCODE_PASSWORD=secret
    $OC serve --port "$PORT" > "$HOME/serve.log" 2>&1 &
    SERVER=$!
    trap 'kill $SERVER 2>/dev/null' EXIT
    for i in $(seq 1 60); do curl -s -o /dev/null "http://127.0.0.1:$PORT/" && break; sleep 0.5; done
    sleep 2
    
    FRESH=$(mktemp -d /tmp/opencode/fresh.XXXX)
    echo "fresh location: $FRESH"
    for t in 0 1 2 3 4 5; do
      OUT=$($OC api get "/api/command?location[directory]=$FRESH" --server "http://127.0.0.1:$PORT" 2>&1)
      NAMES=$(echo "$OUT" | grep -o '"name": *"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/' | paste -sd, -)
      COUNT=$(echo "$NAMES" | tr ',' '\n' | grep -c . )
      echo "t+${t}s: $COUNT -> $NAMES"
      [ -z "$NAMES" ] && echo "   raw: $(echo "$OUT" | head -c 300)"
      sleep 1
    done

    Run it: bash repro.sh

  2. opencodejr
    added
    reproduced
    on Nov 10, 2026
  3. Anthony14FR commented on Nov 11, 2026

    @Anthony14FR
    Anthony14FR
    on Nov 11, 2026
    More actions

    I'd like to work on this. Before writing code: would you prefer the endpoint to wait for the location's commands to finish loading before answering, or the client to refresh its command list once loading completes? #54192 looks like the same race for MCP, so I'd rather follow whatever approach you want there.

  4. Halconmza commented on Nov 12, 2026

    @Halconmza
    Halconmza
    on Nov 12, 2026
    Author
    More actions

    I'd like to work on this. Before writing code: would you prefer the endpoint to wait for the location's commands to finish loading before answering, or the client to refresh its command list once loading completes? #54192 looks like the same race for MCP, so I'd rather follow whatever approach you want there.

    I guess the best UX is option 1, so once you have the window ready, all commands are available. I prefer to wait 2/3 seconds.

  5. Anthony14FR commented on Nov 12, 2026

    @Anthony14FR
    Anthony14FR
    on Nov 12, 2026
    More actions

    @Halconmza Waiting would be nicer for a one-shot read, but the repo's AGENTS.md rules it out on purpose: server handlers never wait for plugin or catalog loading, and long-lived clients refresh on the matching *.updated event. The server already publishes command.updated once a location's commands load (packages/core/src/command.ts), and the app and ACP clients reload on it.

    So for Orca the fix is to subscribe to command.updated for that location and refetch /api/command. The other part of your report (deleting one command file dropping all file commands) does look like a server bug, likely the same as #54545.

    Maintainers, if you'd still rather have the endpoint wait here, tell me and I'll do that instead.

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

    reproduced

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.