Skip to content

refactor(mcp): rename start_claude_session to start_agent_session#1683

Merged
Kitenite merged 14 commits into
mainfrom
kitenite/open-codex-mcp
Feb 22, 2026
Merged

refactor(mcp): rename start_claude_session to start_agent_session#1683
Kitenite merged 14 commits into
mainfrom
kitenite/open-codex-mcp

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 22, 2026

Summary

  • Generalize the start_claude_session MCP tool into start_agent_session with support for multiple AI agents: Claude, Codex, Gemini, OpenCode, Copilot, and Cursor Agent
  • Add an optional agent parameter (defaults to "claude") so existing callers are unaffected
  • Extract agent command-building logic into packages/shared/src/agent-command.ts with per-agent CLI builders
  • Preserve backward compatibility via deprecated re-exports in claude-command.ts

Changes

packages/shared

  • New agent-command.tsAGENT_TYPES, AgentType, TaskInput, buildAgentCommand(), deprecated buildClaudeCommand() wrapper
  • claude-command.ts — replaced with re-exports from agent-command.ts
  • package.json — added "./agent-command" export

packages/mcp

  • New start-agent-session/ tool — renamed from start-claude-session, added agent param validated against AGENT_TYPES
  • Deleted start-claude-session/ directory
  • Updated index.ts import and get-workspace-details description reference

apps/desktop

  • Renamed start-claude-session.tsstart-agent-session.ts (tool + export)
  • Renamed buildClaudeCommand.tsbuildAgentCommand.ts (re-exports from shared)
  • Updated OpenInWorkspace.tsx to use buildAgentCommand
  • Updated tools index.ts imports

Docs & commands

  • .claude/commands/task-run.md — references start_agent_session
  • apps/docs/content/docs/mcp.mdx — updated tool table, descriptions, and examples for multi-agent support

Test Plan

  • bun run typecheck — all 18 packages pass
  • bun run lint:fix — no lint errors
  • Grep for stale references: start_claude_session, startClaudeSession, buildClaudeCommand only appear in deprecated re-export paths

Summary by CodeRabbit

  • New Features

    • Multi-agent sessions: start autonomous sessions with multiple AI agents (Claude, Codex, Gemini, OpenCode, Copilot, Cursor Agent) and choose a default agent (defaults to Claude).
    • Option to add a local MCP entry during setup (-m / --mcp).
  • User Interface

    • Agent selection added to workspace/launch flows and session labels; "Claude Code" terminology renamed to "Agent".
    • Terminal presets now reflect available agents dynamically.
  • Documentation

    • Docs and examples updated for multi-agent usage and renamed commands.

…h multi-agent support

Generalize the MCP tool to support multiple AI agents (claude, codex, gemini, opencode, copilot, cursor-agent) instead of being hardcoded to Claude Code.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 22, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Renames Claude-specific tooling to generic "agent" terminology, adds multi-agent support and presets, centralizes command generation in a new shared agent-command module, updates MCP start-session tooling and desktop UI to support selectable agents, and adds an opt-in local MCP setup step and docs updates.

Changes

