Skip to content

feat(desktop): seed claude and codex as default terminal presets#1401

Merged
AviPeltz merged 1 commit into
mainfrom
pre-added-presets
Feb 11, 2026
Merged

feat(desktop): seed claude and codex as default terminal presets#1401
AviPeltz merged 1 commit into
mainfrom
pre-added-presets

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Feb 11, 2026

Summary

  • Seeds claude and codex as default terminal presets for new users on first launch
  • Uses the existing terminalPresetsInitialized flag in the settings table to ensure presets are only seeded once
  • Existing users are unaffected — initialization only runs when the flag is falsy

Test plan

  • Fresh install: verify claude and codex presets appear in Settings > Terminal > Presets
  • Existing install: verify no duplicate presets are created
  • Quick-add buttons show "Already added" for claude and codex after initialization

Summary by CodeRabbit

New Features

  • Added default terminal presets to the desktop application that are automatically initialized and available on first launch, eliminating manual setup for common configurations.

New users get claude and codex presets pre-populated on first launch
using the existing terminalPresetsInitialized flag.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

This change introduces a default terminal presets mechanism to the settings router. It adds DEFAULT_PRESETS containing preset configurations, implements initializeDefaultPresets() to generate IDs and persist presets to storage, and updates getTerminalPresets to automatically initialize defaults on first retrieval if not already done.

Changes

Cohort / File(s) Summary
Default Terminal Presets Initialization
apps/desktop/src/lib/trpc/routers/settings/index.ts
Added DEFAULT_PRESETS data structure with two preset configurations (claude, codex), initializeDefaultPresets() function to generate IDs and persist to database with conflict handling, and updated getTerminalPresets() to trigger initialization if terminalPresetsInitialized flag is false.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Router as Settings Router
    participant DB as Database
    
    Client->>Router: getTerminalPresets()
    Router->>Router: Check terminalPresetsInitialized flag
    alt Flag is false
        Router->>Router: initializeDefaultPresets()
        Router->>Router: Generate preset IDs
        Router->>DB: Store presets with conflict update
        Router->>DB: Mark terminalPresetsInitialized = true
    else Flag is true
        Router->>Router: Skip initialization
    end
    Router->>Client: Return presets
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Presets now bloom on first load's gentle call,
Default Claude and Codex, stored for one and all!
A flag to guard against the double-init blight,
Your terminal presets, forever done just right! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the key aspects (summary, test plan) but is missing required template sections like Related Issues, Type of Change, Screenshots, and Additional Notes. Add missing sections from the template: Related Issues, Type of Change (mark 'New feature'), and other optional sections to fully comply with repository standards.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: seeding claude and codex as default terminal presets, which aligns perfectly with the code changes and PR objectives.

