Skip to content

feat(cli): add org support for /kiloclaw command#8218

Merged
catrielmuller merged 3 commits into
mainfrom
catrielmuller/kiloclaw-chat-orgs
Apr 2, 2026
Merged

feat(cli): add org support for /kiloclaw command#8218
catrielmuller merged 3 commits into
mainfrom
catrielmuller/kiloclaw-chat-orgs

Conversation

@catrielmuller

@catrielmuller catrielmuller commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Context

The /kiloclaw command always resolved the user's personal KiloClaw instance, even when the user had selected an organization via /teams. This PR adds organization support so the command resolves the correct org-scoped instance when a team is active.

Implementation

The org context flows through 3 layers, following the same pattern used by existing org-aware endpoints (/notifications, /fim, /modes):

  1. Gateway (packages/kilo-gateway/src/server/routes.ts): Both /claw/status and /claw/chat-credentials handlers now read auth.accountId (set by /teams) and forward it as the X-KiloCode-OrganizationId header when proxying to the cloud API.

  2. Command handler (packages/opencode/src/kilocode/kilo-commands.tsx): The /kiloclaw onSelect now fetches sdk.client.kilo.profile() in parallel with the status check to obtain currentOrgId, and passes it to the setup/upgrade dialogs.

  3. Dialogs (dialog-claw-setup.tsx, dialog-claw-upgrade.tsx): Both accept an orgId prop and construct the correct dashboard URL — https://app.kilo.ai/organizations/{orgId}/claw when in org context, falling back to https://app.kilo.ai/claw for personal.

Cloud changes (separate repo — cloud/): The REST API routes /api/kiloclaw/status and /api/kiloclaw/chat-credentials need a corresponding update to destructure organizationId from getUserFromAuth() and use getActiveOrgInstance() when present. The cloud already has org membership validation in getUserFromAuth() and the getActiveOrgInstance() function in the instance registry.

No SDK regeneration needed — the Hono route signatures are unchanged.

Screenshots

N/A — TUI changes, no visual diff.

How to Test

  1. Authenticate with Kilo Gateway (/login)
  2. Select an organization that has a KiloClaw instance via /teams
  3. Run /kiloclaw
    • If the org has no instance: the setup dialog should link to https://app.kilo.ai/organizations/{orgId}/claw
    • If the org has an instance with chat: the full-screen chat view should connect to the org instance
  4. Switch back to Personal Account via /teams
  5. Run /kiloclaw again — should resolve the personal instance and link to https://app.kilo.ai/claw

Pass the selected organization context through to KiloClaw API
endpoints so the /kiloclaw command resolves the correct org-scoped
instance when a team is selected via /teams.
@kilo-code-bot

kilo-code-bot Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • packages/kilo-gateway/src/server/routes.ts
  • packages/opencode/src/kilocode/components/dialog-claw-setup.tsx
  • packages/opencode/src/kilocode/components/dialog-claw-upgrade.tsx
  • packages/opencode/src/kilocode/kilo-commands.tsx

Reviewed by gpt-5.4-2026-03-05 · 166,635 tokens

Align variable naming with existing patterns in the same file
(lines 326, 396).
headers[HEADER_ORGANIZATIONID] = organizationId
}
// kilocode_change end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need kilocode_change here?

@catrielmuller catrielmuller merged commit 73c4efe into main Apr 2, 2026
13 checks passed
@catrielmuller catrielmuller deleted the catrielmuller/kiloclaw-chat-orgs branch April 2, 2026 18:48
jliounis pushed a commit to jliounis/kilocode that referenced this pull request May 18, 2026
…-chat-orgs

feat(cli): add org support for /kiloclaw command
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.

2 participants