Cohort / File(s) Summary
Docs & CLI help
/.claude/commands/task-run.md, apps/docs/content/docs/mcp.mdx, .superset/lib/setup/args.sh
Reword Claude-specific docs and CLI help to use "agent"; add -m/--mcp setup option and help text.
Desktop UI: command builder & agent selection
apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/$taskId/components/PropertiesSidebar/components/OpenInWorkspace/OpenInWorkspace.tsx, apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/$taskId/utils/buildAgentCommand.ts, apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/$taskId/utils/buildClaudeCommand.ts, apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetsSection.tsx
Switch UI/logic to use buildAgentCommand, add agent selection UI/state (persisted in localStorage), adapt workspace/terminal init to carry agentCommand, remove local buildClaudeCommand re-export, and generate presets from shared AGENT_* constants.
AgentHooks tools (desktop)
apps/desktop/src/renderer/routes/_authenticated/components/AgentHooks/hooks/useCommandWatcher/tools/index.ts, .../start-agent-session.ts
Replace start_claude_session references with start_agent_session, rename exported tool identifier and update tool metadata and error messages.
MCP tools: start session migration
packages/mcp/src/tools/devices/start-agent-session/start-agent-session.ts, packages/mcp/src/tools/devices/start-agent-session/index.ts, packages/mcp/src/tools/devices/start-claude-session/index.ts, packages/mcp/src/tools/index.ts, packages/mcp/src/tools/devices/get-workspace-details/get-workspace-details.ts
Introduce start_agent_session tool (replacing start_claude_session): add optional agent arg (enum AGENT_TYPES) defaulting to "claude", validate/forward agent, use buildAgentCommand, update descriptions, add new re-export and remove old re-export.
Shared command module
packages/shared/src/agent-command.ts, packages/shared/src/claude-command.ts, packages/shared/package.json
Add new agent-command module exposing AGENT_TYPES, labels, preset commands/descriptions, prompt/heredoc builders, AGENT_COMMANDS, and buildAgentCommand (with deprecated buildClaudeCommand wrapper); refactor claude-command.ts to re-export from it and add package export.
Setup flow: local MCP step
.superset/lib/setup/args.sh, .superset/lib/setup/main.sh, .superset/lib/setup/steps.sh
Add SETUP_LOCAL_MCP flag parsing, new step_setup_local_mcp() to add/update superset-local entry in .mcp.json (requires jq, uses API_PORT), and conditionally run it in setup_main when flag set.
Minor housekeeping & tests
apps/desktop/src/renderer/stores/tabs/utils.test.ts, apps/desktop/src/renderer/stores/tabs/utils.ts
Remove unused import in test and reformat named imports in utils.ts; no behavior changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DesktopApp
    participant SharedModule
    participant MCP_Tool
    participant Device

    User->>DesktopApp: Click "Open in workspace" / start session
    DesktopApp->>SharedModule: buildAgentCommand(task, randomId, agent)
    SharedModule-->>DesktopApp: return agent command string
    DesktopApp->>MCP_Tool: invoke start_agent_session with command payload
    MCP_Tool->>Device: launch agent session with provided command
    Device-->>MCP_Tool: session started / status
    MCP_Tool-->>DesktopApp: tool execution result (session running)
    DesktopApp-->>User: show "Agent session: running" status
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
I nudge the burrow, now many a voice,
Claude and Codex and friends rejoice.
One prompt to govern, one shared command,
Hopping through tools with tidy hand.
Agents assemble — hop, hop, hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main refactoring work: renaming start_claude_session to start_agent_session with multi-agent support.
Description check ✅ Passed The description provides comprehensive context including summary, affected files, changes, and test plan. It covers all critical information needed to understand the refactor's scope and impact.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kitenite/open-codex-mcp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 22, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Fly.io Electric (Fly.io) View App
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/mcp/src/tools/devices/start-agent-session/start-agent-session.ts (2)

99-104: Hardcoded agent list in the description string will drift if AGENT_TYPES is updated.

Line 103 enumerates agents as a literal string ("claude", "codex", "gemini", ...). If a new agent is added to AGENT_TYPES, this description won't automatically reflect it. Consider generating the description from the constant, or leave a comment linking the two.