✏️ 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 pre-added-presets

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/desktop/src/lib/trpc/routers/settings/index.ts`:
- Around line 51-77: initializeDefaultPresets currently overwrites existing user
presets when terminalPresetsInitialized is null; change it to merge
DEFAULT_PRESETS with any existing row.terminalPresets returned by getSettings()
instead of replacing them: build mergedPresets by taking existing presets first,
add defaults whose name is not already present (deduplicate by name), ensure
each added default gets a new id via crypto.randomUUID(), then upsert
terminalPresets to mergedPresets and set terminalPresetsInitialized = true (use
the same localDb.insert(...).onConflictDoUpdate(...) flow). Keep getSettings(),
initializeDefaultPresets(), and the upsert call as the touch points.
🧹 Nitpick comments (1)
apps/desktop/src/lib/trpc/routers/settings/index.ts (1)

97-103: Add a log entry when seeding default presets.

Per coding guidelines, significant operations should use prefixed console logging. The initialization is a one-time side effect worth logging for debuggability.

Suggested change
 		getTerminalPresets: publicProcedure.query(() => {
 			const row = getSettings();
 			if (!row.terminalPresetsInitialized) {
+				console.log("[settings/presets] Initializing default terminal presets");
 				return initializeDefaultPresets();
 			}
 			return row.terminalPresets ?? [];
 		}),

As per coding guidelines, "Use prefixed console logging with consistent context pattern: [domain/operation] message for entry/exit of significant operations".

Comment on lines +51 to +77
function initializeDefaultPresets() {
const row = getSettings();
if (row.terminalPresetsInitialized) return row.terminalPresets ?? [];

const presets: TerminalPreset[] = DEFAULT_PRESETS.map((p) => ({
id: crypto.randomUUID(),
...p,
}));

localDb
.insert(settings)
.values({
id: 1,
terminalPresets: presets,
terminalPresetsInitialized: true,
})
.onConflictDoUpdate({
target: settings.id,
set: {
terminalPresets: presets,
terminalPresetsInitialized: true,
},
})
.run();

return presets;
}
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Feb 11, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for terminalPresetsInitialized usage and migrations
echo "=== Searching for terminalPresetsInitialized ==="
rg -n 'terminalPresetsInitialized' --type ts -A 2 -B 2

echo -e "\n=== Searching for database migrations ==="
find . -name "*migration*" -o -name "*schema*" | grep -E '\.(ts|js|sql)$' | head -20

echo -e "\n=== Checking for drizzle migrations ==="
fd -e ts -e sql 'migration'

Repository: superset-sh/superset

Length of output: 2566


🏁 Script executed:

#!/bin/bash
# Look for getSettings implementation
echo "=== Finding getSettings implementation ==="
rg -n 'function getSettings|const getSettings' --type ts -A 10

echo -e "\n=== Check for database schema definition ==="
rg -n 'const settings|export const settings' --type ts -A 20 | head -60

Repository: superset-sh/superset

Length of output: 6246


🏁 Script executed:

#!/bin/bash
# Check the initial migration schema for settings table
echo "=== Checking initial migration ==="
cat packages/local-db/drizzle/0000_initial_schema.sql | grep -A 20 "settings"

echo -e "\n=== Check if there are any other migration files ==="
ls -la packages/local-db/drizzle/

Repository: superset-sh/superset

Length of output: 2746


🏁 Script executed:

#!/bin/bash
# Check package.json to understand drizzle setup and if migrations are auto-generated
echo "=== Checking local-db package config ==="
cat packages/local-db/package.json

echo -e "\n=== Check for any migration generation logs or pushdb ==="
grep -r "drizzle-kit" packages/local-db/ --type json

Repository: superset-sh/superset

Length of output: 989


🏁 Script executed:

#!/bin/bash
# Search for all places that modify terminalPresets
echo "=== Searching for all writes to terminalPresets ==="
rg -n 'terminalPresets' --type ts -B 2 -A 2

echo -e "\n=== Check the full settings router to understand all preset operations ==="
cat apps/desktop/src/lib/trpc/routers/settings/index.ts

Repository: superset-sh/superset

Length of output: 24817


Critical: initializeDefaultPresets overwrites existing user presets on upgrade.

The column terminalPresetsInitialized is uninitialized (null) for existing users after a schema migration. When getTerminalPresets is called post-upgrade, !row.terminalPresetsInitialized evaluates to true, and this function replaces any existing terminalPresets with only the two defaults — destroying presets the user may have already created.

Merge defaults with existing presets and deduplicate by name to avoid losing user-created presets and prevent adding defaults that match existing ones.

Proposed fix
 function initializeDefaultPresets() {
 	const row = getSettings();
 	if (row.terminalPresetsInitialized) return row.terminalPresets ?? [];
 
-	const presets: TerminalPreset[] = DEFAULT_PRESETS.map((p) => ({
+	const existing = row.terminalPresets ?? [];
+	const existingNames = new Set(existing.map((p) => p.name.toLowerCase()));
+
+	const newDefaults: TerminalPreset[] = DEFAULT_PRESETS
+		.filter((p) => !existingNames.has(p.name.toLowerCase()))
+		.map((p) => ({
 		id: crypto.randomUUID(),
 		...p,
 	}));
 
+	const presets = [...existing, ...newDefaults];
+
 	localDb
 		.insert(settings)
 		.values({
🤖 Prompt for AI Agents
In `@apps/desktop/src/lib/trpc/routers/settings/index.ts` around lines 51 - 77,
initializeDefaultPresets currently overwrites existing user presets when
terminalPresetsInitialized is null; change it to merge DEFAULT_PRESETS with any
existing row.terminalPresets returned by getSettings() instead of replacing
them: build mergedPresets by taking existing presets first, add defaults whose
name is not already present (deduplicate by name), ensure each added default
gets a new id via crypto.randomUUID(), then upsert terminalPresets to
mergedPresets and set terminalPresetsInitialized = true (use the same
localDb.insert(...).onConflictDoUpdate(...) flow). Keep getSettings(),
initializeDefaultPresets(), and the upsert call as the touch points.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@AviPeltz AviPeltz merged commit 8c0bbb8 into main Feb 11, 2026
6 checks passed
@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.

2 participants