Repository navigation
Warn about and manage repository overrides for AI action recipes - #7386
Conversation
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.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughChangesThis 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
Compact metadata
Related issues: Not specified Poem 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (5)
src/renderer/src/components/settings/RepositorySourceControlAiActionRows.tsx (1)
251-298: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLocale 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 underRepositorySourceControlAiActionRows. 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 toen.jsonunder theauto.components.<Dir>.<ComponentFile>namespace."Source: Learnings
src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.tsx (1)
18-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider 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
neverexhaustiveness 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 winMissing test for the "+N more" overflow case.
No test covers the
hiddenOverrideCount > 0tooltip branch (more thanMAX_VISIBLE_REPOSoverrides). 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 valueScope-note computation looks correct.
agentScopeNotecorrectly gates onoverridesGlobalAgentand derives labels via the catalog. Minor edge case:labelForfalls back to the raw agent id string if the id isn't in the catalog (line 285), but sinceTuiAgentvalues 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 winMemoize the repo filter and per-action override summary.
reposis a freshly filtered array on every render, andsummarizeReposOverridingActionRecipeis 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 byuseSourceControlActionRecipeDraftStatein 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
useMemokeyed onrepos, or compute all summaries once outside the.mapin 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
📒 Files selected for processing (22)
src/renderer/src/components/right-sidebar/SourceControlAgentActionDialog.tsxsrc/renderer/src/components/right-sidebar/SourceControlAgentActionDialogForm.test.tsxsrc/renderer/src/components/right-sidebar/SourceControlAgentActionDialogForm.tsxsrc/renderer/src/components/right-sidebar/source-control-agent-action-dialog-result.tssrc/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.tssrc/renderer/src/components/settings/RepositorySourceControlAiActionRows.tsxsrc/renderer/src/components/settings/RepositorySourceControlAiSection.test.tssrc/renderer/src/components/settings/RepositorySourceControlAiSection.tsxsrc/renderer/src/components/settings/SourceControlActionRecipeRow.tsxsrc/renderer/src/components/settings/SourceControlActionRepoOverrideNote.test.tsxsrc/renderer/src/components/settings/SourceControlActionRepoOverrideNote.tsxsrc/renderer/src/components/settings/SourceControlAiActionRecipeDefaults.tsxsrc/renderer/src/components/settings/repository-settings-targets.tssrc/renderer/src/components/settings/repository-source-control-ai-draft.test.tssrc/renderer/src/components/settings/repository-source-control-ai-draft.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/source-control-launch-agent-selection.test.tssrc/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.
…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.
…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.
Summary
Warns about and manages repository overrides for AI action recipes.
Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildSourceControlAgentActionDialogForm.test.tsx.RepositorySourceControlAiSection.test.ts.SourceControlActionRepoOverrideNote.test.tsx.repository-source-control-ai-draft.test.ts.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.