Skip to content

refactor: route-scoped registry and live custom mode - #5472

Merged
iscekic merged 5 commits into
mainfrom
audit-w7b-data-contracts-dffd-s4
Aug 26, 2026
Merged

refactor: route-scoped registry and live custom mode#5472
iscekic merged 5 commits into
mainfrom
audit-w7b-data-contracts-dffd-s4

Conversation

@iscekic

@iscekic iscekic commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

The live cloud chat mode picker lists only the custom agents the session can run. An agent added to the profile after the session was created is not offered in that session.

The mode control shows Select mode when no mode is stored, instead of defaulting to Code. A session stored with a custom agent mode keeps that mode on live resume.

Legacy Build and Architect modes show as Code and Plan.


The live chat page composes the mode picker's custom options from the session's frozen runtime agents plus the current default profile's agents, filtered to the slugs the session can still run. The profile list enriches those runtime agents with current descriptions, but a profile agent whose slug is not in the frozen runtimeAgents list is excluded because the worker's validateModeAgainstRuntimeAgents rejects it on send. The send path normalizes the mode, and the provider normalizes the fetched session mode so an absent mode resolves to an empty string instead of null.

Files
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx — builds custom mode options from runtime agents plus profile agents filtered to runtimeAgentSlugs; uses modeControlValue for the control and normalizeAlias(mode) || 'code' on send.
  • apps/web/src/components/cloud-agent-next/CloudAgentProvider.tsx — normalizes the fetched session's mode with normalizeAlias, so an absent mode is now '' instead of null.

Session mode validation now accepts any non-empty slug after alias normalization, matching the already-widened AgentMode type. New pure helpers normalize legacy aliases (buildcode, architectplan), resolve an empty value to the picker's Select mode placeholder, identify built-in slugs, and dedupe custom options. The runtime validity gate no longer rejects unknown slugs, so a custom SessionConfig.mode outside the five built-ins is now valid.

Files
  • apps/web/src/components/cloud-agent-next/session-config.ts — adds normalizeAlias, modeControlValue, isBuiltinAgentMode, dedupeCustomModeOptions, ensureSelectedCustomOption, and CustomModeOption; rewrites isValidSessionConfig to accept any non-empty normalized slug with a model.

The mobile picker bridges move into a route-scoped registry keyed by a route key. A route key is the session id for the agent-chat pickers, the lowercased owner/repo/#number triple for pull-request flows, or the fixed keys unscoped and security-filter. The useRouteRegistry hook clears every slot under a key when the owning route unmounts, so a stale value can no longer leak between flows, at the cost that every consumer must name its route key.

Files
  • apps/mobile/src/lib/route-registry.ts — adds the typed seven-slot registry, UNFENCED_ROUTE_KEY, SECURITY_FILTER_ROUTE_KEY, prRouteKey, and the useRouteRegistry cleanup hook.

The process-global model, mode, repo, and instance bridges are removed, and each selector now writes its value into a registry slot before navigating. Each picker route reads its slot once on focus and clears it on blur, selection, or unmount. The four bridge types are exported, RepoOption now requires a platform, and the old set/get/clear exports are gone, so a repo list built directly must supply a platform or default it to GitHub.

Files
  • apps/mobile/src/lib/picker-bridge.ts — exports the four bridge types; removes the module-level storage and its set/get/clear functions; adds required platform and optional workspaceUuid/repositoryUuid to RepoOption.
  • apps/mobile/src/components/agents/model-selector.tsx — writes modelPickerSlot under the selection scope's session id and pushes the route with that route key.
  • apps/mobile/src/components/agents/mode-selector.tsx — writes modePickerSlot under the session-id param or unscoped, and pushes the route key.
  • apps/mobile/src/components/agents/repo-selector.tsx — maps local repo rows to bridge RepoOptions (defaulting platform to github) and writes repoPickerSlot under unscoped.
  • apps/mobile/src/components/agents/instance-selector.tsx — writes instancePickerSlot under unscoped.
  • apps/mobile/src/components/agents/model-picker-content.tsx — reads and clears modelPickerSlot by route key; commits the selection on blur.
  • apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx — reads modePickerSlot by route key and clears it on select.
  • apps/mobile/src/app/(app)/agent-chat/repo-picker.tsx — reads and clears repoPickerSlot under unscoped, and keys rows by platform:fullName.
  • apps/mobile/src/app/(app)/agent-chat/instance-picker.tsx — reads and clears instancePickerSlot under unscoped.

