Skip to content

fix(server): honor workspace header in routing#29481

Closed
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/web-custom-primary-agent
Closed

fix(server): honor workspace header in routing#29481
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/web-custom-primary-agent

Conversation

@YOMXXX
Copy link
Copy Markdown

@YOMXXX YOMXXX commented May 27, 2026

Issue for this PR

Closes #29468

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Workspace routing selected a workspace only from the workspace query parameter. The generated SDK keeps x-opencode-workspace as a header for non-GET requests such as POST /session/:id/prompt_async, so Web could load/list agents in the selected workspace on GET routes but submit prompts in a different instance context on POST routes.

This makes workspace routing also read x-opencode-workspace, matching the existing x-opencode-directory fallback. Local workspace POST requests now route to the selected workspace target instead of the fallback directory.

How did you verify your code works?

  • PATH="$HOME/.bun/bin:$PATH" bun test test/server/httpapi-workspace-routing.test.ts -t "routes local workspace requests from workspace header"
    • Red before the fix: response used the directory header and no workspace id instead of the selected workspace target.
    • Green after the fix: 1 pass, 0 fail.
  • PATH="$HOME/.bun/bin:$PATH" bun test test/server/httpapi-workspace-routing.test.ts
    • 10 pass, 0 fail.
  • PATH="$HOME/.bun/bin:$PATH" bun test test/server/httpapi-promptasync-context.test.ts
    • 2 pass, 0 fail.
  • PATH="$HOME/.bun/bin:$PATH" bun test test/server/httpapi-query-schema-drift.test.ts
    • 12 pass, 0 fail.
  • PATH="$HOME/.bun/bin:$PATH" bun typecheck from packages/opencode.
  • PATH="$HOME/.bun/bin:$PATH" bun x prettier --check src/server/routes/instance/httpapi/middleware/workspace-routing.ts test/server/httpapi-workspace-routing.test.ts.
  • git diff --check.
  • PATH="$HOME/.bun/bin:$PATH" .husky/pre-push currently fails in unrelated @opencode-ai/console-support typecheck because local dependencies/generated console-core modules are missing (@solidjs/*, solid-js/jsx-runtime, vite, @opencode-ai/console-core/*). The touched opencode package typecheck completed separately and passed.

Screenshots / recordings

N/A - server routing fix.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

Related PR:

However, this is not a duplicate — it's addressing a separate but related routing concern. The current PR (#29481) focuses on honoring the x-opencode-workspace header for workspace routing, while #29472 focuses on routing agent lists by directory.

@thdxr thdxr closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom primary agents fail silently in web UI

2 participants