Skip to content

Fail on ambiguous Firefox targeting#5

Merged
Nek-12 merged 8 commits into
mainfrom
FFCLI-1
Jul 16, 2026
Merged

Fail on ambiguous Firefox targeting#5
Nek-12 merged 8 commits into
mainfrom
FFCLI-1

Conversation

@Nek-12

@Nek-12 Nek-12 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Reject omitted window or tab selectors when more than one candidate exists; explicit active, index, and ID selectors remain intentional.
  • Preserve selector omission through CLI and protocol boundaries so the extension—not parser defaults—owns ambiguity checks.
  • Make batch target locking dimension-aware, including window-only tab.new, window.select, and window.close steps.
  • Explain in tab select / window select help and text output that selection brings Firefox forward to the user and does not establish durable CLI target state.
  • Align route contracts, protocol schemas, documentation, and two-window regression coverage.

Verification

  • bun run check
  • 591 Vitest tests passed
  • git diff --check

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Nek-12, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 84965498-006e-4d74-8c55-34b395a343b4

📥 Commits

Reviewing files that changed from the base of the PR and between 1c50378 and 5a50b78.

📒 Files selected for processing (41)
  • docs/all-commands-qa.md
  • docs/architecture.md
  • docs/commands.md
  • docs/firefox-cli-spec.md
  • packages/cli/src/cli-batch-core.test.ts
  • packages/cli/src/cli-help.test.ts
  • packages/cli/src/cli-tabs-targets.test.ts
  • packages/cli/src/cli-target-contract.test.ts
  • packages/cli/src/cli-target-safety.test.ts
  • packages/cli/src/commands/batch.ts
  • packages/cli/src/commands/tabs-windows.ts
  • packages/cli/src/format.ts
  • packages/cli/src/help.ts
  • packages/cli/src/parse.ts
  • packages/cli/src/route-registry.ts
  • packages/extension/src/background-controller-test-cases.ts
  • packages/extension/src/browser-command/batch.ts
  • packages/extension/src/browser-command/target-context.test.ts
  • packages/extension/src/browser-command/target-context.ts
  • packages/extension/src/browser-command/targets.ts
  • packages/extension/src/browser-commands-batch-targeting.test.ts
  • packages/extension/src/browser-commands-batch.test.ts
  • packages/extension/src/browser-commands-targets.test.ts
  • packages/extension/src/browser-commands-test-cases.ts
  • packages/extension/src/browser-handlers/navigation.ts
  • packages/extension/src/browser-handlers/phase8-browser.ts
  • packages/extension/src/browser-handlers/tabs-windows.ts
  • packages/protocol/src/batch.ts
  • packages/protocol/src/browser/output.ts
  • packages/protocol/src/command-validation.ts
  • packages/protocol/src/metadata.ts
  • packages/protocol/src/protocol-metadata-behavior.test.ts
  • packages/protocol/src/protocol-request.test.ts
  • packages/protocol/src/protocol-response-6.test.ts
  • packages/protocol/src/protocol-test-support.ts
  • packages/protocol/src/registry/browsing.ts
  • packages/protocol/src/registry/define.ts
  • packages/protocol/src/registry/index.ts
  • packages/protocol/src/registry/phase8.ts
  • packages/protocol/src/target.ts
  • skills/firefox-cli/SKILL.md
📝 Walkthrough

Walkthrough

The change adds route-specific selector dimensions to protocol metadata, schemas, CLI parsing, help output, browser targeting tests, and documentation. Unsupported --window and --tab options now fail before transport, while valid selectors serialize into protocol target parameters.

Changes

Route-aware target contracts

