Preserve future API mode defaults after customization#1009
Preserve future API mode defaults after customization#1009PeterDaveHello wants to merge 1 commit into
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughSchema version 2 introduces materialized API mode defaults, migration reconciliation, atomic popup updates, and import normalization for API mode fields and known default identifiers. ChangesAPI mode defaults and migration
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)Configuration migrationsequenceDiagram
participant getUserConfig
participant migrateUserConfig
participant reconcileMaterializedApiModeDefaults
participant BrowserStorage
getUserConfig->>migrateUserConfig: migrate stored configuration
migrateUserConfig->>reconcileMaterializedApiModeDefaults: reconcile known defaults
reconcileMaterializedApiModeDefaults-->>migrateUserConfig: return modes and known IDs
migrateUserConfig-->>getUserConfig: return migrated config and keys
getUserConfig->>BrowserStorage: persist migration
BrowserStorage-->>getUserConfig: confirm successful write
getUserConfig->>BrowserStorage: remove obsolete keys
Popup API mode updatessequenceDiagram
participant ApiModes
participant api_mode_config_utils
participant PopupUpdateConfig
participant BrowserStorage
ApiModes->>api_mode_config_utils: build atomic API mode update
api_mode_config_utils-->>ApiModes: return normalized bundle
ApiModes->>PopupUpdateConfig: submit expanded patch
PopupUpdateConfig->>BrowserStorage: persist update
BrowserStorage-->>PopupUpdateConfig: return success or failure
PopupUpdateConfig-->>ApiModes: apply update or rollback
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
PR Summary by QodoPreserve future API mode defaults after profile customization
AI Description
Diagram
High-Level Assessment
Files changed (10)
|
Code Review SummaryStatus: No New Issues Found (incremental) | Recommendation: Merge Incremental diff since Prior CRITICAL/WARNING findings on lines 266/283/150/1630/1638/1589/45/95/158/27 are outside this incremental diff and were previously marked fixed, resolved, or not-adopted by the author; no new issues are raised here. Files Reviewed (2 files)
Previous Review Summaries (5 snapshots, latest commit cbfaec7)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit cbfaec7)Status: No New Issues Found (incremental) | Recommendation: Merge Incremental diff since Prior CRITICAL/WARNING findings on lines 266/283/150/1630/1638/1589/45/95/158/27 are outside this incremental diff and were previously marked fixed, resolved, or not-adopted by the author; no new issues are raised here. Files Reviewed (2 files)
Previous review (commit 15257cc)Status: No New Issues Found (incremental) | Recommendation: Merge Incremental diff since Prior CRITICAL/WARNING findings on lines 266/150/283/1589/1630/1638 are outside this incremental diff and were previously marked fixed or not-adopted; no new issues are raised here. Files Reviewed (2 files)
Previous review (commit f53bcf1)Status: 6 Issues Found (verified carry-forward) | Recommendation: Address before merge
Overview
Issue Details (click to expand)CRITICAL
WARNING
SUGGESTION
Resolved / Verified
Files Reviewed (10 files)
Fix these issues in Kilo Cloud Previous review (commit da25801)Status: 4 Issues Found (verified carry-forward) | Recommendation: Address before merge
Overview
Issue Details (click to expand)CRITICAL
WARNING
SUGGESTION
Resolved / Verified
Files Reviewed (10 files)
Previous review (commit d99a2c6)Status: No Issues Found | Recommendation: Merge Files Reviewed (10 files)
Reviewed by hy3:free · Input: 66.3K · Output: 1.9K · Cached: 226.1K |
There was a problem hiding this comment.
Code Review
This pull request implements a significant refactor of the API mode configuration system, introducing a versioned schema (upgraded to version 2) and a more robust mechanism for materializing default API modes. It introduces 'knownApiModeDefaultIds' to track and reconcile default modes, ensuring that user configurations remain stable across updates while allowing for the seamless addition of new defaults. The changes include updates to the migration logic, the introduction of utility functions for building and expanding configuration updates, and comprehensive unit tests to verify the migration paths and default reconciliation behavior.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/popup/sections/import-data-cleanup.mjs`:
- Around line 13-23: Update prepareImportData so replacing any API-mode list
also resets missing apiMode and modelName fields to null, preventing storage
merging from retaining stale selections. Use the existing list-replacement
detection and list metadata, and extend the import integration test to cover
omitted selection fields and stale persisted values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 21afd85f-7b39-49f4-a85d-d2e85332c7cd
📒 Files selected for processing (10)
src/config/index.mjssrc/popup/Popup.jsxsrc/popup/api-mode-config-utils.mjssrc/popup/sections/ApiModes.jsxsrc/popup/sections/import-data-cleanup.mjssrc/utils/model-name-convert.mjstests/unit/config/migrate-user-config.test.mjstests/unit/popup/api-mode-config-utils.test.mjstests/unit/popup/import-data-cleanup.test.mjstests/unit/utils/model-name-convert.test.mjs
There was a problem hiding this comment.
Code Review
This pull request introduces a robust migration system for API mode configurations, transitioning from a simple list to a versioned, materialized baseline approach. It adds a new schema version (v2), introduces knownApiModeDefaultIds to track default API modes, and implements reconciliation logic to ensure user configurations remain consistent across updates. The changes include utility functions for building and expanding configuration updates, as well as comprehensive unit tests to verify the migration and reconciliation behavior. I have kept the critical feedback regarding the inconsistent handling of 'customModel' and the suggestion to simplify the baseline check condition.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Pull request overview
This PR updates how API mode lists are persisted for customized profiles by introducing a “known default baseline” (knownApiModeDefaultIds). The goal is to let the extension append newly introduced default API modes in future releases without reintroducing defaults that a user previously removed, while keeping migrations/backups deterministic and rollback-safe.
Changes:
- Introduces
defaultApiModeIds+knownApiModeDefaultIdsand migration logic to distinguish “live default” profiles from materialized/customized ones, and to reconcile future defaults deterministically. - Ensures API mode list + selection state are persisted as an atomic bundle in popup updates (including rollback-safe behavior on write failure).
- Adds import cleanup behavior to clear stale/missing API mode fields for older backups, plus broad unit test coverage for the new behaviors.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/utils/model-name-convert.test.mjs | Adds unit tests for default reconciliation, dedupe behavior, and Azure/Ollama preset handling. |
| tests/unit/popup/import-data-cleanup.test.mjs | Adds tests ensuring imported backups deterministically clear/normalize API mode state. |
| tests/unit/popup/api-mode-config-utils.test.mjs | Adds tests for atomic API mode list update/rollback helpers used by the popup. |
| tests/unit/config/migrate-user-config.test.mjs | Extends migration tests for schema v2 baseline behavior and deterministic retry after write failure. |
| src/utils/model-name-convert.mjs | Adds default reconciliation helper and adjusts filtering logic for AlwaysCustomGroups. |
| src/popup/sections/import-data-cleanup.mjs | Normalizes imported API mode fields (including baseline) and ensures missing fields are cleared atomically. |
| src/popup/sections/ApiModes.jsx | Switches API mode edits/toggles/deletes to use atomic list+selection update helper. |
| src/popup/Popup.jsx | Ensures API mode list updates are expanded into a complete atomic bundle before queueing persistence. |
| src/popup/api-mode-config-utils.mjs | Introduces helpers to build/expand atomic API mode list config updates. |
| src/config/index.mjs | Adds defaultApiModeIds, bumps schema version, and implements baseline-aware migration + safe persistence/removal ordering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d99a2c6 to
da25801
Compare
|
/agentic_review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a robust migration and materialization system for API modes, upgrading the configuration schema to version 2. It centralizes default API mode management, improves configuration consistency by introducing knownApiModeDefaultIds, and adds utility functions to handle the reconciliation of materialized defaults. The changes also include comprehensive unit tests to verify the migration logic and ensure backward compatibility. I have included a suggestion to extract the array sanitization logic into a shared utility function to improve maintainability and reduce code duplication.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Code review by qodo was updated up to the latest commit da25801 |
da25801 to
f53bcf1
Compare
|
/agentic_review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the user configuration schema from version 1 to 2, introducing a more robust mechanism for handling default and customized API modes. It adds defaultApiModeIds and knownApiModeDefaultIds to allow untouched profiles to dynamically read live defaults while appending future defaults to customized profiles. The migration logic in migrateUserConfig has been updated to manage these keys and clean up stale storage keys. Additionally, the popup configuration update flow has been refactored, and extensive unit tests have been added. Feedback on these changes highlights that silently ignoring errors during Browser.storage.local.remove could leave the storage in an inconsistent state if a removal fails after a successful write, potentially corrupting subsequent configuration migrations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Code review by qodo was updated up to the latest commit f53bcf1 |
f53bcf1 to
15257cc
Compare
|
/agentic_review |
|
/gemini review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15257cc5e6
ℹ️ 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".
There was a problem hiding this comment.
Code Review
This pull request updates the configuration schema to version 2, introducing a baseline tracking system via knownApiModeDefaultIds to manage default API modes dynamically. It materializes default API modes into customApiModes for customized profiles while allowing untouched profiles to read live defaults, and updates the popup components and import utilities to handle these updates atomically. The feedback suggests simplifying state management in ApiModes.jsx by deriving model names directly from the apiModes state rather than relying on a redundant state variable, and using optional chaining in expandApiModeListConfigUpdate to safely handle potentially null or undefined configurations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Code review by qodo was updated up to the latest commit 15257cc |
15257cc to
cbfaec7
Compare
|
/agentic_review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors API mode configuration management by bumping the schema version to 2 and introducing a default baseline tracking mechanism (knownApiModeDefaultIds). This ensures untouched profiles use live defaults while customized profiles safely append future defaults. The changes include atomic config update helpers, import/export cleanup, and extensive unit tests. The review feedback focuses on enhancing robustness, specifically recommending keeping modelName and apiMode in sync during edits, guarding against potential TypeErrors when accessing properties of potentially null or undefined objects (data and currentConfig), and ensuring array checks are performed before canonicalizing model keys.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Code review by qodo was updated up to the latest commit cbfaec7 |
Track the default API mode IDs seen by materialized profiles so newly introduced defaults can be appended without restoring modes users previously removed. Migrate legacy list states, keep import recovery deterministic, and persist list and selection changes as one rollback-safe update.
cbfaec7 to
ed87e8d
Compare
|
/agentic_review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request upgrades the configuration schema to version 2, introducing a mechanism to manage API mode defaults and customizations. Untouched profiles now read live defaults dynamically, while customized profiles materialize their settings into customApiModes and track them using knownApiModeDefaultIds. The update includes migration logic, popup utility enhancements, import data cleanup, and comprehensive unit tests. The review feedback recommends adding defensive checks, specifically validating the input data object in prepareImportData and using optional chaining on currentConfig in expandApiModeListConfigUpdate to prevent potential runtime crashes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Code review by qodo was updated up to the latest commit ed87e8d |
Summary
Validation
npm run lintnpm test(714 tests)npm run buildRollout
This is phase 1 of the future-default rollout. The API mode reorder UI is intentionally deferred until this PR is accepted.
Summary by CodeRabbit