Skip to content

fix(desktop): preserve existing terminal presets during initialization#1421

Merged
Kitenite merged 1 commit into
mainfrom
kitenite/presets-fix
Feb 12, 2026
Merged

fix(desktop): preserve existing terminal presets during initialization#1421
Kitenite merged 1 commit into
mainfrom
kitenite/presets-fix

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 12, 2026

Summary

  • initializeDefaultPresets() was overwriting existing user terminal presets when terminalPresetsInitialized was null
  • Now preserves existing presets and only applies defaults when no presets exist

Changes

  • apps/desktop/src/lib/trpc/routers/settings/index.ts: Changed initializeDefaultPresets() to check for existing row.terminalPresets before applying defaults. If presets already exist, they are kept as-is and only the terminalPresetsInitialized flag is set to true.

Test Plan

  • Verify existing user presets are preserved when terminalPresetsInitialized is null
  • Verify default presets are still created for fresh installs (no existing presets)
  • Verify the function still early-returns when terminalPresetsInitialized is already true

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced terminal preset initialization to properly preserve and merge existing presets, preventing unnecessary regeneration of preset identifiers during setup.

initializeDefaultPresets() was overwriting user presets when
terminalPresetsInitialized was null. Now checks for existing presets
first and only applies defaults when none exist.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

Modified initializeDefaultPresets function to merge existing terminal presets with defaults rather than replacing them. The function now preserves existing preset IDs by checking if presets already exist in the database, and updates storage with the merged result instead of generating new presets.

Changes

Cohort / File(s) Summary
Preset Merge Logic
apps/desktop/src/lib/trpc/routers/settings/index.ts
Changed initializeDefaultPresets to merge existing terminal presets with defaults instead of replacing them. Now checks if row.terminalPresets contains items and reuses existing preset IDs; otherwise builds from DEFAULT_PRESETS. Updates database with merged presets in both insert and conflict scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Hooray! We merge presets with care,
Preserving each precious ID there,
No duplicates lost in the fray,
Settings dance and gracefully sway,
A rabbit's most jubilant day!

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main fix: preserving existing terminal presets during initialization, which directly matches the core change in the pull request.
Description check ✅ Passed The description covers the key sections including a summary of the fix, the specific file changes, and a test plan. While the formal template sections (Related Issues, Type of Change) are not explicitly filled, the core information is present and well-organized.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kitenite/presets-fix

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

@Kitenite Kitenite merged commit 862947b into main Feb 12, 2026
6 checks passed
@Kitenite Kitenite deleted the kitenite/presets-fix branch February 12, 2026 05:49
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app
  • ⚠️ Streams Fly.io app

Thank you for your contribution! 🎉

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