Layer / File(s) Summary
Protocol selector contracts and registry
packages/protocol/src/metadata.ts, packages/protocol/src/target.ts, packages/protocol/src/registry/*, packages/protocol/src/*test*
Routes declare supported selector dimensions; schemas constrain window-only targets and non-negative IDs; registry assembly validates metadata against parameter schemas.
Route-aware CLI parsing and help
packages/cli/src/argv-contracts.ts, packages/cli/src/route-registry.ts, packages/cli/src/runner.ts, packages/cli/src/help.ts, packages/cli/src/*target*test.ts
CLI options and generated help are derived from route dimensions, supported selectors serialize into requests, and unsupported selectors are rejected before transport.
Window-targeted browser request behavior
packages/extension/src/browser-commands-targets.test.ts
Tests cover explicit window resolution, invalid-target rejection before side effects, and focus metadata updates without creating a durable target.
Targeting semantics documentation
docs/commands.md, docs/firefox-cli-spec.md, skills/firefox-cli/SKILL.md
Documentation describes advertised selector flags, accepted target formats, focus behavior, and screenshot activation effects.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant RouteRegistry
  participant ArgvParser
  participant BrowserExtension
  CLI->>RouteRegistry: resolve route and selector dimensions
  RouteRegistry->>ArgvParser: provide supported --window/--tab options
  ArgvParser->>BrowserExtension: send validated target request
  BrowserExtension-->>CLI: return targeted result and metadata
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the core change: tightening Firefox targeting behavior and rejecting ambiguous or unsupported targets.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch FFCLI-1

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abfaa2ef79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/protocol/src/target.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c50378a24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/protocol/src/target.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
packages/protocol/src/target.ts (1)

17-21: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Prefer z.discriminatedUnion for better performance and clearer error messages.

Because kind acts as a discriminator among the shapes, using z.discriminatedUnion("kind", [...]) provides O(1) evaluation and prevents misleading validation error messages compared to a standard z.union.

♻️ Proposed refactor
-export const targetDimensionSelectorSchema = z.union([
+export const targetDimensionSelectorSchema = z.discriminatedUnion("kind", [
   z.object({ kind: z.literal("active") }).strict(),
   z.object({ kind: z.literal("id"), id: z.number().int().nonnegative() }).strict(),
   z.object({ kind: z.literal("index"), index: z.number().int().nonnegative() }).strict(),
 ]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/protocol/src/target.ts` around lines 17 - 21, Update
targetDimensionSelectorSchema to use z.discriminatedUnion with "kind" as the
discriminator and retain the existing active, id, and index object schemas
unchanged.
packages/cli/src/route-registry.ts (1)

154-161: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify the generation of the selector usage suffix.

The array spread and ternary logic can be flattened into simple branching, making it slightly more direct and easier to read.

💡 Proposed refactor
-function withTargetSelectorUsage(help: string, selectorDimensions: CliRouteMetadata["selectorDimensions"]): string {
-  const selectorUsage = [
-    ...(selectorDimensions === "window" || selectorDimensions === "both" ? ["[--window <target>]"] : []),
-    ...(selectorDimensions === "tab" || selectorDimensions === "both" ? ["[--tab <target>]"] : []),
-  ];
-  return selectorUsage.length === 0 ? help : `${help} ${selectorUsage.join(" ")}`;
-}
+function withTargetSelectorUsage(help: string, selectorDimensions: CliRouteMetadata["selectorDimensions"]): string {
+  if (selectorDimensions === "neither") {
+    return help;
+  }
+  const usage = selectorDimensions === "both"
+    ? "[--window <target>] [--tab <target>]"
+    : `[--${selectorDimensions} <target>]`;
+  return `${help} ${usage}`;
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/route-registry.ts` around lines 154 - 161, Update
withTargetSelectorUsage to build the selector usage suffix through
straightforward branching instead of conditional array spreads and ternaries.
Preserve the existing ordering and inclusion rules for window, tab, both, and no
selector dimensions, as well as the current help-string formatting.
packages/cli/src/cli-tabs-targets.test.ts (1)

346-352: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify the flag support condition.

The boolean logic covers all valid paths but can be simplified into direct checks, taking advantage of the flag naming structure directly matching the dimension values.

💡 Proposed refactor
-function supportsSelectorFlag(selectorDimensions: "neither" | "window" | "tab" | "both", flag: "--tab" | "--window"): boolean {
-  return (
-    (flag === "--tab" && (selectorDimensions === "tab" || selectorDimensions === "both")) ||
-    (flag === "--window" && (selectorDimensions === "window" || selectorDimensions === "both"))
-  );
-}
+function supportsSelectorFlag(selectorDimensions: "neither" | "window" | "tab" | "both", flag: "--tab" | "--window"): boolean {
+  if (selectorDimensions === "both") return true;
+  if (selectorDimensions === "neither") return false;
+  return flag === `--${selectorDimensions}`;
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/cli-tabs-targets.test.ts` around lines 346 - 352, Update
supportsSelectorFlag to simplify the boolean condition by deriving the dimension
from the flag name and directly checking it against selectorDimensions, while
preserving "both" support and the existing behavior for all valid flag and
selector values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/cli/src/cli-tabs-targets.test.ts`:
- Around line 346-352: Update supportsSelectorFlag to simplify the boolean
condition by deriving the dimension from the flag name and directly checking it
against selectorDimensions, while preserving "both" support and the existing
behavior for all valid flag and selector values.

In `@packages/cli/src/route-registry.ts`:
- Around line 154-161: Update withTargetSelectorUsage to build the selector
usage suffix through straightforward branching instead of conditional array
spreads and ternaries. Preserve the existing ordering and inclusion rules for
window, tab, both, and no selector dimensions, as well as the current
help-string formatting.

In `@packages/protocol/src/target.ts`:
- Around line 17-21: Update targetDimensionSelectorSchema to use
z.discriminatedUnion with "kind" as the discriminator and retain the existing
active, id, and index object schemas unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2281a2db-9e4b-4bd9-84af-2ab8269beef7

📥 Commits

Reviewing files that changed from the base of the PR and between b7eb49a and 1c50378.

📒 Files selected for processing (26)
  • docs/commands.md
  • docs/firefox-cli-spec.md
  • packages/cli/src/argv-contracts.ts
  • packages/cli/src/cli-tabs-targets.test.ts
  • packages/cli/src/cli-target-contract.test.ts
  • packages/cli/src/help.ts
  • packages/cli/src/route-registry.test.ts
  • packages/cli/src/route-registry.ts
  • packages/cli/src/runner.ts
  • packages/extension/src/browser-commands-targets.test.ts
  • packages/protocol/src/browser/output.ts
  • packages/protocol/src/metadata.ts
  • packages/protocol/src/protocol-metadata-behavior.test.ts
  • packages/protocol/src/protocol-request.test.ts
  • packages/protocol/src/protocol-test-support.ts
  • packages/protocol/src/registry/actions.ts
  • packages/protocol/src/registry/browsing.ts
  • packages/protocol/src/registry/content.ts
  • packages/protocol/src/registry/core.ts
  • packages/protocol/src/registry/define.ts
  • packages/protocol/src/registry/index.ts
  • packages/protocol/src/registry/pairing.ts
  • packages/protocol/src/registry/phase8.ts
  • packages/protocol/src/registry/registry.test.ts
  • packages/protocol/src/target.ts
  • skills/firefox-cli/SKILL.md
💤 Files with no reviewable changes (1)
  • packages/protocol/src/browser/output.ts

@Nek-12 Nek-12 changed the title Harden explicit Firefox window targeting Fail on ambiguous Firefox targeting Jul 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d766b1534b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/extension/src/browser-command/batch.ts Outdated
@Nek-12
Nek-12 merged commit f0d2110 into main Jul 16, 2026
11 checks passed
@Nek-12
Nek-12 deleted the FFCLI-1 branch July 16, 2026 12:09
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