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/blog/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

47 changes: 45 additions & 2 deletions apps/desktop/src/main/lib/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class ConfigManager {
const defaultConfig: WorkspaceConfig = {
workspaces: [],
lastOpenedWorkspaceId: null,
activeWorktreeId: null,
activeTabGroupId: null,
activeTabId: null,
};
writeFileSync(
this.configPath,
Expand All @@ -46,15 +49,30 @@ class ConfigManager {
try {
const content = readFileSync(this.configPath, "utf-8");
const config = JSON.parse(content) as WorkspaceConfig;
// Ensure lastOpenedWorkspaceId exists for backwards compatibility
// Ensure fields exist for backwards compatibility
if (config.lastOpenedWorkspaceId === undefined) {
config.lastOpenedWorkspaceId = null;
}
if (config.activeWorktreeId === undefined) {
config.activeWorktreeId = null;
}
if (config.activeTabGroupId === undefined) {
config.activeTabGroupId = null;
}
if (config.activeTabId === undefined) {
config.activeTabId = null;
}
return config;
} catch (error) {
console.error("Failed to read config:", error);
// Return default config if read fails
return { workspaces: [], lastOpenedWorkspaceId: null };
return {
workspaces: [],
lastOpenedWorkspaceId: null,
activeWorktreeId: null,
activeTabGroupId: null,
activeTabId: null,
};
}
}

Expand Down Expand Up @@ -82,6 +100,31 @@ class ConfigManager {
config.lastOpenedWorkspaceId = id;
return this.write(config);
}

getActiveSelection(): {
worktreeId: string | null;
tabGroupId: string | null;
tabId: string | null;
} {
const config = this.read();
return {
worktreeId: config.activeWorktreeId,
tabGroupId: config.activeTabGroupId,
tabId: config.activeTabId,
};
}

setActiveSelection(
worktreeId: string | null,
tabGroupId: string | null,
tabId: string | null,
): boolean {
const config = this.read();
config.activeWorktreeId = worktreeId;
config.activeTabGroupId = tabGroupId;
config.activeTabId = tabId;
return this.write(config);
}
}

export default ConfigManager.getInstance();
36 changes: 32 additions & 4 deletions apps/desktop/src/main/lib/workspace-ipcs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { BrowserWindow, dialog, ipcMain } from "electron";

import type {
CreateScreenInput,
CreateTabGroupInput,
CreateTabInput,
CreateWorkspaceInput,
CreateWorktreeInput,
UpdateWorkspaceInput,
} from "shared/types";

import configManager from "./config-manager";
import workspaceManager from "./workspace-manager";

export function registerWorkspaceIPCs() {
Expand Down Expand Up @@ -123,9 +125,17 @@ export function registerWorkspaceIPCs() {
},
);

// Create screen
ipcMain.handle("screen-create", async (_event, input: CreateScreenInput) => {
return await workspaceManager.createScreen(input);
// Create tab group
ipcMain.handle(
"tab-group-create",
async (_event, input: CreateTabGroupInput) => {
return await workspaceManager.createTabGroup(input);
},
);

// Create tab
ipcMain.handle("tab-create", async (_event, input: CreateTabInput) => {
return await workspaceManager.createTab(input);
});

// Scan and import existing worktrees
Expand All @@ -135,4 +145,22 @@ export function registerWorkspaceIPCs() {
return await workspaceManager.scanAndImportWorktrees(workspaceId);
},
);

// Get active selection
ipcMain.handle("workspace-get-active-selection", async () => {
return configManager.getActiveSelection();
});

// Set active selection
ipcMain.handle(
"workspace-set-active-selection",
async (
_event,
worktreeId: string | null,
tabGroupId: string | null,
tabId: string | null,
) => {
return configManager.setActiveSelection(worktreeId, tabGroupId, tabId);
},
);
}
Loading
Loading