Skip to content

Warn about and manage repository overrides for AI action recipes - #7386

Merged
AmethystLiang merged 3 commits into
mainfrom
conflict-resolve-button-not-wired-up
Jul 5, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
conflict-resolve-button-not-wired-up

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Warns about and manages repository overrides for AI action recipes.

  • Dialog warning: Surfaces a note in the source control launch dialog when a repository-specific override differs from the global default agent.
  • Settings override note: Warns on global settings recipe rows when one or more repositories have overrides that won't be updated by global changes, allowing the user to click "Review" to jump straight to that repository's settings.
  • Action-scoped save/discard: Allows saving or discarding individual repository action override drafts independently of sibling action rows.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed
    • Added unit tests for dialog form overrides in SourceControlAgentActionDialogForm.test.tsx.
    • Added unit tests for action rows override rendering in RepositorySourceControlAiSection.test.ts.
    • Added unit tests for repository override note rendering and action handler in SourceControlActionRepoOverrideNote.test.tsx.
    • Added unit tests for draft scoping helper in repository-source-control-ai-draft.test.ts.
    • Added unit tests for launch agent scope resolution and override summarization in source-control-launch-agent-selection.test.ts.

AI Review Report

Reviewed the agent selection logic, scope resolution, and settings state management to prevent accidental state flushes. Cross-platform compatibility was explicitly checked for macOS, Linux, and Windows, ensuring that settings paths, localized strings in multiple locales, and scroll-to anchor targets function correctly across all environments.

Security Audit

No security vulnerabilities introduced. All IPC configurations and repository updates are validated using standard state persistence helpers (toSourceControlAiRepoUpdate), avoiding any shell execution or injection risks.

Notes

Uses scroll anchor IDs (repo-${repoId}-source-control-ai-${actionId}) to jump directly to target repository settings rows from global default notes.

This improves the user experience around overriding global AI action recipe
defaults with repository-specific settings:
- In global settings, display a note if repositories override a recipe,
  with a shortcut to review those repository settings.
- In the agent launch dialog, show a warning if the repo overrides the
  global default and default the save target to the repo.
- In repository settings, support saving and discarding recipe overrides
  on a per-action basis.
@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 297a252c-fb86-4d94-bc99-7590cbebede3

📥 Commits

Reviewing files that changed from the base of the PR and between d36bf59 and 1543786.

📒 Files selected for processing (3)
  • src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.test.tsx
  • src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.tsx
  • src/renderer/src/components/settings/SourceControlAiActionRecipeDefaults.tsx

📝 Walkthrough

Walkthrough

Changes

This change adds repo-level source control AI override handling across dialog, settings, and localization flows. It introduces launch-agent scope resolution, per-repo override summaries, a scope note in the agent action dialog, and per-action save/discard controls in repository settings. It also adds a repo override note component with navigation into repo-specific settings, plus tests and locale strings for the new UI copy.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Rows as RepositorySourceControlAiActionRows
  participant Section as RepositorySourceControlAiSection
  participant Draft as buildActionScopedRepoAiSave
  User->>Rows: click Save on action
  Rows->>Section: onActionSave(actionId)
  Section->>Draft: buildActionScopedRepoAiSave(persisted, draft, actionId)
  Draft-->>Section: scoped RepoSourceControlAiOverrides
  Section->>Section: updateRepo(update)
  Section-->>Rows: isSaving=false, actionDirtyById updated
Loading

Compact metadata

  • Files changed: 22
  • Lines added/removed: approximately +860/-88 across renderer components, hooks, libs, and locale files
  • Test files: 5 new/updated test files

Related issues: Not specified
Related PRs: Not specified
Suggested labels: review_needed_junior_swe, review_depth_standard
Suggested reviewers: Not specified

Poem
A rabbit hopped through settings deep,
Found repos overriding, secrets to keep,
"Save this one, discard that," it cheered,
While scope notes whispered what agent steered,
Five locales sang the same override tune. 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: repository override warnings and management for AI action recipes.
Description check ✅ Passed The description matches the template and covers summary, screenshots, testing, AI review, security, and notes, with only minor detail gaps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@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.

🧹 Nitpick comments (5)
src/renderer/src/components/settings/RepositorySourceControlAiActionRows.tsx (1)

251-298: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Locale keys reuse another component file's namespace.

The footer's "Unsaved changes"/"Saved"/"Discard"/"Saving..."/"Save" strings reuse auto.components.settings.RepositorySourceControlAiSection.* keys rather than keys namespaced under RepositorySourceControlAiActionRows. This deviates from the established convention of scoping hash-based keys per component file.

Based on learnings: "use hash-based locale keys with translate('auto.components.<Dir>.<ComponentFile>.<10-char-hash>', 'Default English text')... Ensure the corresponding pre-generated keys are added to en.json under the auto.components.<Dir>.<ComponentFile> namespace."

Source: Learnings

src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.tsx (1)

18-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider an exhaustive switch for future-proofing.

The current if/if/else pattern silently falls back to "Command template" for any future field variant instead of failing at compile time. A switch with a never exhaustiveness check would catch this at the type level if the union is extended.

