mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Hide setup action when no setup ran
This commit is contained in:
@@ -66,7 +66,7 @@ import {
|
|||||||
} from "@/utils/workspace-tab-identity";
|
} from "@/utils/workspace-tab-identity";
|
||||||
import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
||||||
import { useProvidersSnapshot } from "@/hooks/use-providers-snapshot";
|
import { useProvidersSnapshot } from "@/hooks/use-providers-snapshot";
|
||||||
import { useWorkspaceSetupStore } from "@/stores/workspace-setup-store";
|
import { shouldShowWorkspaceSetup, useWorkspaceSetupStore } from "@/stores/workspace-setup-store";
|
||||||
import { useWorkspace } from "@/stores/session-store-hooks";
|
import { useWorkspace } from "@/stores/session-store-hooks";
|
||||||
import { useWorkspaceTerminalSessionRetention } from "@/terminal/hooks/use-workspace-terminal-session-retention";
|
import { useWorkspaceTerminalSessionRetention } from "@/terminal/hooks/use-workspace-terminal-session-retention";
|
||||||
import {
|
import {
|
||||||
@@ -976,6 +976,7 @@ function WorkspaceScreenContent({
|
|||||||
const workspaceSetupSnapshot = useWorkspaceSetupStore((state) =>
|
const workspaceSetupSnapshot = useWorkspaceSetupStore((state) =>
|
||||||
persistenceKey ? (state.snapshots[persistenceKey] ?? null) : null,
|
persistenceKey ? (state.snapshots[persistenceKey] ?? null) : null,
|
||||||
);
|
);
|
||||||
|
const showWorkspaceSetup = shouldShowWorkspaceSetup(workspaceSetupSnapshot);
|
||||||
const uiTabs = useMemo(
|
const uiTabs = useMemo(
|
||||||
() => (workspaceLayout ? collectAllTabs(workspaceLayout.root) : EMPTY_UI_TABS),
|
() => (workspaceLayout ? collectAllTabs(workspaceLayout.root) : EMPTY_UI_TABS),
|
||||||
[workspaceLayout],
|
[workspaceLayout],
|
||||||
@@ -1229,7 +1230,7 @@ function WorkspaceScreenContent({
|
|||||||
if (!persistenceKey) {
|
if (!persistenceKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!workspaceSetupSnapshot) {
|
if (!workspaceSetupSnapshot || !showWorkspaceSetup) {
|
||||||
if (autoOpenedSetupTabWorkspaceRef.current === persistenceKey) {
|
if (autoOpenedSetupTabWorkspaceRef.current === persistenceKey) {
|
||||||
autoOpenedSetupTabWorkspaceRef.current = null;
|
autoOpenedSetupTabWorkspaceRef.current = null;
|
||||||
}
|
}
|
||||||
@@ -1271,6 +1272,7 @@ function WorkspaceScreenContent({
|
|||||||
normalizedWorkspaceId,
|
normalizedWorkspaceId,
|
||||||
openWorkspaceTabInBackground,
|
openWorkspaceTabInBackground,
|
||||||
persistenceKey,
|
persistenceKey,
|
||||||
|
showWorkspaceSetup,
|
||||||
workspaceSetupSnapshot,
|
workspaceSetupSnapshot,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -2258,6 +2260,8 @@ function WorkspaceScreenContent({
|
|||||||
Copy branch name
|
Copy branch name
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
) : null}
|
) : null}
|
||||||
|
{showWorkspaceSetup ? (
|
||||||
|
<>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
testID="workspace-header-show-setup"
|
testID="workspace-header-show-setup"
|
||||||
@@ -2266,6 +2270,8 @@ function WorkspaceScreenContent({
|
|||||||
>
|
>
|
||||||
Show setup
|
Show setup
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { beforeEach, describe, expect, it } from "vitest";
|
import { beforeEach, describe, expect, it } from "vitest";
|
||||||
import { useWorkspaceSetupStore } from "./workspace-setup-store";
|
import { shouldShowWorkspaceSetup, useWorkspaceSetupStore } from "./workspace-setup-store";
|
||||||
|
|
||||||
describe("workspace-setup-store", () => {
|
describe("workspace-setup-store", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -38,4 +38,65 @@ describe("workspace-setup-store", () => {
|
|||||||
|
|
||||||
expect(useWorkspaceSetupStore.getState().pendingWorkspaceSetup).toBeNull();
|
expect(useWorkspaceSetupStore.getState().pendingWorkspaceSetup).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("hides empty successful setup snapshots", () => {
|
||||||
|
expect(
|
||||||
|
shouldShowWorkspaceSetup({
|
||||||
|
workspaceId: "workspace-1",
|
||||||
|
status: "completed",
|
||||||
|
detail: {
|
||||||
|
type: "worktree_setup",
|
||||||
|
worktreePath: "/Users/test/project",
|
||||||
|
branchName: "main",
|
||||||
|
log: "",
|
||||||
|
commands: [],
|
||||||
|
},
|
||||||
|
error: null,
|
||||||
|
updatedAt: Date.now(),
|
||||||
|
}),
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows setup snapshots with commands or errors", () => {
|
||||||
|
expect(
|
||||||
|
shouldShowWorkspaceSetup({
|
||||||
|
workspaceId: "workspace-1",
|
||||||
|
status: "completed",
|
||||||
|
detail: {
|
||||||
|
type: "worktree_setup",
|
||||||
|
worktreePath: "/Users/test/project",
|
||||||
|
branchName: "main",
|
||||||
|
log: "done\n",
|
||||||
|
commands: [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
command: "npm install",
|
||||||
|
cwd: "/Users/test/project",
|
||||||
|
log: "done\n",
|
||||||
|
status: "completed",
|
||||||
|
exitCode: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
error: null,
|
||||||
|
updatedAt: Date.now(),
|
||||||
|
}),
|
||||||
|
).toBe(true);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
shouldShowWorkspaceSetup({
|
||||||
|
workspaceId: "workspace-1",
|
||||||
|
status: "failed",
|
||||||
|
detail: {
|
||||||
|
type: "worktree_setup",
|
||||||
|
worktreePath: "/Users/test/project",
|
||||||
|
branchName: "main",
|
||||||
|
log: "",
|
||||||
|
commands: [],
|
||||||
|
},
|
||||||
|
error: "Failed to parse paseo.json",
|
||||||
|
updatedAt: Date.now(),
|
||||||
|
}),
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ export interface WorkspaceSetupSnapshot extends WorkspaceSetupProgressPayload {
|
|||||||
updatedAt: number;
|
updatedAt: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function shouldShowWorkspaceSetup(snapshot: WorkspaceSetupSnapshot | null): boolean {
|
||||||
|
if (!snapshot) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return snapshot.error !== null || snapshot.detail.commands.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
interface WorkspaceSetupStoreState {
|
interface WorkspaceSetupStoreState {
|
||||||
pendingWorkspaceSetup: PendingWorkspaceSetup | null;
|
pendingWorkspaceSetup: PendingWorkspaceSetup | null;
|
||||||
snapshots: Record<string, WorkspaceSetupSnapshot>;
|
snapshots: Record<string, WorkspaceSetupSnapshot>;
|
||||||
|
|||||||
Reference in New Issue
Block a user