diff --git a/src/mcp/tools/session-management/session_set_defaults.ts b/src/mcp/tools/session-management/session_set_defaults.ts index 220a888..6526a14 100644 --- a/src/mcp/tools/session-management/session_set_defaults.ts +++ b/src/mcp/tools/session-management/session_set_defaults.ts @@ -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 diff --git a/src/utils/__tests__/build-utils-suppress-warnings.test.ts b/src/utils/__tests__/build-utils-suppress-warnings.test.ts new file mode 100644 index 0000000..61dd69a --- /dev/null +++ b/src/utils/__tests__/build-utils-suppress-warnings.test.ts @@ -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:'); + }); +}); diff --git a/src/utils/build-utils.ts b/src/utils/build-utils.ts index 66c769e..565c412 100644 --- a/src/utils/build-utils.ts +++ b/src/utils/build-utils.ts @@ -30,6 +30,7 @@ import { doesMakefileExist, doesMakeLogFileExist, } from './xcodemake.ts'; +import { sessionStore } from './session-store.ts'; import path from 'path'; /** @@ -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}`, diff --git a/src/utils/session-store.ts b/src/utils/session-store.ts index 9df96c7..e61c691 100644 --- a/src/utils/session-store.ts +++ b/src/utils/session-store.ts @@ -10,6 +10,7 @@ export type SessionDefaults = { deviceId?: string; useLatestOS?: boolean; arch?: 'arm64' | 'x86_64'; + suppressWarnings?: boolean; }; class SessionStore {