♻️ Dynamic description
 			agent: z
 				.enum(AGENT_TYPES)
 				.optional()
 				.describe(
-					'AI agent to use: "claude", "codex", "gemini", "opencode", "copilot", or "cursor-agent". Defaults to "claude".',
+					`AI agent to use: ${AGENT_TYPES.map((t) => `"${t}"`).join(", ")}. Defaults to "claude".`,
 				),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/mcp/src/tools/devices/start-agent-session/start-agent-session.ts`
around lines 99 - 104, The description for the z.enum field `agent` is hardcoded
and will drift from the `AGENT_TYPES` constant; change the `describe` call on
the `agent: z.enum(AGENT_TYPES).optional()` schema to build its text from
`AGENT_TYPES` (e.g., join the array into a string) or replace the literal list
with a short reference comment linking to `AGENT_TYPES`, so the schema
description always reflects the actual entries in `AGENT_TYPES`.

42-62: Narrow the return type of validateArgs from agent?: string to agent?: AgentType.

AgentType is properly exported from @superset/shared/agent-command and the Zod schema already validates agent as an enum member. Using the narrower type in validateArgs eliminates the need for the cast on line 112.

Update the return type and the type assertion on line 53 to use AgentType | undefined, then simplify line 112 from (validated.agent as (typeof AGENT_TYPES)[number]) ?? "claude" to just validated.agent ?? "claude".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/mcp/src/tools/devices/start-agent-session/start-agent-session.ts`
around lines 42 - 62, The validateArgs function currently types agent as string
which forces a cast later; change its return type so agent is typed as AgentType
| undefined (import AgentType from `@superset/shared/agent-command`), update the
agent local extraction inside validateArgs to const agent = args.agent as
AgentType | undefined, and return agent as AgentType when present; then remove
the cast where AGENT_TYPES is used (replace `(validated.agent as (typeof
AGENT_TYPES)[number]) ?? "claude"` with `validated.agent ?? "claude"`), keeping
references to validateArgs, AgentType, and AGENT_TYPES.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/shared/src/agent-command.ts`:
- Around line 54-64: The heredoc in buildHeredoc can be prematurely terminated
if the generated delimiter appears inside the prompt; update buildAgentCommand
(or the caller that generates the delimiter) to validate that the chosen
delimiter (e.g., SUPERSET_PROMPT_<id>) does not occur in the prompt/combined
task fields and, if it does, derive a new delimiter (for example by appending a
random suffix or regenerating the id) until it's unique, then pass that safe
delimiter into buildHeredoc so the heredoc body cannot be truncated; ensure the
check happens before calling buildHeredoc and use the same delimiter value for
both the opening and closing markers.
- Around line 78-82: The mapping for "cursor-agent" in the agent registry uses
an unsupported CLI flag (--yolo) which may produce an invalid runtime command;
check whether cursor-agent supports that flag by running cursor-agent --help and
then either remove the "--yolo" token from the buildHeredoc call in the
"cursor-agent" entry, replace it with a supported flag, or gate its inclusion
behind a feature flag/config so buildHeredoc(prompt, delimiter, "cursor-agent
-p", ...) only receives valid args; update any tests or documentation that
assume "--yolo" is present.

---

Nitpick comments:
In `@packages/mcp/src/tools/devices/start-agent-session/start-agent-session.ts`:
- Around line 99-104: The description for the z.enum field `agent` is hardcoded
and will drift from the `AGENT_TYPES` constant; change the `describe` call on
the `agent: z.enum(AGENT_TYPES).optional()` schema to build its text from
`AGENT_TYPES` (e.g., join the array into a string) or replace the literal list
with a short reference comment linking to `AGENT_TYPES`, so the schema
description always reflects the actual entries in `AGENT_TYPES`.
- Around line 42-62: The validateArgs function currently types agent as string
which forces a cast later; change its return type so agent is typed as AgentType
| undefined (import AgentType from `@superset/shared/agent-command`), update the
agent local extraction inside validateArgs to const agent = args.agent as
AgentType | undefined, and return agent as AgentType when present; then remove
the cast where AGENT_TYPES is used (replace `(validated.agent as (typeof
AGENT_TYPES)[number]) ?? "claude"` with `validated.agent ?? "claude"`), keeping
references to validateArgs, AgentType, and AGENT_TYPES.

Comment on lines +54 to +64
function buildHeredoc(
prompt: string,
delimiter: string,
command: string,
suffix?: string,
): string {
const closing = suffix ? `)" ${suffix}` : ')"';
return [`${command} "$(cat <<'${delimiter}'`, prompt, delimiter, closing].join(
"\n",
);
}
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.

⚠️ Potential issue | 🟡 Minor

Heredoc body containing the delimiter would truncate the prompt.

If any task field (title, description, etc.) happens to contain the exact string SUPERSET_PROMPT_<randomId_without_hyphens>, the heredoc terminates early. The UUID-derived delimiter makes accidental collision astronomically unlikely, but it's not impossible with adversarial or machine-generated task content. Consider validating that the delimiter doesn't appear in the prompt, or adjusting the delimiter if it does.

