Skip to content

feat(mobile): support remote CLI slash commands#4547

Open
iscekic wants to merge 19 commits into
mainfrom
feature/mobile-remote-cli-slash-commands
Open

feat(mobile): support remote CLI slash commands#4547
iscekic wants to merge 19 commits into
mainfrom
feature/mobile-remote-cli-slash-commands

Conversation

@iscekic

@iscekic iscekic commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • discover and display the connected CLI's bounded remote-safe slash command catalog
  • execute structured remote commands, including real /compact, without forwarding known commands as model text
  • reserve mobile /new for remote sessions, create a root session in the same CLI workspace, and replace the route with the returned session ID
  • preserve drafts on retryable failures and surface explicit upgrade guidance for incompatible CLIs
  • enforce relay command allowlisting, owner fencing, catalog limits, and exact old-CLI error mapping
  • keep web slash command defaults isolated by active session type

Coordinated change

Verification

  • Mobile: 105 test files / 600 tests, pnpm typecheck, pnpm lint, pnpm check:unused, pnpm format:check
  • Cloud Agent SDK: 24 suites / 892 tests, focused post-merge suite 151 tests, pnpm typecheck, pnpm lint
  • Session ingest: 106 focused tests, pnpm typecheck, pnpm lint
  • fresh full-diff reviews for both repositories: approved with no findings
  • iOS local E2E on isolated worktree stack and claimed simulator:
    • compatible CLI catalog showed /compact, /new, and registered commands
    • /compact triggered actual CLI compaction
    • /new created and opened a new session; Agents list showed both sessions
    • terminated CLI produced one connection error while preserving /compact draft
    • logs contained no tokens, credentials, or command payloads
  • old-CLI upgrade-required behavior is covered at relay, SDK, and mobile parser layers by automated tests

E2E environment

  • local stack used isolated port offset 1300
  • simulator and worktree services were released/stopped after verification

Comment thread apps/web/src/lib/cloud-agent-sdk/schemas.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of commits since the last pass (mobile chat-composer voice-input wiring, session context-usage header/sheet integration, and the UserConnectionDO.hasActiveCliSession helper) found no new correctness or security issues; the previously flagged hints schema WARNING is confirmed fixed.

Files Reviewed (10 files)
  • apps/mobile/src/components/agents/chat-composer.tsx
  • apps/mobile/src/components/agents/chat-composer-slash-commands.test.ts
  • apps/mobile/src/components/agents/session-detail-content.tsx
  • apps/mobile/src/lib/submit-lock.ts
  • apps/mobile/src/lib/voice-input/voice-input-submit.test.ts
  • apps/mobile/vitest.config.ts
  • apps/web/src/lib/cloud-agent-sdk/remote-command-catalog.test.ts
  • apps/web/src/lib/cloud-agent-sdk/schemas.ts - previously flagged issue fixed
  • services/session-ingest/src/dos/UserConnectionDO.ts
  • services/session-ingest/src/dos/UserConnectionDO.test.ts
Previous Review Summary (commit 4d916a8)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 4d916a8)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

