Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@superset/desktop",
"productName": "Superset",
"description": "The last developer tool you'll ever need",
"version": "0.0.23",
"version": "0.0.24",
"main": "./dist/main/index.js",
"resources": "src/resources",
"repository": {
Expand Down
54 changes: 2 additions & 52 deletions apps/desktop/src/lib/trpc/routers/settings/index.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,19 @@
import { db } from "main/lib/db";
import type { TerminalPreset } from "main/lib/db/schemas";
import { nanoid } from "nanoid";
import { DEFAULT_RINGTONE_ID, RINGTONES } from "shared/ringtones";
import { z } from "zod";
import { publicProcedure, router } from "../..";

/** Valid ringtone IDs for validation */
const VALID_RINGTONE_IDS = RINGTONES.map((r) => r.id);

/** Default presets to load when no presets exist */
const DEFAULT_PRESETS: Omit<TerminalPreset, "id">[] = [
{
name: "codex",
description: "Danger mode: All permissions auto-approved",
cwd: "",
commands: [
'codex -c model_reasoning_effort="high" --ask-for-approval never --sandbox danger-full-access -c model_reasoning_summary="detailed" -c model_supports_reasoning_summaries=true',
],
},
{
name: "claude",
description: "Danger mode: All permissions auto-approved",
cwd: "",
commands: ["claude --dangerously-skip-permissions"],
},
];

export const createSettingsRouter = () => {
return router({
getLastUsedApp: publicProcedure.query(() => {
return db.data.settings.lastUsedApp ?? "cursor";
}),

getTerminalPresets: publicProcedure.query(async () => {
const { terminalPresets, terminalPresetsInitialized } = db.data.settings;

// Handle first-time initialization
if (!terminalPresetsInitialized) {
// If user already has presets (from before the flag existed), preserve them
if (terminalPresets && terminalPresets.length > 0) {
await db.update((data) => {
data.settings.terminalPresetsInitialized = true;
});
return terminalPresets;
}

// No existing presets - seed with defaults
const defaultPresetsWithIds: TerminalPreset[] = DEFAULT_PRESETS.map(
(preset) => ({
id: nanoid(),
...preset,
}),
);

await db.update((data) => {
data.settings.terminalPresets = defaultPresetsWithIds;
data.settings.terminalPresetsInitialized = true;
});

return defaultPresetsWithIds;
}

return terminalPresets ?? [];
getTerminalPresets: publicProcedure.query(() => {
return db.data.settings.terminalPresets ?? [];
}),

createTerminalPreset: publicProcedure
.input(
z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import codexIcon from "./codex.svg";
import codexWhiteIcon from "./codex-white.svg";
import cursorIcon from "./cursor.svg";
import geminiIcon from "./gemini.svg";
import opencodeIcon from "./opencode.svg";
import opencodeWhiteIcon from "./opencode-white.svg";

interface PresetIconSet {
light: string;
Expand All @@ -15,6 +17,7 @@ const PRESET_ICONS: Record<string, PresetIconSet> = {
codex: { light: codexIcon, dark: codexWhiteIcon },
gemini: { light: geminiIcon, dark: geminiIcon },
"cursor-agent": { light: cursorIcon, dark: cursorIcon },
opencode: { light: opencodeIcon, dark: opencodeWhiteIcon },
};

export function getPresetIcon(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ const PRESET_TEMPLATES: PresetTemplate[] = [
commands: ["cursor-agent"],
},
},
{
name: "opencode",
preset: {
name: "opencode",
description: "OpenCode: Open source AI coding agent",
cwd: "",
commands: ["opencode"],
},
},
];

export function PresetsSettings() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DiffEditor, type DiffOnMount } from "@monaco-editor/react";
import { useCallback, useEffect, useRef } from "react";
import { useCallback, useRef } from "react";
import { monaco, SUPERSET_THEME } from "renderer/contexts/MonacoProvider";
import type { DiffViewMode, FileContents } from "shared/changes-types";

Expand Down Expand Up @@ -40,12 +40,6 @@ export function DiffViewer({
[editable, handleSave],
);

useEffect(() => {
return () => {
modifiedEditorRef.current = null;
};
}, []);

return (
<div className="h-full w-full">
<DiffEditor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export function TabsView() {
const activeWorkspaceId = activeWorkspace?.id;
const allTabs = useTabsStore((s) => s.tabs);
const addTab = useTabsStore((s) => s.addTab);
const addPane = useTabsStore((s) => s.addPane);
const renameTab = useTabsStore((s) => s.renameTab);
const reorderTabById = useTabsStore((s) => s.reorderTabById);
const activeTabIds = useTabsStore((s) => s.activeTabIds);
Expand All @@ -55,24 +54,11 @@ export function TabsView() {
[activeWorkspaceId, allTabs],
);

const activeTabId = activeWorkspaceId
? activeTabIds[activeWorkspaceId]
: null;

const handleAddTab = () => {
if (!activeWorkspaceId) return;

// If there's an active tab, add a pane to it instead of creating a new tab
if (activeTabId) {
const paneId = addPane(activeTabId);
// Fall back to creating a new tab if the active tab no longer exists
if (!paneId) {
addTab(activeWorkspaceId);
}
} else {
if (activeWorkspaceId) {
addTab(activeWorkspaceId);
setCommandOpen(false);
}
setCommandOpen(false);
};

const handleOpenPresetsSettings = () => {
Expand All @@ -83,28 +69,15 @@ export function TabsView() {
const handleSelectPreset = (preset: TerminalPreset) => {
if (!activeWorkspaceId) return;

const presetOptions = {
// Pass preset options to addTab - Terminal component will read them from pane state
const { tabId } = addTab(activeWorkspaceId, {
initialCommands: preset.commands,
initialCwd: preset.cwd || undefined,
name: preset.name || undefined,
};
});

// If there's an active tab, add a pane to it instead of creating a new tab
if (activeTabId) {
const paneId = addPane(activeTabId, presetOptions);
// Fall back to creating a new tab if the active tab no longer exists
if (!paneId) {
const { tabId } = addTab(activeWorkspaceId, presetOptions);
if (preset.name) {
renameTab(tabId, preset.name);
}
}
} else {
const { tabId } = addTab(activeWorkspaceId, presetOptions);
// Rename the tab to the preset name only when creating a new tab
if (preset.name) {
renameTab(tabId, preset.name);
}
// Rename the tab to the preset name
if (preset.name) {
renameTab(tabId, preset.name);
}

setCommandOpen(false);
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/renderer/stores/tabs/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ export const useTabsStore = create<TabsStore>()(
},

// Pane operations
addPane: (tabId, options?: CreatePaneOptions) => {
addPane: (tabId) => {
const state = get();
const tab = state.tabs.find((t) => t.id === tabId);
if (!tab) return "";

const newPane = createPane(tabId, "terminal", options);
const newPane = createPane(tabId);

// Add pane to layout (append to the right)
const newLayout: MosaicNode<string> = {
Expand Down
4 changes: 1 addition & 3 deletions apps/desktop/src/renderer/stores/tabs/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { MosaicBranch, MosaicNode } from "react-mosaic-component";
import type { BaseTab, BaseTabsState, Pane, PaneType } from "shared/tabs-types";
import type { CreatePaneOptions } from "./utils";

// Re-export shared types
export type { Pane, PaneType };
Expand All @@ -27,7 +26,6 @@ export interface TabsState extends Omit<BaseTabsState, "tabs"> {
export interface AddTabOptions {
initialCommands?: string[];
initialCwd?: string;
name?: string;
}

/**
Expand All @@ -52,7 +50,7 @@ export interface TabsStore extends TabsState {
updateTabLayout: (tabId: string, layout: MosaicNode<string>) => void;

// Pane operations
addPane: (tabId: string, options?: CreatePaneOptions) => string;
addPane: (tabId: string) => string;
removePane: (paneId: string) => void;
setFocusedPane: (tabId: string, paneId: string) => void;
markPaneAsUsed: (paneId: string) => void;
Expand Down
3 changes: 1 addition & 2 deletions apps/desktop/src/renderer/stores/tabs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const extractPaneIdsFromLayout = (
export interface CreatePaneOptions {
initialCommands?: string[];
initialCwd?: string;
name?: string;
}

/**
Expand All @@ -55,7 +54,7 @@ export const createPane = (
id,
tabId,
type,
name: options?.name || "Terminal",
name: "Terminal",
isNew: true,
initialCommands: options?.initialCommands,
initialCwd: options?.initialCwd,
Expand Down