fix(ci): stabilize workspace test suite
This commit is contained in:
parent
5683973c04
commit
19e7ea995e
6 changed files with 73 additions and 13 deletions
|
|
@ -240,7 +240,7 @@ export class ProjectScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ms = Date.now() - startedAt;
|
const ms = Date.now() - startedAt;
|
||||||
if (ms >= 2000) {
|
if (ms >= 5000) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`[scan] completed slow ms=${ms} projectDirs=${projectDirs.length} projects=${validProjects.length}`
|
`[scan] completed slow ms=${ms} projectDirs=${projectDirs.length} projects=${validProjects.length}`
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import { isCommandOutputContent, sanitizeDisplayContent } from '@shared/utils/contentSanitizer';
|
import { isCommandOutputContent, sanitizeDisplayContent } from '@shared/utils/contentSanitizer';
|
||||||
import { createLogger } from '@shared/utils/logger';
|
import { createLogger } from '@shared/utils/logger';
|
||||||
|
import * as fs from 'fs/promises';
|
||||||
import * as readline from 'readline';
|
import * as readline from 'readline';
|
||||||
|
|
||||||
import { LocalFileSystemProvider } from '../services/infrastructure/LocalFileSystemProvider';
|
import { LocalFileSystemProvider } from '../services/infrastructure/LocalFileSystemProvider';
|
||||||
|
|
@ -29,7 +30,7 @@ function normalizeDriveLetter(p: string): string {
|
||||||
|
|
||||||
const defaultProvider = new LocalFileSystemProvider();
|
const defaultProvider = new LocalFileSystemProvider();
|
||||||
|
|
||||||
const JSONL_HEAD_TIMEOUT_MS = 2000;
|
const JSONL_HEAD_TIMEOUT_MS = 5000;
|
||||||
const JSONL_HEAD_MAX_BYTES = 256 * 1024;
|
const JSONL_HEAD_MAX_BYTES = 256 * 1024;
|
||||||
const JSONL_HEAD_MAX_LINES = 400;
|
const JSONL_HEAD_MAX_LINES = 400;
|
||||||
|
|
||||||
|
|
@ -53,6 +54,41 @@ function createStreamCleanup(rl: readline.Interface, fileStream: Readable): () =
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractCwdFromBufferedText(text: string): string | null {
|
||||||
|
const lines = text.split(/\r?\n/, JSONL_HEAD_MAX_LINES);
|
||||||
|
for (const line of lines) {
|
||||||
|
if (!line.trim()) continue;
|
||||||
|
|
||||||
|
let entry: ChatHistoryEntry;
|
||||||
|
try {
|
||||||
|
entry = JSON.parse(line) as ChatHistoryEntry;
|
||||||
|
} catch {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('cwd' in entry && entry.cwd) {
|
||||||
|
return normalizeDriveLetter(translateWslMountPath(entry.cwd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function extractCwdFromLocalFile(filePath: string): Promise<string | null> {
|
||||||
|
const handle = await fs.open(filePath, 'r');
|
||||||
|
try {
|
||||||
|
const buffer = Buffer.alloc(JSONL_HEAD_MAX_BYTES);
|
||||||
|
const { bytesRead } = await handle.read(buffer, 0, JSONL_HEAD_MAX_BYTES, 0);
|
||||||
|
if (bytesRead <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return extractCwdFromBufferedText(buffer.toString('utf8', 0, bytesRead));
|
||||||
|
} finally {
|
||||||
|
await handle.close().catch(() => undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract CWD (current working directory) from the first entry.
|
* Extract CWD (current working directory) from the first entry.
|
||||||
* Used to get the actual project path from encoded directory names.
|
* Used to get the actual project path from encoded directory names.
|
||||||
|
|
@ -74,6 +110,15 @@ export async function extractCwd(
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fsProvider.type === 'local') {
|
||||||
|
try {
|
||||||
|
return await extractCwdFromLocalFile(filePath);
|
||||||
|
} catch (error) {
|
||||||
|
logger.debug(`Error extracting cwd from local file ${filePath}:`, error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const fileStream = fsProvider.createReadStream(filePath, { encoding: 'utf8' });
|
const fileStream = fsProvider.createReadStream(filePath, { encoding: 'utf8' });
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: fileStream,
|
input: fileStream,
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ describe('CliInstallerService health check', () => {
|
||||||
|
|
||||||
it('does not treat a found binary as installed until --version succeeds', async () => {
|
it('does not treat a found binary as installed until --version succeeds', async () => {
|
||||||
resolveBinaryMock.mockResolvedValue('/usr/local/bin/claude');
|
resolveBinaryMock.mockResolvedValue('/usr/local/bin/claude');
|
||||||
execCliMock.mockRejectedValueOnce(new Error('spawn EACCES'));
|
execCliMock.mockRejectedValue(new Error('spawn EACCES'));
|
||||||
|
|
||||||
const status = await service.getStatus();
|
const status = await service.getStatus();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,12 @@ describe('ConfigManager notification config shape', () => {
|
||||||
vi.resetModules();
|
vi.resetModules();
|
||||||
|
|
||||||
overrideRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'config-notifications-'));
|
overrideRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'config-notifications-'));
|
||||||
|
const configPath = path.join(overrideRoot, 'claude-devtools-config.json');
|
||||||
const pathDecoder = await import('../../../../src/main/utils/pathDecoder');
|
const pathDecoder = await import('../../../../src/main/utils/pathDecoder');
|
||||||
pathDecoder.setClaudeBasePathOverride(overrideRoot);
|
pathDecoder.setClaudeBasePathOverride(overrideRoot);
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(overrideRoot, 'claude-devtools-config.json'),
|
configPath,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
notifications: {
|
notifications: {
|
||||||
notifyOnInboxMessages: true,
|
notifyOnInboxMessages: true,
|
||||||
|
|
@ -42,5 +43,14 @@ describe('ConfigManager notification config shape', () => {
|
||||||
expect(config.notifications.autoResumeOnRateLimit).toBe(true);
|
expect(config.notifications.autoResumeOnRateLimit).toBe(true);
|
||||||
expect(config.notifications.notifyOnTeamLaunched).toBe(false);
|
expect(config.notifications.notifyOnTeamLaunched).toBe(false);
|
||||||
expect('notifyOnInboxMessages' in config.notifications).toBe(false);
|
expect('notifyOnInboxMessages' in config.notifications).toBe(false);
|
||||||
|
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
const persisted = JSON.parse(fs.readFileSync(configPath, 'utf8')) as {
|
||||||
|
notifications: Record<string, unknown>;
|
||||||
|
};
|
||||||
|
expect(persisted.notifications.autoResumeOnRateLimit).toBe(true);
|
||||||
|
expect(persisted.notifications.notifyOnTeamLaunched).toBe(false);
|
||||||
|
expect('notifyOnInboxMessages' in persisted.notifications).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -779,16 +779,20 @@ describe('TeamProvisioningService prepare/auth behavior', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates the generated agent-teams MCP server directly over stdio', async () => {
|
it(
|
||||||
const svc = new TeamProvisioningService();
|
'validates the generated agent-teams MCP server directly over stdio',
|
||||||
const configPath = writeMcpConfig(tempRoot, {
|
async () => {
|
||||||
'agent-teams': getRealAgentTeamsMcpLaunchSpec(),
|
const svc = new TeamProvisioningService();
|
||||||
});
|
const configPath = writeMcpConfig(tempRoot, {
|
||||||
|
'agent-teams': getRealAgentTeamsMcpLaunchSpec(),
|
||||||
|
});
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
(svc as any).validateAgentTeamsMcpRuntime('/fake/claude', tempRoot, process.env, configPath)
|
(svc as any).validateAgentTeamsMcpRuntime('/fake/claude', tempRoot, process.env, configPath)
|
||||||
).resolves.toBeUndefined();
|
).resolves.toBeUndefined();
|
||||||
});
|
},
|
||||||
|
45_000
|
||||||
|
);
|
||||||
|
|
||||||
it('fails validation when the generated MCP config has no agent-teams entry', async () => {
|
it('fails validation when the generated MCP config has no agent-teams entry', async () => {
|
||||||
const svc = new TeamProvisioningService();
|
const svc = new TeamProvisioningService();
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ const storeState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
vi.mock('@renderer/api', () => ({
|
vi.mock('@renderer/api', () => ({
|
||||||
|
isElectronMode: () => true,
|
||||||
api: {
|
api: {
|
||||||
getProjects: vi.fn(async () => [
|
getProjects: vi.fn(async () => [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue