Cloud Agent Next - Support All 5 CLI Agent Modes#366
Open
Conversation
Replace the old 2-mode system (build | plan) with the 5 CLI-aligned agent modes (code | plan | debug | orchestrator | ask) across the worker, Next.js API layer, and UI. - Update InternalAgentModes to pass modes 1:1 to the CLI instead of lossy normalization (debug/orchestrator/ask no longer collapse) - Keep 'build' and 'architect' as backward-compatible API aliases (build → code, architect → plan) for existing DO sessions - Replace all 'build' defaults with 'code' across worker, UI, and tests - Add normalizeMode() in CloudChatContainer to safely handle legacy mode strings from DB/DO without unsafe 'as' casts - Remove dead mode-conversion.ts (unused, stale logic) - Update ModeCombobox, ResumeConfigModal, and tRPC schemas to expose all 5 modes in the UI
| function normalizeMode(mode: string): AgentMode { | ||
| if (mode === 'build') return 'code'; | ||
| if (mode === 'architect') return 'plan'; | ||
| return mode as AgentMode; |
Contributor
There was a problem hiding this comment.
[SUGGESTION]: The as AgentMode cast silently passes through any unknown mode string from DB/DO (e.g. 'custom', 'foobar'). Consider validating against the known modes and falling back to a safe default:
Suggested change
| return mode as AgentMode; | |
| const validModes: AgentMode[] = ['code', 'plan', 'debug', 'orchestrator', 'ask']; | |
| return (validModes as string[]).includes(mode) ? (mode as AgentMode) : 'code'; |
This avoids silently propagating an invalid mode through the UI.
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Merge (minor suggestion only) Overview
Issue Details (click to expand)SUGGESTION
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (20 files)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the old 2-mode system (
build|plan) with the 5 CLI-aligned agent modes (code|plan|debug|orchestrator|ask) across the worker, Next.js API layer, and UI.Changes
cloud-agent-next/src/schema.ts):InternalAgentModesnow includes all 6 modes (5 + custom).normalizeAgentModepasses modes 1:1 to the CLI instead of collapsingdebug/orchestrator/ask.buildandarchitectremain as backward-compatible API aliases.'build'fallback defaults changed to'code'(CloudAgentSession.ts,auto-commit.ts,openrouter route).cloud-agent-next-schemas.ts,cloud-agent-client.ts):agentModeSendMessageSchemaupdated from['plan', 'build']to['code', 'plan', 'debug', 'orchestrator', 'ask'].AgentModetype,ModeCombobox,ResumeConfigModal,session-config.ts, anddb-session-atoms.tsall updated to the 5 new modes.normalizeMode()helper inCloudChatContainer.tsxto map legacy'build'/'architect'strings from DB/DO to their new equivalents, replacing unsafeascasts.mode-conversion.ts.'build'updated to'code'across 8 test files. All 627 cloud-agent-next tests and 16 frontend tests pass.Backward Compatibility
mode: 'build'are handled by keeping'build'as an accepted API alias that normalizes to'code'.cli_sessions.last_modeis free-text; existing'build'values are handled by worker normalization and the newnormalizeMode()in the UI.