A required-with-no-default hints field in the new remote command-catalog schema can fail-close the entire catalog parse if a CLI omits an empty hints array.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/cloud-agent-sdk/schemas.ts 354 hints on remoteSlashCommandInfoSchema is required with no .optional()/.default([]); a CLI omitting the key on a hint-less command fails the whole strict catalog parse
Files Reviewed (46 files)
  • services/session-ingest/src/dos/UserConnectionDO.ts / .test.ts
  • apps/web/src/lib/cloud-agent-sdk/cli-live-transport.ts / .test.ts
  • apps/web/src/lib/cloud-agent-sdk/transport.ts
  • apps/web/src/lib/cloud-agent-sdk/session.ts / .test.ts
  • apps/web/src/lib/cloud-agent-sdk/session-manager.ts / .test.ts
  • apps/web/src/lib/cloud-agent-sdk/session-routing.test.ts
  • apps/web/src/lib/cloud-agent-sdk/session-transport.test.ts
  • apps/web/src/lib/cloud-agent-sdk/create-session.ts / .test.ts
  • apps/web/src/lib/cloud-agent-sdk/remote-command-catalog.ts / .test.ts
  • apps/web/src/lib/cloud-agent-sdk/schemas.ts - 1 issue
  • apps/web/src/lib/cloud-agent-sdk/user-web-connection.ts / .test.ts
  • apps/web/src/components/cloud-agent-next/BrowseCommandsDialog.tsx
  • apps/web/src/components/cloud-agent-next/ChatInput.tsx
  • apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
  • apps/web/src/components/cloud-agent-next/browse-command-sets.ts / .test.ts
  • apps/web/src/hooks/slash-command-selection.ts
  • apps/web/src/hooks/useSlashCommandSets.ts / .test.ts
  • apps/mobile/src/components/agents/chat-composer-slash-commands.ts / .test.ts
  • apps/mobile/src/components/agents/chat-composer-slash-commands-new-reservation.test.ts
  • apps/mobile/src/components/agents/chat-composer-submission.ts / .test.ts
  • apps/mobile/src/components/agents/chat-composer.tsx
  • apps/mobile/src/components/agents/slash-command-suggestions.tsx
  • apps/mobile/src/lib/submit-lock.ts / .test.ts
  • apps/mobile/src/components/agents/create-and-navigate-agent-session.ts / .test.ts
  • apps/mobile/src/components/agents/create-remote-session-with-feedback.ts / .test.ts
  • apps/mobile/src/components/agents/mobile-session-manager.test.ts
  • apps/mobile/src/components/agents/session-detail-content.tsx
  • apps/mobile/src/components/agents/session-detail-routes.ts / .test.ts
  • apps/mobile/src/components/agents/session-router-like.ts
  • apps/mobile/vitest.config.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 48 · Output: 13.3K · Cached: 1.5M

Review guidance: REVIEW.md from base branch main

iscekic added 4 commits July 15, 2026 12:34
…-cli-slash-commands

# Conflicts:
#	apps/mobile/src/components/agents/chat-composer.tsx
#	apps/mobile/src/components/agents/session-detail-content.tsx
@iscekic

iscekic commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@kilocode-bot review the latest head

@kilo-code-bot

kilo-code-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

To use Kilo from GitHub you first need to link your GitHub account to Kilo. Link your Kilo account to continue. After linking, mention me again in this issue or pull request.

@iscekic

iscekic commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@kilocode-bot review the current latest head 49dc920

@kilo-code-bot

kilo-code-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

No new PR-authored code changes since the last review; the head advanced only via an empty chore: trigger latest-head review commit, with no file changes in the PR's own diff scope.

Files Reviewed (0 files)
  • No files changed in this range (8ec6d166a..ba335dba4 touches only services/session-ingest/wrangler.jsonc, which is not part of this PR's diff and originates from an unrelated main change)
Previous Review Summaries (2 snapshots, latest commit 8ec6d16)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 8ec6d16)

Status: No Issues Found | Recommendation: Merge

Executive Summary

No new PR-authored code changes since the last review; the head advanced only via an empty chore: trigger latest-head review commit and a merge of origin/main (bringing in an unrelated kilo-pass-router fix, out of scope for this PR).

Files Reviewed (0 files)
  • No files changed in this range (a5d97fdb..8ec6d166a contains only a main merge and an empty commit)

Previous review (commit a5d97fd)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of the diff since the last reviewed commit (4d916a8) up to the current head (49dc920). Excluding the origin/main merge commits and an empty chore: trigger latest-head review commit, the only PR-authored change in this range is commit e59e881fix(cloud-agent-sdk): accept omitted command hints.

This change directly resolves the single issue flagged in the previous review: hints on remoteSlashCommandInfoSchema was required, so an older CLI omitting the key on a hint-less command would fail-close the entire strict catalog parse. hints is now .optional().default([]), matching the pattern already used by the internal slashCommandInfoSchema. No new correctness or security issues were found.

Detailed Findings

Previously flagged issue — now resolved ✅

  • apps/web/src/lib/cloud-agent-sdk/schemas.ts:357hints: z.array(remoteCommandStringSchema).max(REMOTE_COMMAND_MAX_HINTS).optional().default([]). A missing hints key now normalizes to [] rather than rejecting the catalog. The z.output type keeps hints: string[], so SlashCommandInfo (which requires a non-nullable array) stays structurally satisfied.

