Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/mcp/tools/session-management/session_set_defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const baseSchema = z.object({
deviceId: z.string().optional(),
useLatestOS: z.boolean().optional(),
arch: z.enum(['arm64', 'x86_64']).optional(),
suppressWarnings: z
.boolean()
.optional()
.describe('When true, warning messages are filtered from build output to conserve context'),
});

const schemaObj = baseSchema
Expand Down
78 changes: 78 additions & 0 deletions src/utils/__tests__/build-utils-suppress-warnings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { executeXcodeBuildCommand } from '../build-utils.ts';
import { XcodePlatform } from '../../types/common.ts';
import { sessionStore } from '../session-store.ts';
import { createMockExecutor } from '../../test-utils/mock-executors.ts';

describe('executeXcodeBuildCommand - suppressWarnings', () => {
beforeEach(() => {
sessionStore.clear();
});

it('should include warnings when suppressWarnings is false', async () => {
sessionStore.setDefaults({ suppressWarnings: false });

const mockExecutor = createMockExecutor({
success: true,
output: 'warning: Some warning\nerror: Some error',
error: '',
exitCode: 0,
});

const result = await executeXcodeBuildCommand(
{
projectPath: '/test/project.xcodeproj',
scheme: 'TestScheme',
configuration: 'Debug',
},
{
platform: XcodePlatform.macOS,
logPrefix: 'Test',
},
false,
'build',
mockExecutor,
);

expect(result.content).toBeDefined();
const textContent = result.content
?.filter((c) => c.type === 'text')
.map((c) => (c as { text: string }).text)
.join('\n');
expect(textContent).toContain('⚠️ Warning:');
});

it('should suppress warnings when suppressWarnings is true', async () => {
sessionStore.setDefaults({ suppressWarnings: true });

const mockExecutor = createMockExecutor({
success: true,
output: 'warning: Some warning\nerror: Some error',
error: '',
exitCode: 0,
});

const result = await executeXcodeBuildCommand(
{
projectPath: '/test/project.xcodeproj',
scheme: 'TestScheme',
configuration: 'Debug',
},
{
platform: XcodePlatform.macOS,
logPrefix: 'Test',
},
false,
'build',
mockExecutor,
);

expect(result.content).toBeDefined();
const textContent = result.content
?.filter((c) => c.type === 'text')
.map((c) => (c as { text: string }).text)
.join('\n');
expect(textContent).not.toContain('⚠️ Warning:');
expect(textContent).toContain('❌ Error:');
});
});
5 changes: 5 additions & 0 deletions src/utils/build-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
doesMakefileExist,
doesMakeLogFileExist,
} from './xcodemake.ts';
import { sessionStore } from './session-store.ts';
import path from 'path';

/**
Expand Down Expand Up @@ -231,7 +232,11 @@ export async function executeXcodeBuildCommand(

// Grep warnings and errors from stdout (build output)
const warningOrErrorLines = grepWarningsAndErrors(result.output);
const suppressWarnings = sessionStore.get('suppressWarnings');
warningOrErrorLines.forEach(({ type, content }) => {
if (type === 'warning' && suppressWarnings) {
return;
}
buildMessages.push({
type: 'text',
text: type === 'warning' ? `⚠️ Warning: ${content}` : `❌ Error: ${content}`,
Expand Down
1 change: 1 addition & 0 deletions src/utils/session-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type SessionDefaults = {
deviceId?: string;
useLatestOS?: boolean;
arch?: 'arm64' | 'x86_64';
suppressWarnings?: boolean;
};

class SessionStore {
Expand Down
Loading