Skip to content
Draft
39 changes: 14 additions & 25 deletions src/__tests__/main/ipc/handlers/tabNaming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
}));

vi.mock('../../../../main/utils/ssh-command-builder', () => ({
buildSshCommand: vi.fn(),
buildSshCommandWithStdin: vi.fn(),
}));

// Capture registered handlers
Expand Down Expand Up @@ -508,7 +508,7 @@

const result = await resultPromise;
// Lines starting with quotes are filtered out as example inputs
expect(result).toBeNull();

Check failure on line 511 in src/__tests__/main/ipc/handlers/tabNaming.test.ts

View workflow job for this annotation

GitHub Actions / test

src/__tests__/main/ipc/handlers/tabNaming.test.ts > Tab Naming IPC Handlers > tabNaming:generateTabName > filters out lines starting with quotes (example inputs)

AssertionError: expected 'Quoted Tab Name' to be null - Expected: null + Received: "Quoted Tab Name" ❯ src/__tests__/main/ipc/handlers/tabNaming.test.ts:511:19
});

it('removes trailing quotes from tab names', async () => {
Expand Down Expand Up @@ -543,7 +543,8 @@
it('uses stdin for prompt when SSH remote is configured', async () => {
// Import and mock the SSH utilities
const { getSshRemoteConfig } = await import('../../../../main/utils/ssh-remote-resolver');
const { buildSshCommand } = await import('../../../../main/utils/ssh-command-builder');
const { buildSshCommandWithStdin } =
await import('../../../../main/utils/ssh-command-builder');

// Mock SSH config resolution to return a valid config
(getSshRemoteConfig as Mock).mockReturnValue({
Expand All @@ -555,25 +556,13 @@
source: 'session',
});

// Mock buildSshCommand to return SSH-wrapped command
(buildSshCommand as Mock).mockResolvedValue({
// Mock buildSshCommandWithStdin to return SSH-wrapped command
(buildSshCommandWithStdin as Mock).mockResolvedValue({
command: '/usr/bin/ssh',
args: [
'-o',
'BatchMode=yes',
'test.example.com',
'claude --print --input-format stream-json',
],
});

// Update mock agent to support stream-json input
const mockAgentWithStreamJson: AgentConfig = {
...mockClaudeAgent,
capabilities: {
supportsStreamJsonInput: true,
},
};
mockAgentDetector.getAgent.mockResolvedValue(mockAgentWithStreamJson);
args: ['-o', 'BatchMode=yes', 'test.example.com', '/bin/bash'],
stdinScript:
'export PATH=...\nexec claude run --format json\nHelp me with SSH remote feature',
});

let onDataCallback: ((sessionId: string, data: string) => void) | undefined;
let onExitCallback: ((sessionId: string) => void) | undefined;
Expand All @@ -599,18 +588,18 @@
expect(mockProcessManager.spawn).toHaveBeenCalled();
});

// Verify spawn was called with sendPromptViaStdin flag
// Verify spawn was called with sshStdinScript
expect(mockProcessManager.spawn).toHaveBeenCalledWith(
expect.objectContaining({
sendPromptViaStdin: true,
sshStdinScript: expect.any(String),
})
);

// Verify buildSshCommand was called with useStdin option
expect(buildSshCommand).toHaveBeenCalledWith(
// Verify buildSshCommandWithStdin was called with stdinInput (the prompt)
expect(buildSshCommandWithStdin).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
useStdin: true,
stdinInput: expect.any(String),
})
);

Expand Down
2 changes: 2 additions & 0 deletions src/main/agents/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export interface AgentConfig {
noPromptSeparator?: boolean; // If true, don't add '--' before the prompt in batch mode (OpenCode doesn't support it)
defaultEnvVars?: Record<string, string>; // Default environment variables for this agent (merged with user customEnvVars)
readOnlyEnvOverrides?: Record<string, string>; // Env var overrides applied in read-only mode (replaces keys from defaultEnvVars)
// Optional default model id discovered from the agent's local config or binary
defaultModel?: string;
}

/**
Expand Down
Loading
Loading