From 60fdfc8c268c394b078dcd6e9e7486493509e3ce Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Fri, 24 Apr 2026 05:28:43 +0700 Subject: [PATCH] chore(lint): no-shadow in composer.test, host-runtime.test, new-workspace-screen.test --- packages/app/src/components/composer.test.tsx | 58 +++++++++--------- packages/app/src/runtime/host-runtime.test.ts | 60 +++++++++---------- .../src/screens/new-workspace-screen.test.tsx | 44 +++++++------- 3 files changed, 81 insertions(+), 81 deletions(-) diff --git a/packages/app/src/components/composer.test.tsx b/packages/app/src/components/composer.test.tsx index 94251943b..69ad86689 100644 --- a/packages/app/src/components/composer.test.tsx +++ b/packages/app/src/components/composer.test.tsx @@ -29,7 +29,7 @@ const { setQueuedMessagesMock, agentDirectoryStatusMock, } = vi.hoisted(() => { - const theme = { + const hoistedTheme = { spacing: { 1: 4, 2: 8, 3: 12, 4: 16, 6: 24, 8: 32 }, iconSize: { sm: 14, md: 18, lg: 22 }, borderWidth: { 1: 1 }, @@ -59,7 +59,7 @@ const { }, }; - const imageMetadata: AttachmentMetadata = { + const hoistedImageMetadata: AttachmentMetadata = { id: "img-1", mimeType: "image/png", storageType: "web-indexeddb", @@ -69,7 +69,7 @@ const { createdAt: 1, }; - const issueItem: GitHubSearchItem = { + const hoistedIssueItem: GitHubSearchItem = { kind: "issue", number: 101, title: "Fix composer attachments", @@ -81,7 +81,7 @@ const { headRefName: null, }; - const prItem: GitHubSearchItem = { + const hoistedPrItem: GitHubSearchItem = { kind: "pr", number: 202, title: "Refactor composer attachments", @@ -93,15 +93,15 @@ const { headRefName: "composer-attachments", }; - const mockClient = { + const hoistedMockClient = { isConnected: true, - searchGitHub: vi.fn(async () => ({ items: [issueItem, prItem] })), + searchGitHub: vi.fn(async () => ({ items: [hoistedIssueItem, hoistedPrItem] })), sendAgentMessage: vi.fn(async () => {}), cancelAgent: vi.fn(async () => {}), }; - const setQueuedMessagesMock = vi.fn(); - const mockSessionState: { + const hoistedSetQueuedMessagesMock = vi.fn(); + const hoistedMockSessionState: { sessions: Record< string, { @@ -145,42 +145,42 @@ const { agentStreamTail: new Map(), }, }, - setQueuedMessages: setQueuedMessagesMock, + setQueuedMessages: hoistedSetQueuedMessagesMock, }; - const setAgentStreamTailMock = vi.fn( + const hoistedSetAgentStreamTailMock = vi.fn( (serverId: string, updater: (prev: Map) => Map) => { - const session = mockSessionState.sessions[serverId]; + const session = hoistedMockSessionState.sessions[serverId]; session.agentStreamTail = updater(session.agentStreamTail); }, ); - const setAgentStreamHeadMock = vi.fn( + const hoistedSetAgentStreamHeadMock = vi.fn( (serverId: string, updater: (prev: Map) => Map) => { - const session = mockSessionState.sessions[serverId]; + const session = hoistedMockSessionState.sessions[serverId]; session.agentStreamHead = updater(session.agentStreamHead); }, ); - mockSessionState.setAgentStreamTail = setAgentStreamTailMock; - mockSessionState.setAgentStreamHead = setAgentStreamHeadMock; - const markScrollInvestigationRenderMock = vi.fn(); - const agentDirectoryStatusMock = vi.fn(() => "ready"); + hoistedMockSessionState.setAgentStreamTail = hoistedSetAgentStreamTailMock; + hoistedMockSessionState.setAgentStreamHead = hoistedSetAgentStreamHeadMock; + const hoistedMarkScrollInvestigationRenderMock = vi.fn(); + const hoistedAgentDirectoryStatusMock = vi.fn(() => "ready"); return { - theme, - imageMetadata, - issueItem, - prItem, - mockClient, + theme: hoistedTheme, + imageMetadata: hoistedImageMetadata, + issueItem: hoistedIssueItem, + prItem: hoistedPrItem, + mockClient: hoistedMockClient, pickImagesMock: vi.fn(), - persistAttachmentFromBlobMock: vi.fn(async () => imageMetadata), + persistAttachmentFromBlobMock: vi.fn(async () => hoistedImageMetadata), deleteAttachmentsMock: vi.fn(async () => {}), encodeImagesMock: vi.fn(async (images: AttachmentMetadata[]) => images), openExternalUrlMock: vi.fn(async () => {}), - markScrollInvestigationRenderMock, - mockSessionState, - setAgentStreamTailMock, - setAgentStreamHeadMock, - setQueuedMessagesMock, - agentDirectoryStatusMock, + markScrollInvestigationRenderMock: hoistedMarkScrollInvestigationRenderMock, + mockSessionState: hoistedMockSessionState, + setAgentStreamTailMock: hoistedSetAgentStreamTailMock, + setAgentStreamHeadMock: hoistedSetAgentStreamHeadMock, + setQueuedMessagesMock: hoistedSetQueuedMessagesMock, + agentDirectoryStatusMock: hoistedAgentDirectoryStatusMock, }; }); diff --git a/packages/app/src/runtime/host-runtime.test.ts b/packages/app/src/runtime/host-runtime.test.ts index 82dd8718a..73a2635be 100644 --- a/packages/app/src/runtime/host-runtime.test.ts +++ b/packages/app/src/runtime/host-runtime.test.ts @@ -400,7 +400,7 @@ describe("HostRuntimeController", () => { createClient: () => { throw new Error("should adopt the probe client"); }, - connectToDaemon: async ({ host, connection }) => { + connectToDaemon: async ({ host: hostProfile, connection }) => { const client = makeConnectedProbeClient(connection.id === "direct:lan:6767" ? 12 : 30); if (connection.id === "relay:relay.paseo.sh:443") { client.ping = async () => ({ rttMs: await slowPing.promise }); @@ -408,8 +408,8 @@ describe("HostRuntimeController", () => { clients.push(client); return { client: client as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }; }, getClientId: async () => "cid_test_runtime", @@ -450,7 +450,7 @@ describe("HostRuntimeController", () => { createClient: () => { throw new Error("should adopt probe clients"); }, - connectToDaemon: async ({ host, connection }) => { + connectToDaemon: async ({ host: hostProfile, connection }) => { probeAttempts.push(connection.id); const value = latencies[connection.id]; if (value instanceof Error) { @@ -461,8 +461,8 @@ describe("HostRuntimeController", () => { } return { client: makeConnectedProbeClient(value) as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }; }, getClientId: async () => "cid_test_runtime", @@ -873,10 +873,10 @@ describe("HostRuntimeController", () => { createdClients.push(client); return client as unknown as DaemonClient; }, - connectToDaemon: async ({ host }) => ({ + connectToDaemon: async ({ host: hostProfile }) => ({ client: makeConnectedProbeClient(10) as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }), getClientId: async () => "cid_test_runtime", }; @@ -950,7 +950,7 @@ describe("HostRuntimeController", () => { host, deps: { createClient: () => new FakeDaemonClient() as unknown as DaemonClient, - connectToDaemon: async ({ host }) => { + connectToDaemon: async ({ host: hostProfile }) => { probeCalls += 1; const client = new FakeDaemonClient(); client.connectCalls = 1; @@ -963,8 +963,8 @@ describe("HostRuntimeController", () => { }; return { client: client as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }; }, getClientId: async () => "cid_test_runtime", @@ -1005,12 +1005,12 @@ describe("HostRuntimeController", () => { createdClients.push(client); return client as unknown as DaemonClient; }, - connectToDaemon: async ({ host }) => { + connectToDaemon: async ({ host: hostProfile }) => { const client = makeConnectedProbeClient(10); return { client: client as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }; }, getClientId: async () => "cid_test_runtime", @@ -1173,10 +1173,10 @@ describe("HostRuntimeStore", () => { const store = new HostRuntimeStore({ deps: { createClient: () => fakeClient as unknown as DaemonClient, - connectToDaemon: async ({ host }) => ({ + connectToDaemon: async ({ host: hostProfile }) => ({ client: fakeClient as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }), getClientId: async () => "cid_test_runtime", }, @@ -1224,10 +1224,10 @@ describe("HostRuntimeStore", () => { const store = new HostRuntimeStore({ deps: { createClient: () => fakeClient as unknown as DaemonClient, - connectToDaemon: async ({ host }) => ({ + connectToDaemon: async ({ host: hostProfile }) => ({ client: fakeClient as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }), getClientId: async () => "cid_test_runtime", }, @@ -1295,10 +1295,10 @@ describe("HostRuntimeStore", () => { const store = new HostRuntimeStore({ deps: { createClient: () => fakeClient as unknown as DaemonClient, - connectToDaemon: async ({ host }) => ({ + connectToDaemon: async ({ host: hostProfile }) => ({ client: fakeClient as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }), getClientId: async () => "cid_test_runtime", }, @@ -1364,10 +1364,10 @@ describe("HostRuntimeStore", () => { const store = new HostRuntimeStore({ deps: { createClient: () => fakeClient as unknown as DaemonClient, - connectToDaemon: async ({ host }) => ({ + connectToDaemon: async ({ host: hostProfile }) => ({ client: fakeClient as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }), getClientId: async () => "cid_test_runtime", }, @@ -1435,10 +1435,10 @@ describe("HostRuntimeStore", () => { const store = new HostRuntimeStore({ deps: { createClient: () => fakeClient as unknown as DaemonClient, - connectToDaemon: async ({ host }) => ({ + connectToDaemon: async ({ host: hostProfile }) => ({ client: fakeClient as unknown as DaemonClient, - serverId: host.serverId, - hostname: host.label ?? null, + serverId: hostProfile.serverId, + hostname: hostProfile.label ?? null, }), getClientId: async () => "cid_test_runtime", }, diff --git a/packages/app/src/screens/new-workspace-screen.test.tsx b/packages/app/src/screens/new-workspace-screen.test.tsx index 091b66c2e..93d9e99f3 100644 --- a/packages/app/src/screens/new-workspace-screen.test.tsx +++ b/packages/app/src/screens/new-workspace-screen.test.tsx @@ -25,7 +25,7 @@ const { initialAttachments, initialDraftState, } = vi.hoisted(() => { - const theme = { + const hoistedTheme = { spacing: { 1: 4, 2: 8, 3: 12, 4: 16, 6: 24, 8: 32 }, iconSize: { sm: 14, md: 18, lg: 22 }, borderWidth: { 1: 1 }, @@ -48,7 +48,7 @@ const { }, }; - const prItem: GitHubSearchItem = { + const hoistedPrItem: GitHubSearchItem = { kind: "pr", number: 202, title: "Refactor picker", @@ -60,7 +60,7 @@ const { headRefName: "feature/picker", }; - const prItemB: GitHubSearchItem = { + const hoistedPrItemB: GitHubSearchItem = { kind: "pr", number: 303, title: "Polish composer chip", @@ -72,7 +72,7 @@ const { headRefName: "feature/composer-chip", }; - const issueItem: GitHubSearchItem = { + const hoistedIssueItem: GitHubSearchItem = { kind: "issue", number: 44, title: "Keep manual attachment", @@ -82,50 +82,50 @@ const { labels: [], }; - const initialAttachments: ComposerAttachment[] = []; - const initialDraftState = { text: "" }; + const hoistedInitialAttachments: ComposerAttachment[] = []; + const hoistedInitialDraftState = { text: "" }; - const createdWorkspace = { + const hoistedCreatedWorkspace = { id: "workspace-1", workspaceDirectory: "/repo/.paseo/worktrees/workspace-1", }; - const createdAgent = { + const hoistedCreatedAgent = { id: "agent-1", - cwd: createdWorkspace.workspaceDirectory, + cwd: hoistedCreatedWorkspace.workspaceDirectory, }; - const mockClient = { + const hoistedMockClient = { isConnected: true, getCheckoutStatus: vi.fn(async () => ({ currentBranch: "main" })), getBranchSuggestions: vi.fn(async () => ({ branches: ["main", "dev", "feat/x"] })), searchGitHub: vi.fn(async () => ({ - items: [prItem, prItemB], + items: [hoistedPrItem, hoistedPrItemB], githubFeaturesEnabled: true, error: null, })), createPaseoWorktree: vi.fn(async (_input: CreatePaseoWorktreeInput) => ({ - workspace: createdWorkspace, + workspace: hoistedCreatedWorkspace, error: null, })), - createAgent: vi.fn(async () => createdAgent), + createAgent: vi.fn(async () => hoistedCreatedAgent), }; return { - theme, - mockClient, + theme: hoistedTheme, + mockClient: hoistedMockClient, mergeWorkspacesMock: vi.fn(), navigateMock: vi.fn(), saveDraftInputMock: vi.fn(), clearDraftInputMock: vi.fn(), queueDraftSubmissionMock: vi.fn(), - createdAgent, - createdWorkspace, - prItem, - prItemB, - issueItem, - initialAttachments, - initialDraftState, + createdAgent: hoistedCreatedAgent, + createdWorkspace: hoistedCreatedWorkspace, + prItem: hoistedPrItem, + prItemB: hoistedPrItemB, + issueItem: hoistedIssueItem, + initialAttachments: hoistedInitialAttachments, + initialDraftState: hoistedInitialDraftState, }; });