The pull-request review bridges keep their public signatures but store state in the registry under each PR's route key. setDiffSelection, getDiffSelection, and subscribeFileNavigatorRequest/requestScrollToFile now resolve per PR via the lowercased prRouteKey, and clearDiffSelection clears the whole diff-selection slot. Existing callers compile unchanged, and a request for one PR can no longer reach another PR's mounted listener.

Files
  • apps/mobile/src/lib/pr-review/diff-selection-bridge.ts — delegates to prDiffSelectionSlot keyed by prRouteKey; clearDiffSelection clears the entire slot.
  • apps/mobile/src/lib/pr-review/file-navigator-bridge.ts — keeps listener sets per route key; the unsubscribe cleans the key once its set is empty.

The security finding filter bridge stores its draft in the registry under the fixed security-filter key. setSecurityFindingFilterBridge keeps its signature so the producer screen compiles unchanged, while the filter route reads securityFilterSlot and clears it on blur and unmount.

Files
  • apps/mobile/src/lib/security-finding-filter-bridge.ts — replaces the module-level variable with securityFilterSlot.set under SECURITY_FILTER_ROUTE_KEY; removes the get/clear exports.
  • apps/mobile/src/app/(app)/(tabs)/(3_profile)/security-agent/[scope]/filter.tsx — reads the slot by the fixed key, registers useRouteRegistry, and clears the slot on blur.

Tests: 4 test files changed (route-registry.test.ts added; session-config.test.ts grown; picker-bridge.test.ts and repo-picker-filter.test.ts updated).
Generated: none.


Verification

No E2E report is attached for this level. Full E2E verification runs on the tip PR #5479.

Visual Changes

Visual Changes: N/A

Reviewer Notes

Human steps: none known.

Notes: none.

Stacked PRs — merge bottom to top. Each level shows only its own diff.

Full verification (E2E, user advocacy, simplify, bot review) runs on the tip PR over every level.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.

  1. audit-w7b-data-contracts-dffdrefactor(mobile): parse raw HTTP and infer review contracts #5460
  2. audit-w7b-data-contracts-dffd-s2feat(web): add org credit and invoice page procedures #5462
  3. audit-w7b-data-contracts-dffd-s3feat(mobile): owner-keyed credits, ledger paging, list freshness #5468
  4. audit-w7b-data-contracts-dffd-s4refactor: route-scoped registry and live custom mode #5472 ← this PR
  5. audit-w7b-data-contracts-dffd-s5feat(mobile): provider-aware new-session and layout extract #5479 (tip)

@iscekic iscekic self-assigned this Aug 25, 2026
Comment thread apps/mobile/src/lib/route-registry.ts
Comment thread apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx
Comment thread apps/mobile/src/lib/pr-review/diff-selection-bridge.ts Outdated
Comment thread apps/web/src/components/cloud-agent-next/CloudChatPage.tsx
@kilo-code-bot

kilo-code-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (25 files)
  • apps/mobile/src/app/(app)/(tabs)/(3_profile)/security-agent/[scope]/filter.tsx
  • apps/mobile/src/app/(app)/agent-chat/instance-picker.tsx
  • apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx
  • apps/mobile/src/app/(app)/agent-chat/repo-picker.tsx
  • apps/mobile/src/components/agents/instance-selector.tsx
  • apps/mobile/src/components/agents/mode-selector.tsx
  • apps/mobile/src/components/agents/model-picker-content.tsx
  • apps/mobile/src/components/agents/model-selector.tsx
  • apps/mobile/src/components/agents/repo-selector.tsx
  • apps/mobile/src/components/pr-review/diff/pr-diff-file-list.tsx
  • apps/mobile/src/components/pr-review/diff/pr-diff-floating-actions.tsx
  • apps/mobile/src/components/pr-review/diff/use-diff-selection.ts
  • apps/mobile/src/lib/picker-bridge.test.ts
  • apps/mobile/src/lib/picker-bridge.ts
  • apps/mobile/src/lib/pr-review/diff-selection-bridge.ts
  • apps/mobile/src/lib/pr-review/file-navigator-bridge.ts
  • apps/mobile/src/lib/pr-review/pr-bridges.test.ts
  • apps/mobile/src/lib/repo-picker-filter.test.ts
  • apps/mobile/src/lib/route-registry.test.ts
  • apps/mobile/src/lib/route-registry.ts
  • apps/mobile/src/lib/security-finding-filter-bridge.ts
  • apps/web/src/components/cloud-agent-next/CloudAgentProvider.tsx
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx
  • apps/web/src/components/cloud-agent-next/session-config.test.ts
  • apps/web/src/components/cloud-agent-next/session-config.ts