Correctness

  • The relaxation is narrowly scoped. Existing guardrails are preserved: .strict() still rejects unknown keys, .max(REMOTE_COMMAND_MAX_HINTS) (32) and remoteCommandStringSchema (max 2000 chars) still reject malformed hints, and the 512 KB serialized-catalog cap and REMOTE_COMMAND_MAX_COMMANDS (256) limits are untouched.
  • Added tests cover the meaningful cases: omitted hints normalizes to [], explicit hints preserved, malformed hints rejected (non-string / over-length / over-cap), and unknown command keys still rejected under .strict().
  • The mobile test addition confirms createMobileSlashCommandList('remote', [], { commands: [], refresh: 'upgrade-required' }) returns only the reserved /new command and never surfaces compact, matching the fail-closed upgrade-handling contract.

Security

  • No regression. Making an optional array default to empty is not an injection or resource-exhaustion vector, and all size/length/strictness bounds remain enforced.

Quality (non-blocking nit)

  • In the remoteCommandCatalogV1Schema.transform, .map(command => ({ ...command, hints: command.hints })) is a redundant no-op spread now that the shape parse guarantees hints is present; it could be simplified to a plain .filter(...). Harmless as-is.
Files Reviewed (3 files)
  • apps/web/src/lib/cloud-agent-sdk/schemas.tshints relaxed to optional/default (fixes prior finding)
  • apps/web/src/lib/cloud-agent-sdk/remote-command-catalog.test.ts — new coverage for omitted/explicit/malformed hints and unknown keys
  • apps/mobile/src/components/agents/chat-composer-slash-commands.test.ts — new coverage for empty upgrade-required remote catalog

Note: the 4d916a8..49dc920 range also contains a large origin/main merge (kilo-pass, ai-gateway, code-reviews, session-ingest attention, voice input, etc.). Those changes land in their own merged PRs and are out of scope for this incremental review of the mobile remote-CLI-slash-commands PR.


Reviewed by claude-sonnet-5 · Input: 26 · Output: 3.2K · Cached: 450.1K

Review guidance: REVIEW.md from base branch main

@kilo-code-bot

kilo-code-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review already posted at head 49dc920: No Issues Found — Merge. #4547 (comment)

Only substantive change since last review was e59e881, which fixed the previously flagged hints schema issue by making it optional/defaulted. No further action needed.

…-cli-slash-commands

# Conflicts:
#	apps/mobile/src/components/agents/session-detail-content.tsx
#	apps/web/src/lib/cloud-agent-sdk/cli-live-transport.ts
@iscekic iscekic enabled auto-merge (squash) July 16, 2026 16:56
@iscekic iscekic disabled auto-merge July 16, 2026 16:57
@iscekic

iscekic commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

(bot) @kilocode-bot review the latest head

@kilo-code-bot

kilo-code-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Full-diff review of the current head (4f87a67) against main (merge-base 8322bf6). The only PR-authored change since the last review at 49dc920 is 04dbe5dafeat(mobile): support remote CLI exit; the remaining commits in the range are unrelated origin/main merges (mobile pagination, cost-insights, admin permissions, model enablement, etc.) that land in their own PRs and are out of scope here.

The exit feature is layered cleanly on the existing remote-slash-command design and stays fail-closed end to end:

  • Relay (UserConnectionDO) now enforces an explicit ALLOWED_VIEWER_COMMANDS allowlist before owner resolution, pending-slot allocation, or CLI forwarding, rejecting anything else with COMMAND_NOT_ALLOWED. exit_cli additionally requires a sessionId and an exact { protocolVersion: 1 } data shape (single-key check via Object.hasOwn + Reflect.get), rejecting drift with INVALID_COMMAND. The unknown command: <op>CLI_UPGRADE_REQUIRED mapping is scoped to a fixed command set and preserves any other CLI error verbatim; non-string CLI errors are sanitized to a generic CLI_COMMAND_ERROR. Catalog dedupe/size-cap logic was generalized from list_models to a CATALOG_DEDUPE_COMMANDS set without loosening bounds.
  • SDK (cli-live-transport, session, session-manager) add exitCli/createSession transport hooks. exitCli fences on canExitCli() (exact exit command shape) and short-circuits on upgrade-required, and both new operations reject hard on transport failure (no auto-retry) so the caller can preserve the draft. Owner-change/generation guards are consistent with existing model-catalog discovery, and create_session/exit_cli responses are validated by strict .strict() Zod schemas with a branded KiloSessionId.
  • Mobile routes /exit through a native destructive confirmation (showRemoteCliExitConfirmation) with idempotent settle, a single-authority SubmitLock shared with voice-settle to close the same-tick double-submit window, single-toast error feedback, and draft preservation on failure/cancel.