♻️ Proposed exhaustive switch
-function getRecipeOverrideFieldLabel(field: SourceControlActionRecipeOverrideField): string {
-  if (field === 'agent') {
-    return translate('auto.components.settings.SourceControlActionRepoOverrideNote.agent', 'Agent')
-  }
-  if (field === 'agentArgs') {
-    return translate(
-      'auto.components.settings.SourceControlActionRepoOverrideNote.agentArgs',
-      'CLI arguments'
-    )
-  }
-  return translate(
-    'auto.components.settings.SourceControlActionRepoOverrideNote.commandTemplate',
-    'Command template'
-  )
-}
+function getRecipeOverrideFieldLabel(field: SourceControlActionRecipeOverrideField): string {
+  switch (field) {
+    case 'agent':
+      return translate('auto.components.settings.SourceControlActionRepoOverrideNote.agent', 'Agent')
+    case 'agentArgs':
+      return translate(
+        'auto.components.settings.SourceControlActionRepoOverrideNote.agentArgs',
+        'CLI arguments'
+      )
+    case 'commandTemplate':
+      return translate(
+        'auto.components.settings.SourceControlActionRepoOverrideNote.commandTemplate',
+        'Command template'
+      )
+    default: {
+      const _exhaustive: never = field
+      return _exhaustive
+    }
+  }
+}
src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.test.tsx (1)

37-83: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing test for the "+N more" overflow case.

No test covers the hiddenOverrideCount > 0 tooltip branch (more than MAX_VISIBLE_REPOS overrides). Consider adding a case with 6+ overrides to assert the "+N more" text renders.

src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts (1)

279-295: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Scope-note computation looks correct.

agentScopeNote correctly gates on overridesGlobalAgent and derives labels via the catalog. Minor edge case: labelFor falls back to the raw agent id string if the id isn't in the catalog (line 285), but since TuiAgent values are all catalog-backed, this is unlikely to surface in practice.

src/renderer/src/components/settings/SourceControlAiActionRecipeDefaults.tsx (1)

93-95: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Memoize the repo filter and per-action override summary.

repos is a freshly filtered array on every render, and summarizeReposOverridingActionRecipe is invoked once per action id inside the render loop — an O(actions × repos) scan that reruns on every re-render, including keystrokes in the sibling CLI-args/template textareas driven by useSourceControlActionRecipeDraftState in this same component. For repos-heavy setups this recomputes on every character typed.

♻️ Suggested memoization
-  const repos = useRepos().filter((repo) => !isFolderRepo(repo))
+  const allRepos = useRepos()
+  const repos = useMemo(() => allRepos.filter((repo) => !isFolderRepo(repo)), [allRepos])

and either memoize per-action summaries with useMemo keyed on repos, or compute all summaries once outside the .map in a single pass.

Also applies to: 182-185


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e80a39d9-19e9-4e1a-a119-f6877fed8b14

📥 Commits

Reviewing files that changed from the base of the PR and between 85adb2d and 71b9211.

📒 Files selected for processing (22)
  • src/renderer/src/components/right-sidebar/SourceControlAgentActionDialog.tsx
  • src/renderer/src/components/right-sidebar/SourceControlAgentActionDialogForm.test.tsx
  • src/renderer/src/components/right-sidebar/SourceControlAgentActionDialogForm.tsx
  • src/renderer/src/components/right-sidebar/source-control-agent-action-dialog-result.ts
  • src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts
  • src/renderer/src/components/settings/RepositorySourceControlAiActionRows.tsx
  • src/renderer/src/components/settings/RepositorySourceControlAiSection.test.ts
  • src/renderer/src/components/settings/RepositorySourceControlAiSection.tsx
  • src/renderer/src/components/settings/SourceControlActionRecipeRow.tsx
  • src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.test.tsx
  • src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.tsx
  • src/renderer/src/components/settings/SourceControlAiActionRecipeDefaults.tsx
  • src/renderer/src/components/settings/repository-settings-targets.ts
  • src/renderer/src/components/settings/repository-source-control-ai-draft.test.ts
  • src/renderer/src/components/settings/repository-source-control-ai-draft.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/source-control-launch-agent-selection.test.ts
  • src/renderer/src/lib/source-control-launch-agent-selection.ts

Avoid re-filtering all repositories and re-computing override summaries
on every keystroke in sibling textareas.

Also use an exhaustive switch check for override field labels, and add
a test verifying the overflow note indicator when overrides exceed the
visible limit.
@AmethystLiang
AmethystLiang merged commit 16d08b4 into main Jul 5, 2026
1 check passed
@hmrserver hmrserver mentioned this pull request Jul 5, 2026
5 tasks done
tomdebres added a commit to tomdebres/orca that referenced this pull request Jul 5, 2026
…ld switch

pnpm lint fails on main since stablyai#7386: the override-field switch in
SourceControlActionRepoOverrideNote covers every union variant, and the
switch-exhaustiveness config sets allowDefaultCaseForExhaustiveSwitch:
false, so the hand-rolled never-guard default is rejected. The lint rule
itself already fails the build if the union grows a new variant, so the
guard is redundant — remove it.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…blyai#7386)

* Warn about and manage repository overrides for AI action recipes

This improves the user experience around overriding global AI action recipe
defaults with repository-specific settings:
- In global settings, display a note if repositories override a recipe,
  with a shortcut to review those repository settings.
- In the agent launch dialog, show a warning if the repo overrides the
  global default and default the save target to the repo.
- In repository settings, support saving and discarding recipe overrides
  on a per-action basis.

* Memoize repo filtering and override summaries in recipe defaults

Avoid re-filtering all repositories and re-computing override summaries
on every keystroke in sibling textareas.

Also use an exhaustive switch check for override field labels, and add
a test verifying the overflow note indicator when overrides exceed the
visible limit.
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