Previous Review Summaries (5 snapshots, latest commit 634d4ca)

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

Previous review (commit 634d4ca)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • apps/mobile/src/components/pr-review/diff/pr-diff-file-list.tsx
  • apps/mobile/src/components/pr-review/diff/pr-diff-floating-actions.tsx
  • apps/mobile/src/components/pr-review/diff/use-diff-selection.ts
  • apps/mobile/src/lib/pr-review/diff-selection-bridge.ts
  • apps/mobile/src/lib/pr-review/pr-bridges.test.ts

Previous review (commit 02a5d4f)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx

Previous review (commit 54d7050)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
apps/mobile/src/lib/route-registry.ts 126 Unmount cleanup wipes every slot kind for a shared key
apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx 36 Mode picker never re-reads the slot on focus
apps/mobile/src/lib/pr-review/diff-selection-bridge.ts 39 clearDiffSelection wipes every PR’s selection
Files Reviewed (21 files)
  • apps/mobile/src/app/(app)/(tabs)/(3_profile)/security-agent/[scope]/filter.tsx
  • apps/mobile/src/app/(app)/agent-chat/instance-picker.tsx
  • apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx - 1 issue
  • apps/mobile/src/app/(app)/agent-chat/repo-picker.tsx
  • apps/mobile/src/components/agents/instance-selector.tsx
  • apps/mobile/src/components/agents/mode-selector.tsx
  • apps/mobile/src/components/agents/model-picker-content.tsx
  • apps/mobile/src/components/agents/model-selector.tsx
  • apps/mobile/src/components/agents/repo-selector.tsx
  • apps/mobile/src/lib/picker-bridge.test.ts
  • apps/mobile/src/lib/picker-bridge.ts
  • apps/mobile/src/lib/pr-review/diff-selection-bridge.ts - 1 issue
  • apps/mobile/src/lib/pr-review/file-navigator-bridge.ts
  • apps/mobile/src/lib/repo-picker-filter.test.ts
  • apps/mobile/src/lib/route-registry.test.ts
  • apps/mobile/src/lib/route-registry.ts - 1 issue
  • apps/mobile/src/lib/security-finding-filter-bridge.ts
  • apps/web/src/components/cloud-agent-next/CloudAgentProvider.tsx
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx
  • apps/web/src/components/cloud-agent-next/session-config.test.ts
  • apps/web/src/components/cloud-agent-next/session-config.ts

Fix these issues in Kilo Cloud

Previous review (commit a9b4003)

Status: 4 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
apps/mobile/src/lib/route-registry.ts 126 Unmount cleanup wipes every slot kind for a shared key
apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx 36 Mode picker never re-reads the slot on focus
apps/mobile/src/lib/pr-review/diff-selection-bridge.ts 39 clearDiffSelection wipes every PR’s selection
apps/web/src/components/cloud-agent-next/CloudChatPage.tsx 772 Profile-only custom agents are selectable but rejected on send
Files Reviewed (21 files)
  • apps/mobile/src/app/(app)/(tabs)/(3_profile)/security-agent/[scope]/filter.tsx
  • apps/mobile/src/app/(app)/agent-chat/instance-picker.tsx
  • apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx - 1 issue
  • apps/mobile/src/app/(app)/agent-chat/repo-picker.tsx
  • apps/mobile/src/components/agents/instance-selector.tsx
  • apps/mobile/src/components/agents/mode-selector.tsx
  • apps/mobile/src/components/agents/model-picker-content.tsx
  • apps/mobile/src/components/agents/model-selector.tsx
  • apps/mobile/src/components/agents/repo-selector.tsx
  • apps/mobile/src/lib/picker-bridge.test.ts
  • apps/mobile/src/lib/picker-bridge.ts
  • apps/mobile/src/lib/pr-review/diff-selection-bridge.ts - 1 issue
  • apps/mobile/src/lib/pr-review/file-navigator-bridge.ts
  • apps/mobile/src/lib/repo-picker-filter.test.ts
  • apps/mobile/src/lib/route-registry.test.ts
  • apps/mobile/src/lib/route-registry.ts - 1 issue
  • apps/mobile/src/lib/security-finding-filter-bridge.ts
  • apps/web/src/components/cloud-agent-next/CloudAgentProvider.tsx
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx - 1 issue
  • apps/web/src/components/cloud-agent-next/session-config.test.ts
  • apps/web/src/components/cloud-agent-next/session-config.ts