Security: No regressions. Command surface is allowlisted and owner-fenced at the relay; catalog size (512 KiB), per-string (2,000), hint (32), and command-count (256) caps are unchanged; parsers fail closed on unknown/extra keys. No tokens, credentials, or command payloads are logged; forwarded CLI error strings go only to the requesting owner.

Correctness: Generation/owner guards, in-flight dedupe, and deep-copy snapshotting of the command catalog are preserved across the new paths. Test coverage is strong (relay allowlist/validation, SDK exit/create parsing and fencing, mobile confirmation/submit-lock/routing).

Non-blocking nits

  • createMobileSlashCommandList gates /exit display on a name-only match, while canExitCli() requires the exact canonical exit shape; a CLI advertising a differently-shaped exit would surface /exit but fail execution with REMOTE_CLI_EXIT_UNAVAILABLE. Fail-closed and safe, just a minor display-vs-execution mismatch.
  • parseChatComposerSubmission treats /exit as exit-cli for every remote session regardless of catalog contents; when the CLI does not advertise exit, the attempt fails with a generic unavailable error rather than the more actionable upgrade copy. Acceptable, but slightly less guided than the upgrade-required path.
  • publishRemoteCommandState stores a deep-copied commands internally but forwards the caller-provided next to the callback. Since all call sites pass a fresh snapshotCommands()/[], the emitted and stored arrays are already independent, so there is no real aliasing risk — the comment just slightly overstates the guarantee for the emitted value.
Files Reviewed (core source, 12 files)
  • services/session-ingest/src/dos/UserConnectionDO.ts — viewer-command allowlist, exit_cli strict validation, generalized catalog dedupe/cap, upgrade-required/error mapping
  • apps/web/src/lib/cloud-agent-sdk/cli-live-transport.ts — command discovery, exitCli/createSession, send_command model mapping, deep-copy snapshotting
  • apps/web/src/lib/cloud-agent-sdk/schemas.ts — remote command catalog v1 schema, createSessionResponseV1, branded kiloSessionIdSchema
  • apps/web/src/lib/cloud-agent-sdk/remote-command-catalog.ts — strict bounded catalog parser + RemoteCommandState
  • apps/web/src/lib/cloud-agent-sdk/create-session.ts / exit-cli.ts — strict response parsers
  • apps/web/src/lib/cloud-agent-sdk/session.ts / session-manager.ts / transport.ts — exit/create wiring, generation guards, atoms
  • apps/web/src/lib/cloud-agent-sdk/user-web-connection.ts — shared sendRawCommand, sendCommandToConnection
  • apps/web/src/hooks/slash-command-selection.ts + components/cloud-agent-next/browse-command-sets.ts — web session-type command isolation
  • apps/mobile/src/components/agents/chat-composer.tsx + chat-composer-slash-commands.ts + chat-composer-submission.ts — parse/execute pipeline, submit lock
  • apps/mobile/src/components/agents/remote-cli-exit-alert.ts / remote-cli-exit-confirmation.ts / exit-remote-cli-with-feedback.ts — exit confirmation + feedback flow
  • apps/mobile/src/components/agents/create-and-navigate-agent-session.ts / create-remote-session-with-feedback.ts / session-detail-routes.ts/new create-and-navigate flow
  • apps/mobile/src/lib/submit-lock.ts — synchronous single-authority send lock

Accompanying test files were reviewed for coverage but omitted for brevity. The 49dc920..4f87a67 range also merges unrelated origin/main work (out of scope).

@kilo-code-bot

kilo-code-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review already posted: no issues found, recommendation is merge. #4547 (comment)

3 non-blocking nits noted (display-vs-execution mismatch on /exit gating, unconditional /exit parsing for remote sessions, slightly overstated deep-copy comment) — none blocking. No further action needed unless you want those nits addressed.

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