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;
|
||||
if (ms >= 2000) {
|
||||
if (ms >= 5000) {
|
||||
logger.warn(
|
||||
`[scan] completed slow ms=${ms} projectDirs=${projectDirs.length} projects=${validProjects.length}`
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import { isCommandOutputContent, sanitizeDisplayContent } from '@shared/utils/contentSanitizer';
|
||||
import { createLogger } from '@shared/utils/logger';
|
||||
import * as fs from 'fs/promises';
|
||||
import * as readline from 'readline';
|
||||
|
||||
import { LocalFileSystemProvider } from '../services/infrastructure/LocalFileSystemProvider';
|
||||
|
|
@ -29,7 +30,7 @@ function normalizeDriveLetter(p: string): string {
|
|||
|
||||
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_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.
|
||||
* Used to get the actual project path from encoded directory names.
|
||||
|
|
@ -74,6 +110,15 @@ export async function extractCwd(
|
|||
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 rl = readline.createInterface({
|
||||
input: fileStream,
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ describe('CliInstallerService health check', () => {
|
|||
|
||||
it('does not treat a found binary as installed until --version succeeds', async () => {
|
||||
resolveBinaryMock.mockResolvedValue('/usr/local/bin/claude');
|
||||
execCliMock.mockRejectedValueOnce(new Error('spawn EACCES'));
|
||||
execCliMock.mockRejectedValue(new Error('spawn EACCES'));
|
||||
|
||||
const status = await service.getStatus();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ describe('ConfigManager notification config shape', () => {
|
|||
vi.resetModules();
|
||||
|
||||
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');
|
||||
pathDecoder.setClaudeBasePathOverride(overrideRoot);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(overrideRoot, 'claude-devtools-config.json'),
|
||||
configPath,
|
||||
JSON.stringify({
|
||||
notifications: {
|
||||
notifyOnInboxMessages: true,
|
||||
|
|
@ -42,5 +43,14 @@ describe('ConfigManager notification config shape', () => {
|
|||
expect(config.notifications.autoResumeOnRateLimit).toBe(true);
|
||||
expect(config.notifications.notifyOnTeamLaunched).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 () => {
|
||||
const svc = new TeamProvisioningService();
|
||||
const configPath = writeMcpConfig(tempRoot, {
|
||||
'agent-teams': getRealAgentTeamsMcpLaunchSpec(),
|
||||
});
|
||||
it(
|
||||
'validates the generated agent-teams MCP server directly over stdio',
|
||||
async () => {
|
||||
const svc = new TeamProvisioningService();
|
||||
const configPath = writeMcpConfig(tempRoot, {
|
||||
'agent-teams': getRealAgentTeamsMcpLaunchSpec(),
|
||||
});
|
||||
|
||||
await expect(
|
||||
(svc as any).validateAgentTeamsMcpRuntime('/fake/claude', tempRoot, process.env, configPath)
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
await expect(
|
||||
(svc as any).validateAgentTeamsMcpRuntime('/fake/claude', tempRoot, process.env, configPath)
|
||||
).resolves.toBeUndefined();
|
||||
},
|
||||
45_000
|
||||
);
|
||||
|
||||
it('fails validation when the generated MCP config has no agent-teams entry', async () => {
|
||||
const svc = new TeamProvisioningService();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ const storeState = {
|
|||
};
|
||||
|
||||
vi.mock('@renderer/api', () => ({
|
||||
isElectronMode: () => true,
|
||||
api: {
|
||||
getProjects: vi.fn(async () => [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue