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
11 changes: 5 additions & 6 deletions apps/desktop/src/main/lib/terminal-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,11 @@ describe("TerminalManager", () => {
testTmpDir,
".superset/terminal-history/workspace-1/tab-delete-history",
);
try {
await fs.stat(historyDir);
throw new Error("Directory should not exist");
} catch (error) {
expect((error as NodeJS.ErrnoException).code).toBe("ENOENT");
}
const exists = await fs
.stat(historyDir)
.then(() => true)
.catch(() => false);
expect(exists).toBe(false);
});

it("should preserve history for recovery after kill without deleteHistory", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { toast } from "@superset/ui/sonner";
import { trpc } from "renderer/lib/trpc";
import { useOpenConfigModal } from "renderer/stores/config-modal";
import { useTabsStore } from "renderer/stores/tabs/store";
import { useWindowsStore } from "renderer/stores/tabs/store";

/**
* Mutation hook for creating a new workspace
* Automatically invalidates all workspace queries on success
* Creates a terminal tab with setup commands if present
* Creates a terminal window with setup commands if present
* Shows config toast if no setup commands are configured
*/
export function useCreateWorkspace(
options?: Parameters<typeof trpc.workspaces.create.useMutation>[0],
) {
const utils = trpc.useUtils();
const addTab = useTabsStore((state) => state.addTab);
const addWindow = useWindowsStore((state) => state.addWindow);
const createOrAttach = trpc.terminal.createOrAttach.useMutation();
const openConfigModal = useOpenConfigModal();
const dismissConfigToast = trpc.config.dismissConfigToast.useMutation();
Expand All @@ -24,16 +24,16 @@ export function useCreateWorkspace(
// Auto-invalidate all workspace queries
await utils.workspaces.invalidate();

// Create terminal tab with setup commands if present
// Create terminal window with setup commands if present
if (
Array.isArray(data.initialCommands) &&
data.initialCommands.length > 0
) {
const tabId = addTab(data.workspace.id);
const { paneId } = addWindow(data.workspace.id);
// Pre-create terminal session with initial commands
// Terminal component will attach to this session when it mounts
createOrAttach.mutate({
tabId,
tabId: paneId,
workspaceId: data.workspace.id,
tabTitle: "Terminal",
initialCommands: data.initialCommands,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
useReorderWorkspaces,
useSetActiveWorkspace,
} from "renderer/react-query/workspaces";
import { useTabs } from "renderer/stores";
import { useCloseSettings } from "renderer/stores/app-state";
import { useWindowsStore } from "renderer/stores/tabs/store";
import { DeleteWorkspaceDialog } from "./DeleteWorkspaceDialog";
import { useWorkspaceRename } from "./useWorkspaceRename";
import { WorkspaceItemContextMenu } from "./WorkspaceItemContextMenu";
Expand Down Expand Up @@ -43,12 +43,37 @@ export function WorkspaceItem({
const reorderWorkspaces = useReorderWorkspaces();
const closeSettings = useCloseSettings();
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
const tabs = useTabs();
const windows = useWindowsStore((s) => s.windows);
const panes = useWindowsStore((s) => s.panes);
const rename = useWorkspaceRename(id, title);

const needsAttention = tabs
.filter((t) => t.workspaceId === id)
.some((t) => t.needsAttention);
// Check if any pane in windows belonging to this workspace needs attention
const workspaceWindows = windows.filter((w) => w.workspaceId === id);
const workspacePaneIds = new Set(
workspaceWindows.flatMap((w) => {
// Extract pane IDs from the layout (which is a MosaicNode<string>)
const collectPaneIds = (node: unknown): string[] => {
if (typeof node === "string") return [node];
if (
node &&
typeof node === "object" &&
"first" in node &&
"second" in node
) {
const branch = node as { first: unknown; second: unknown };
return [
...collectPaneIds(branch.first),
...collectPaneIds(branch.second),
];
}
return [];
};
return collectPaneIds(w.layout);
}),
);
const needsAttention = Object.values(panes)
.filter((p) => workspacePaneIds.has(p.id))
.some((p) => p.needsAttention);

const [{ isDragging }, drag] = useDrag(
() => ({
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading