Skip to content

Fix duplicate session option flags and preserve argument values - #25382

Merged
AmethystLiang merged 2 commits into
mainfrom
fix-one-copy-chat-picked-flag
Oct 5, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
fix-one-copy-chat-picked-flag

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​312 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​303
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​109 $\color{#cf222e}{\Huge{\mathbf{−}}}$​37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​72

ELI5

Saved model picks and configured agent arguments could both send the same flag and stop an agent from starting. The launcher now sends the configured flag once and records only the picks it actually sends.

What Changed

  • Codex and Grok: a saved model plus a configured model could produce duplicate flags and prevent startup. The command now sends only the configured model, without options belonging to the overridden pick.
  • Claude: a picked Opus effort could leak into a configured Haiku launch. That effort is now omitted. A configured effort also replaces the picked effort without emitting both flags.
  • Codex -c model=o3: the command now sends the config override alone, without a competing generated -m. Tests cover the short, long, and joined forms; this does not assume which form Codex previously preferred.
  • Prompt text such as --model=haiku and --effort=low remains a value. Detection, removal, and worker flag insertion share the same matching rules. A prompt value of -- no longer gets mistaken for the argument terminator.

Each catalog identifies its agent to the existing matcher. Known required-value options for Claude and Cursor protect their dash-leading values; boolean and optional-valued options still allow following real flags to be recognized.

Why

The existing catalogs already map model and effort aliases, including Codex config keys. Resolving conflicts before building the command works with CLIs that reject duplicate flags and keeps the launch record accurate. Parsing arbitrary custom commands would confuse wrapper flags such as Docker's -m memory option with agent model flags.

Linked Issue

N/A — maintainer fix; no linked issue.

Visual Proof

N/A — generated CLI arguments change; regression tests assert the before/after behavior. No UI controls or layout changed.

Testing

  • 444 focused tests passed across shared launch code, downstream command plans, worker preferences, renderer callers, and runtime startup.

  • POSIX, PowerShell, and cmd command generation covered on a macOS host, including flag-like values, actual overrides, terminators, and custom-command guards. Existing remote POSIX quoting coverage also passed.

  • pnpm tc and pnpm run check:code-quality:changed passed. The commit hook passed oxlint, React Doctor lint, and formatting.

  • Live native Windows/SSH agent launches were not run. Full-suite tests and packaging are left to CI.

  • I manually tested agent startup in the app

  • Automated tests added/updated

Review

Self-reviewed the shared resolver, matcher consumers, worker argument replacement, and startup callers.

Agent skill upstream boundary

  • Not applicable; no agent skills changed.

Notes

Known limitation: model or effort flags inside a custom Agent Command can still conflict with picks and leave an inaccurate launch record. For example, codex -m o3 plus a picked gpt-5.5 can still emit both model flags. Custom-command handling is unchanged in this PR. A follow-up can inspect commands only when the first token is the agent's own binary, while preserving wrapper and shell commands.

Checklist

  • This PR is focused on launch argument conflicts
  • User-facing before/after, mechanism, and approach explained
  • Visual proof marked N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and folder workspace impact considered; no wire format or Git assumptions changed
  • Full lint, test suite, and build pass; CI covers these, with local focused tests, typecheck, and changed-code checks passing

@pullfrog pullfrog Bot left a comment

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.

Important

The production change is sound, but it leaves one existing test failing, so CI will be red until that expectation is updated.

Reviewed changes

  • Suppress generated model args when the model is overridden: resolveAgentSessionOptionLaunch no longer emits modelApply.launchArgs when modelOverridden, closing the duplicate -m/--model case.
  • Suppress model-scoped options when the model is overridden: options belonging to the picked model are now skipped when a user -m/--model wins, since that model's option menu may not apply.
  • Suppress an option's own args when that option is overridden: an option overridden by user args (e.g. --effort low) no longer emits its configured flag; it is still dropped from appliedValues.
  • Tests: new tui-agent-launch-command-pick-flags.test.ts pins single-flag output for Codex/Claude across command overrides, terminators, and shell quoting; the grok and startup expectations were updated.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

Agent argument parsing now accounts for required-value options when it finds terminators and matching flags. Launch command construction uses the selected agent’s argument rules to insert session options. Session option resolution omits picked arguments when user-supplied arguments override them. Tests cover these behaviors across agents and shell variants.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 09215

Cursor users who pass a dash-leading API key through -a may lose the selected model. Adding -a to the required-value options fixes this, and it is a narrow edge case.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: preventing duplicate session-option flags and preserving argument values.
Description check ✅ Passed The description covers the required sections and explains the change, rationale, testing, visual proof, review, and compatibility considerations. It identifies the linked issue as not applicable for a…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@AmethystLiang
AmethystLiang force-pushed the fix-one-copy-chat-picked-flag branch from 3a2f317 to 092159d Compare October 5, 2026 04:24
@AmethystLiang AmethystLiang changed the title Fix duplicate flags when user args override session options Fix duplicate session option flags and preserve argument values Oct 5, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 27780955-eec7-4679-868a-3ed20aee2679
📥 Commits

Reviewing files that changed from the base of the PR and between 3a2f317 and 092159d.

📒 Files selected for processing (16)
  • src/shared/agent-session-option-agent-args.ts
  • src/shared/agent-session-option-catalog-antigravity.ts
  • src/shared/agent-session-option-catalog-claude-codex.ts
  • src/shared/agent-session-option-catalog-codebuddy.ts
  • src/shared/agent-session-option-catalog-gemini-cursor.ts
  • src/shared/agent-session-option-catalog-grok.ts
  • src/shared/agent-session-option-catalog-muse.ts
  • src/shared/agent-session-option-catalog-omp.ts
  • src/shared/agent-session-option-catalog-opencode.test.ts
  • src/shared/agent-session-option-catalog-opencode.ts
  • src/shared/agent-session-option-catalog-removers.test.ts
  • src/shared/agent-session-option-catalog-types.ts
  • src/shared/command-option-occurrence.ts
  • src/shared/tui-agent-launch-command-argument-values.test.ts
  • src/shared/tui-agent-launch-command-pick-flags.test.ts
  • src/shared/tui-agent-launch-command.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@pullfrog pullfrog Bot left a comment

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.

✅ No new issues found.

Reviewed changes

Re-reviewed the single commit pushed since the prior pullfrog review (3a2f317d). The core override fix in agent-session-option-launch.ts is unchanged; the delta is value-aware argument scanning plus catalog plumbing.

  • Value-aware option scanning: findOptionOccurrence now accepts known required-value options and skips a following dash-leading token (including --), so prompt text like --model=haiku stays a value instead of reading as an override. removeAgentArgOption threads VALUE_OPTIONS[agent] through every catalog.
  • Terminator handling: insertBeforeTerminator uses the new agentArgTerminatorIndex, so a -- that is a required option's value no longer stops worker picks from landing before the real terminator; matchesOption no longer mistakes --=x for --.
  • Catalog plumbing: each catalog identifies its agent to the matcher, and the removeAgentArgs JSDoc reflects the widened contract.
  • Tests: new tui-agent-launch-command-argument-values.test.ts pins flag-like prompt values, -- values, inline values, and Cursor's dash-leading --api-key across posix/powershell/cmd; the stale OpenCode expectation from the prior review is now { args: [], appliedValues: {} }; the removers test covers the terminator scan.

The prior review's one thread is resolved by that OpenCode expectation update. I ran the seven touched suites locally — 135 tests pass.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@AmethystLiang
AmethystLiang merged commit f873aaa into main Oct 5, 2026
zpyoung added a commit to zpyoung/orca that referenced this pull request Oct 12, 2026
… and tolerate headless test doubles

- v1.4.222 (stablyai#25382) drops a structured flag that raw arguments shadow, because a
  repeated model flag can stop the CLI starting. Three fork tests still expected
  the duplicated flags; their original cases now use a non-shadowing raw argument
  and new cases pin the shadow behaviour.
- The re-homed automation dispatch seam called
  runtime.buildAutomationRunLaunchSettings directly, which upstream's headless
  orcad double does not provide; a fork helper returns null when the runtime
  lacks it.
- The PR field generation seam replaced upstream's overrides with resolved Source
  Control AI params even when nothing was saved to materialize; it now does so
  only when the recipe carries structured launch options.
zpyoung added a commit to zpyoung/orca that referenced this pull request Oct 12, 2026
…e fork tests

- The fork composer field handled paste in the bubble phase; upstream's field
  captures it, and non-bubbling paste events never reached the fork handler.
- The terminal dock seam reads the unified tab catalog and remote ConPTY state
  only when they exist and the dock is on, so upstream's minimal store doubles
  render TerminalPaneSurface.
- Two fork tests follow upstream behaviour: stablyai#25382's shadowed-flag rule, and the
  cancelSubscription call v1.4.224's abortable runtime calls make.
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