Fix these issues in Kilo Cloud

Previous review (commit 361350e)

Status: 4 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
apps/mobile/src/lib/route-registry.ts 126 Unmount cleanup wipes every slot kind for a shared key
apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx 36 Mode picker never re-reads the slot on focus
apps/mobile/src/lib/pr-review/diff-selection-bridge.ts 39 clearDiffSelection wipes every PR’s selection
apps/web/src/components/cloud-agent-next/CloudChatPage.tsx 712 Profile-only custom agents are selectable but rejected on send
Files Reviewed (21 files)
  • apps/mobile/src/app/(app)/(tabs)/(3_profile)/security-agent/[scope]/filter.tsx
  • apps/mobile/src/app/(app)/agent-chat/instance-picker.tsx
  • apps/mobile/src/app/(app)/agent-chat/mode-picker.tsx - 1 issue
  • apps/mobile/src/app/(app)/agent-chat/repo-picker.tsx
  • apps/mobile/src/components/agents/instance-selector.tsx
  • apps/mobile/src/components/agents/mode-selector.tsx
  • apps/mobile/src/components/agents/model-picker-content.tsx
  • apps/mobile/src/components/agents/model-selector.tsx
  • apps/mobile/src/components/agents/repo-selector.tsx
  • apps/mobile/src/lib/picker-bridge.test.ts
  • apps/mobile/src/lib/picker-bridge.ts
  • apps/mobile/src/lib/pr-review/diff-selection-bridge.ts - 1 issue
  • apps/mobile/src/lib/pr-review/file-navigator-bridge.ts
  • apps/mobile/src/lib/repo-picker-filter.test.ts
  • apps/mobile/src/lib/route-registry.test.ts
  • apps/mobile/src/lib/route-registry.ts - 1 issue
  • apps/mobile/src/lib/security-finding-filter-bridge.ts
  • apps/web/src/components/cloud-agent-next/CloudAgentProvider.tsx
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx - 1 issue
  • apps/web/src/components/cloud-agent-next/session-config.test.ts
  • apps/web/src/components/cloud-agent-next/session-config.ts

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 60.5K · Output: 11.9K · Cached: 565.9K

Review guidance: REVIEW.md from base branch main


export function clearDiffSelection() {
selection = null;
prDiffSelectionSlot.clearAll();

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.

bot: Clearing a selection for one PR deletes selections for every PR.

Suggested fix: Make the clear operation PR-scoped: change clearDiffSelection to accept PrIdentity (or a route key) and call prDiffSelectionSlot.clear(prRouteKey(pr)). Pass the current { owner, repo, number } from PrDiffFileList, useDiffSelection, and PrDiffFloatingActions. Add a regression test that creates selections for two PRs, clears one, and asserts the other remains available.

@iscekic iscekic closed this Aug 26, 2026
@iscekic iscekic reopened this Aug 26, 2026
@iscekic iscekic closed this Aug 26, 2026
@iscekic iscekic reopened this Aug 26, 2026
Base automatically changed from audit-w7b-data-contracts-dffd-s3 to main August 26, 2026 17:16
Map build/architect aliases to code/plan, widen isValidSessionConfig to accept any non-empty slug after normalization, and derive the mode picker from runtime and profile agents. The empty control shows Select mode instead of Code. The web Jest test runs in CI (workerSetup provisions Postgres).
The live picker surfaced current-profile agents even when they were not in the session's frozen runtimeAgents; the worker rejects such a slug on send. Filter the profile list to runtimeAgents slugs so the picker never offers an agent the session cannot run.
clearDiffSelection wiped every stored selection, so leaving one PR
discarded the selection a second PR entry on the stack was still holding.
Take the PR identity and clear that route key.
@iscekic
iscekic force-pushed the audit-w7b-data-contracts-dffd-s4 branch from 0b0b6d9 to 8c10932 Compare August 26, 2026 17:16
@iscekic
iscekic merged commit 32a8d13 into main Aug 26, 2026
19 checks passed
@iscekic
iscekic deleted the audit-w7b-data-contracts-dffd-s4 branch August 26, 2026 17:36
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