🛡️ Suggested guard in buildAgentCommand
 export function buildAgentCommand({
 	task,
 	randomId,
 	agent = "claude",
 }: {
 	task: TaskInput;
 	randomId: string;
 	agent?: AgentType;
 }): string {
 	const prompt = buildPrompt(task);
-	const delimiter = `SUPERSET_PROMPT_${randomId.replaceAll("-", "")}`;
+	let delimiter = `SUPERSET_PROMPT_${randomId.replaceAll("-", "")}`;
+	// Ensure the delimiter doesn't appear in the prompt body
+	while (prompt.includes(delimiter)) {
+		delimiter += "_";
+	}
 	const builder = AGENT_COMMANDS[agent];
 	return builder(prompt, delimiter);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/shared/src/agent-command.ts` around lines 54 - 64, The heredoc in
buildHeredoc can be prematurely terminated if the generated delimiter appears
inside the prompt; update buildAgentCommand (or the caller that generates the
delimiter) to validate that the chosen delimiter (e.g., SUPERSET_PROMPT_<id>)
does not occur in the prompt/combined task fields and, if it does, derive a new
delimiter (for example by appending a random suffix or regenerating the id)
until it's unique, then pass that safe delimiter into buildHeredoc so the
heredoc body cannot be truncated; ensure the check happens before calling
buildHeredoc and use the same delimiter value for both the opening and closing
markers.

Comment thread packages/shared/src/agent-command.ts
Adds -m/--mcp flag to .superset/setup.sh that adds or updates a
superset-local entry in .mcp.json pointing to the local API port.
…mplates

- Add agent dropdown to OpenInWorkspace with icons and localStorage persistence
- Extract AGENT_LABELS, AGENT_PRESET_COMMANDS, AGENT_PRESET_DESCRIPTIONS
  into packages/shared for reuse
- Refactor PresetsSection to derive PRESET_TEMPLATES from shared agent metadata
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
.superset/lib/setup/args.sh (1)

12-12: Align the description column with the other options.

--mcp is two characters shorter than --force, so the description starts two columns earlier, breaking the table layout.

🎨 Alignment fix
-  -m, --mcp              Add superset-local MCP entry to .mcp.json
+  -m, --mcp                Add superset-local MCP entry to .mcp.json
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.superset/lib/setup/args.sh at line 12, The "-m, --mcp" option line in
args.sh is misaligned because the option text is shorter than others; update the
"-m, --mcp              Add superset-local MCP entry to .mcp.json" entry so its
description column lines up with the other options (e.g., add the necessary
spaces after "--mcp" to match the spacing used by "--force" and other entries),
keeping the option flags and description text unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.superset/lib/setup/steps.sh:
- Around line 466-467: The code uses API_PORT with a default of 3001 which hides
the dynamically allocated workspace port because step_write_env sets API_PORT as
a local variable and it isn't exported; instead derive API_PORT from the
exported SUPERSET_PORT_BASE so non-first workspaces use the right port. Update
the logic in .superset/lib/setup/steps.sh (near step_load_env / step_write_env
usage) to compute API_PORT as $((SUPERSET_PORT_BASE + 1)) when
SUPERSET_PORT_BASE is set (fall back to existing API_PORT default only if
SUPERSET_PORT_BASE is unset), ensuring the MCP URL built from
local_url="http://localhost:${api_port}/api/agent/mcp" uses the correct
per-workspace port; reference functions/vars: allocate_port_base,
step_write_env, step_load_env, SUPERSET_PORT_BASE, and API_PORT.
- Around line 476-477: The mv of "$tmp_file" to "$mcp_file" is not checked so
success "Local MCP set to $local_url" can print even if mv failed; update the
block around the mv (the tmp_file -> mcp_file rename) to test mv's exit status
like allocate_port_base does: run mv "$tmp_file" "$mcp_file" and if it fails,
log an error (or call error) including the filenames, remove or preserve
"$tmp_file" as appropriate, and return a non-zero status instead of printing
success; ensure you reference the same variables tmp_file and mcp_file and
reproduce the error-handling pattern used in allocate_port_base.

---

Nitpick comments:
In @.superset/lib/setup/args.sh:
- Line 12: The "-m, --mcp" option line in args.sh is misaligned because the
option text is shorter than others; update the "-m, --mcp              Add
superset-local MCP entry to .mcp.json" entry so its description column lines up
with the other options (e.g., add the necessary spaces after "--mcp" to match
the spacing used by "--force" and other entries), keeping the option flags and
description text unchanged.

Comment thread .superset/lib/setup/steps.sh Outdated
Comment on lines +466 to +467
local api_port="${API_PORT:-3001}"
local local_url="http://localhost:${api_port}/api/agent/mcp"
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.

⚠️ Potential issue | 🟠 Major

API_PORT fallback of 3001 is incorrect for any non-first workspace.

step_write_env computes API_PORT as $((SUPERSET_PORT_BASE + 1)) but declares it local, so it is never exported to the calling shell. step_load_env sources the root .env, which either has a static default or no API_PORT at all. The result: this step always resolves to 3001 regardless of the dynamically allocated port base.

For workspace 1 (BASE=3000) this is coincidentally correct. For workspace 2 (BASE=3020, API=3021) the MCP URL will point to http://localhost:3001/api/agent/mcp — the wrong workspace's API — defeating the purpose of per-workspace port allocation.

SUPERSET_PORT_BASE is exported by allocate_port_base, so the fix is straightforward:

🐛 Proposed fix
-  local api_port="${API_PORT:-3001}"
+  local api_port="${API_PORT:-$((${SUPERSET_PORT_BASE:-3000} + 1))}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
local api_port="${API_PORT:-3001}"
local local_url="http://localhost:${api_port}/api/agent/mcp"
local api_port="${API_PORT:-$((${SUPERSET_PORT_BASE:-3000} + 1))}"
local local_url="http://localhost:${api_port}/api/agent/mcp"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.superset/lib/setup/steps.sh around lines 466 - 467, The code uses API_PORT
with a default of 3001 which hides the dynamically allocated workspace port
because step_write_env sets API_PORT as a local variable and it isn't exported;
instead derive API_PORT from the exported SUPERSET_PORT_BASE so non-first
workspaces use the right port. Update the logic in .superset/lib/setup/steps.sh
(near step_load_env / step_write_env usage) to compute API_PORT as
$((SUPERSET_PORT_BASE + 1)) when SUPERSET_PORT_BASE is set (fall back to
existing API_PORT default only if SUPERSET_PORT_BASE is unset), ensuring the MCP
URL built from local_url="http://localhost:${api_port}/api/agent/mcp" uses the
correct per-workspace port; reference functions/vars: allocate_port_base,
step_write_env, step_load_env, SUPERSET_PORT_BASE, and API_PORT.

Comment thread .superset/lib/setup/steps.sh Outdated
Comment on lines +476 to +477
mv "$tmp_file" "$mcp_file"
success "Local MCP set to $local_url"
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.

⚠️ Potential issue | 🟠 Major

mv result is unchecked — success is reported even if the file was never updated.

If mv fails (permission error, cross-device rename, etc.), the original .mcp.json is unchanged, $tmp_file is left on disk, and the function still returns 0. Compare with the identical pattern in allocate_port_base (lines 290–295) which guards mv correctly.

🐛 Proposed fix
-  mv "$tmp_file" "$mcp_file"
-  success "Local MCP set to $local_url"
-
-  return 0
+  if ! mv "$tmp_file" "$mcp_file"; then
+    error "Failed to update .mcp.json"
+    rm -f "$tmp_file"
+    return 1
+  fi
+  success "Local MCP set to $local_url"
+
+  return 0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.superset/lib/setup/steps.sh around lines 476 - 477, The mv of "$tmp_file"
to "$mcp_file" is not checked so success "Local MCP set to $local_url" can print
even if mv failed; update the block around the mv (the tmp_file -> mcp_file
rename) to test mv's exit status like allocate_port_base does: run mv
"$tmp_file" "$mcp_file" and if it fails, log an error (or call error) including
the filenames, remove or preserve "$tmp_file" as appropriate, and return a
non-zero status instead of printing success; ensure you reference the same
variables tmp_file and mcp_file and reproduce the error-handling pattern used in
allocate_port_base.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/shared/src/agent-command.ts (1)

21-30: Clarify the distinction between AGENT_PRESET_COMMANDS and AGENT_COMMANDS.

These two maps serve different purposes but their naming is very similar, which could confuse future contributors:

  • AGENT_PRESET_COMMANDS — interactive/preset commands shown in the UI (e.g., codex with detailed -c flags).
  • AGENT_COMMANDS — autonomous task-execution builders using heredoc prompts (e.g., codex with --full-auto).

For instance, codex maps to a long detailed invocation in AGENT_PRESET_COMMANDS but to codex --full-auto in AGENT_COMMANDS. Consider adding a brief doc comment above each to clarify their intent, or renaming one (e.g., AGENT_INTERACTIVE_COMMANDS vs AGENT_TASK_COMMANDS).

Also applies to: 98-114

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/shared/src/agent-command.ts` around lines 21 - 30, Add clear
comments or rename the two maps to remove ambiguity: update
AGENT_PRESET_COMMANDS and AGENT_COMMANDS (and the equivalent map around the
other block at the 98-114 region) to either include brief doc comments above
each describing their purpose ("interactive/preset UI commands" vs
"autonomous/task-execution commands") or rename them to explicit identifiers
like AGENT_INTERACTIVE_COMMANDS and AGENT_TASK_COMMANDS; ensure all
references/usages in the module are updated to match any renamed symbol so
callers still compile.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/$taskId/components/PropertiesSidebar/components/OpenInWorkspace/OpenInWorkspace.tsx (1)

100-114: addTab correctly accepts initialCommands — optional refactor recommended for better UX.

The existing code properly passes initialCommands: [command] to addTab, which is fully supported by the AddTabOptions interface. For improved clarity, use AGENT_LABELS[selectedAgent] instead of the generic "Agent" string for the tab title:

♻️ Use agent-specific tab title
-			setTabAutoTitle(tabId, "Agent");
+			setTabAutoTitle(tabId, AGENT_LABELS[selectedAgent]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/`$taskId/components/PropertiesSidebar/components/OpenInWorkspace/OpenInWorkspace.tsx
around lines 100 - 114, Replace the hardcoded tab title "Agent" in both branches
with the agent-specific label: call setTabAutoTitle(tabId,
AGENT_LABELS[selectedAgent]) after addTab(result.workspace.id, {
initialCommands: [command] }) and when creating a pending setup via
useWorkspaceInitStore.addPendingTerminalSetup ensure you set the tab title
similarly; if selectedAgent might be undefined, fallback to
AGENT_LABELS[selectedAgent] ?? "Agent" to preserve behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/`$taskId/components/PropertiesSidebar/components/OpenInWorkspace/OpenInWorkspace.tsx:
- Around line 50-52: The initialization of selectedAgent in the OpenInWorkspace
component unsafely casts localStorage.getItem("lastSelectedAgent") to AgentType
causing AGENT_COMMANDS[selectedAgent] to possibly be undefined; change the
initializer to read the stored string, validate it against the known agent
enum/keys (e.g., keys of AGENT_COMMANDS or a canonical AGENT_TYPES array) and
only use it if it matches a valid AgentType, otherwise default to "claude";
apply the same validation whenever you read/update lastSelectedAgent (e.g., in
setSelectedAgent or any effect that syncs with localStorage) so you never store
or use an invalid AgentType.
- Line 33: The import in the OpenInWorkspace component uses a fragile relative
path for buildAgentCommand; change the import to use the renderer/ alias (e.g.,
import { buildAgentCommand } from "renderer/utils/buildAgentCommand") so it
follows the project's tsconfig alias convention and matches the other imports in
this file.

In `@packages/shared/src/agent-command.ts`:
- Around line 50-51: The code currently does an unsafe cast of
localStorage.getItem("lastSelectedAgent") to AgentType and accesses
AGENT_COMMANDS[selectedAgent], which can be undefined for stale/invalid values;
update the logic that initializes selectedAgent (and anything using it inside
buildPrompt) to first read the raw value from localStorage, check that it exists
in AGENT_TYPES (or Object.keys(AGENT_COMMANDS)), and only then cast to
AgentType; if the check fails, fall back to the default "claude" so
AGENT_COMMANDS[selectedAgent] is always defined and you avoid runtime TypeError.
- Around line 83-96: The heredoc in buildHeredoc can collide if prompt contains
the chosen delimiter; modify buildHeredoc to ensure the delimiter does not
appear inside prompt by testing prompt.includes(delimiter) and, if it does,
generate a new delimiter (e.g., append or re-roll a UUID fragment or suffix) in
a loop until unique before constructing the heredoc; keep the function signature
and the closing logic (closing variable and returned array) but replace the
single fixed delimiter selection with the uniqueness-check loop so the produced
heredoc delimiter is guaranteed not to occur in prompt.

---

Nitpick comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/`$taskId/components/PropertiesSidebar/components/OpenInWorkspace/OpenInWorkspace.tsx:
- Around line 100-114: Replace the hardcoded tab title "Agent" in both branches
with the agent-specific label: call setTabAutoTitle(tabId,
AGENT_LABELS[selectedAgent]) after addTab(result.workspace.id, {
initialCommands: [command] }) and when creating a pending setup via
useWorkspaceInitStore.addPendingTerminalSetup ensure you set the tab title
similarly; if selectedAgent might be undefined, fallback to
AGENT_LABELS[selectedAgent] ?? "Agent" to preserve behavior.

In `@packages/shared/src/agent-command.ts`:
- Around line 21-30: Add clear comments or rename the two maps to remove
ambiguity: update AGENT_PRESET_COMMANDS and AGENT_COMMANDS (and the equivalent
map around the other block at the 98-114 region) to either include brief doc
comments above each describing their purpose ("interactive/preset UI commands"
vs "autonomous/task-execution commands") or rename them to explicit identifiers
like AGENT_INTERACTIVE_COMMANDS and AGENT_TASK_COMMANDS; ensure all
references/usages in the module are updated to match any renamed symbol so
callers still compile.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/shared/src/agent-command.ts`:
- Around line 21-30: AGENT_PRESET_COMMANDS entries diverge from the actual
runtime commands produced by buildAgentCommand (via AGENT_COMMANDS) for codex,
opencode, copilot, and cursor-agent; either update AGENT_PRESET_COMMANDS to
match the exact flags used by AGENT_COMMANDS/buildAgentCommand for those agents
or add a clear inline comment and UI-facing note that presets are templates and
additional flags (e.g., --full-auto, --prompt, -i --yolo, --yolo) are appended
at runtime by buildAgentCommand; locate AGENT_PRESET_COMMANDS and compare with
AGENT_COMMANDS and buildAgentCommand, then either synchronize the strings or add
the clarifying comment and ensure any UI text uses the clarified preset
description.
- Around line 108-109: The CLI invocation string passed to buildHeredoc is
incorrect: change the third argument in the opencode mapping from "opencode
--prompt" to the correct non-interactive command "opencode run" so that
opencode: (prompt, delimiter) => buildHeredoc(prompt, delimiter, "opencode run")
uses the documented CLI; locate the opencode property in
packages/shared/src/agent-command.ts and update the literal accordingly.

---

Duplicate comments:
In `@packages/shared/src/agent-command.ts`:
- Around line 83-96: The heredoc can break if the chosen delimiter appears
inside the prompt; update buildHeredoc to verify that the supplied delimiter
(and the generator used elsewhere, e.g.,
SUPERSET_PROMPT_${randomId.replaceAll("-", "")}) does not occur in prompt and,
if it does, generate a new unique delimiter (for example by appending a counter
or random suffix) until it is absent; then use that safe delimiter in the
returned heredoc string so prompt content cannot prematurely close the heredoc.

Comment on lines +21 to +30
export const AGENT_PRESET_COMMANDS: Record<AgentType, string[]> = {
claude: ["claude --dangerously-skip-permissions"],
codex: [
'codex -c model_reasoning_effort="high" --ask-for-approval never --sandbox danger-full-access -c model_reasoning_summary="detailed" -c model_supports_reasoning_summaries=true',
],
gemini: ["gemini --yolo"],
opencode: ["opencode"],
copilot: ["copilot"],
"cursor-agent": ["cursor-agent"],
};
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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, locate and view the full agent-command.ts file to verify the divergence
fd -e ts -p "agent-command.ts" 2>/dev/null | head -5

Repository: superset-sh/superset

Length of output: 100


🏁 Script executed:

# Search for AGENT_PRESET_COMMANDS usage across the codebase
rg "AGENT_PRESET_COMMANDS" --type ts -B 2 -A 3

Repository: superset-sh/superset

Length of output: 2731


🏁 Script executed:

# Search for AGENT_COMMANDS and buildAgentCommand to understand the implementation
rg "AGENT_COMMANDS|buildAgentCommand" --type ts -B 2 -A 5 packages/shared/src/agent-command.ts

Repository: superset-sh/superset

Length of output: 786


🏁 Script executed:

cat packages/shared/src/agent-command.ts

Repository: superset-sh/superset

Length of output: 4043


AGENT_PRESET_COMMANDS and AGENT_COMMANDS diverge for codex, opencode, copilot, and cursor-agent.

AGENT_PRESET_COMMANDS is displayed as example commands in the Terminal Settings presets UI, but does not match what buildAgentCommand actually executes via AGENT_COMMANDS:

Agent AGENT_PRESET_COMMANDS AGENT_COMMANDS (actual runtime)
codex codex -c model_reasoning_effort="high" --ask-for-approval never --sandbox danger-full-access … codex --full-auto
opencode opencode opencode --prompt
copilot copilot copilot -i --yolo
cursor-agent cursor-agent cursor-agent --yolo

The codex divergence is the most severe — these are fundamentally different invocation styles. Users copying the example from settings will not execute the same command that the system runs. Either align these constants, or add a clarifying comment explaining that presets are templates and the actual execution adds required flags.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/shared/src/agent-command.ts` around lines 21 - 30,
AGENT_PRESET_COMMANDS entries diverge from the actual runtime commands produced
by buildAgentCommand (via AGENT_COMMANDS) for codex, opencode, copilot, and
cursor-agent; either update AGENT_PRESET_COMMANDS to match the exact flags used
by AGENT_COMMANDS/buildAgentCommand for those agents or add a clear inline
comment and UI-facing note that presets are templates and additional flags
(e.g., --full-auto, --prompt, -i --yolo, --yolo) are appended at runtime by
buildAgentCommand; locate AGENT_PRESET_COMMANDS and compare with AGENT_COMMANDS
and buildAgentCommand, then either synchronize the strings or add the clarifying
comment and ensure any UI text uses the clarified preset description.

Comment on lines +108 to +109
opencode: (prompt, delimiter) =>
buildHeredoc(prompt, delimiter, "opencode --prompt"),
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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

OpenCode CLI documentation "opencode run" non-interactive mode

💡 Result:

opencode run is the OpenCode CLI’s non-interactive mode: it runs a prompt directly (no TUI), which is intended for scripting/automation. (opencode.ai)

Basic usage

  • opencode run [message..]
    Example: opencode run "Explain the use of context in Go" (opencode.ai)

Useful flags for non-interactive automation

  • --format json to output raw JSON events (machine-friendly). (opencode.ai)
  • --file, -f attach file(s) to the message. (opencode.ai)
  • --model, -m select a model (provider/model). (opencode.ai)
  • Session controls: --continue/-c, --session/-s, --fork, --title, --share. (opencode.ai)

Avoid cold starts (attach to a running server)

  1. Start a headless server: opencode serve (opencode.ai)
  2. Run with: opencode run --attach http://localhost:4096 "Your prompt" (opencode.ai)

Citations:


opencode --prompt is not a valid CLI invocation — change to opencode run.

OpenCode's official CLI documentation specifies non-interactive mode as opencode run [message..], intended for scripting and automation. There is no --prompt top-level flag; the current invocation will fail with an unknown flag error at runtime.

Proposed fix
-	opencode: (prompt, delimiter) =>
-		buildHeredoc(prompt, delimiter, "opencode --prompt"),
+	opencode: (prompt, delimiter) =>
+		buildHeredoc(prompt, delimiter, "opencode run"),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
opencode: (prompt, delimiter) =>
buildHeredoc(prompt, delimiter, "opencode --prompt"),
opencode: (prompt, delimiter) =>
buildHeredoc(prompt, delimiter, "opencode run"),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/shared/src/agent-command.ts` around lines 108 - 109, The CLI
invocation string passed to buildHeredoc is incorrect: change the third argument
in the opencode mapping from "opencode --prompt" to the correct non-interactive
command "opencode run" so that opencode: (prompt, delimiter) =>
buildHeredoc(prompt, delimiter, "opencode run") uses the documented CLI; locate
the opencode property in packages/shared/src/agent-command.ts and update the
literal accordingly.

- Guard against heredoc delimiter collision with prompt content
- Derive API_PORT from SUPERSET_PORT_BASE for non-first workspaces
- Add error handling for mv in local MCP setup
- Validate localStorage agent type against AGENT_TYPES before use
@Kitenite Kitenite merged commit d92a4e6 into main Feb 22, 2026
13 checks passed
@Kitenite Kitenite deleted the kitenite/open-codex-mcp branch February 22, 2026 20:03
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.

1 participant