From 9f1e7293f461e8eb38bd74eb71d25fabcf46c675 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 22 Jul 2025 22:05:47 -0700 Subject: [PATCH] log errors from headless mode if fatal --- src/commands/chat.ts | 9 +++++++-- src/ui/TUIChat.advanced.test.tsx | 15 --------------- src/ui/TUIChat.test.tsx | 1 - src/ui/TUIChat.tsx | 10 ++-------- src/ui/__tests__/TUIChat.messages.dual.test.tsx | 6 ------ src/ui/__tests__/TUIChat.messages.local.test.tsx | 6 ------ 6 files changed, 9 insertions(+), 38 deletions(-) delete mode 100644 src/ui/TUIChat.advanced.test.tsx delete mode 100644 src/ui/__tests__/TUIChat.messages.dual.test.tsx delete mode 100644 src/ui/__tests__/TUIChat.messages.local.test.tsx diff --git a/src/commands/chat.ts b/src/commands/chat.ts index f72d59ac4..c3cd33112 100644 --- a/src/commands/chat.ts +++ b/src/commands/chat.ts @@ -3,6 +3,7 @@ import { ChatCompletionMessageParam } from "openai/resources.mjs"; import * as readlineSync from "readline-sync"; import { CONTINUE_ASCII_ART } from "../asciiArt.js"; import { configureLogger } from "../logger.js"; +import * as logging from "../logging.js"; import { loadSession, saveSession } from "../session.js"; import { initializeServices } from "../services/index.js"; import { serviceContainer } from "../services/ServiceContainer.js"; @@ -138,6 +139,9 @@ async function runHeadlessMode( export async function chat(prompt?: string, options: ChatOptions = {}) { // Configure logger based on headless mode configureLogger(options.headless ?? false); + + // Configure headless-aware logging system + logging.configureLogger({ headless: options.headless ?? false }); try { // Record session start @@ -157,10 +161,11 @@ export async function chat(prompt?: string, options: ChatOptions = {}) { return; } - // Run headless mode with old initialization pattern + // Run headless mode await runHeadlessMode(prompt, options); } catch (error: any) { - logger.error(chalk.red(`Fatal error: ${formatError(error)}`)); + // Use headless-aware error logging to ensure fatal errors are shown in headless mode + logging.error(chalk.red(`Fatal error: ${formatError(error)}`)); process.exit(1); } finally { // Stop active time tracking diff --git a/src/ui/TUIChat.advanced.test.tsx b/src/ui/TUIChat.advanced.test.tsx deleted file mode 100644 index 02f1a6bab..000000000 --- a/src/ui/TUIChat.advanced.test.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; -import { render } from "ink-testing-library"; -import type { ChatCompletionMessageParam } from "openai/resources/index.js"; -import type { BaseLlmApi } from "@continuedev/openai-adapters"; -import type { AssistantUnrolled } from "@continuedev/config-yaml"; -import TUIChat from "./TUIChat.js"; -import type { MCPService } from "../mcp.js"; -import { jest } from "@jest/globals"; - -// Skip these tests for now - they require complex mocking setup -describe.skip("TUIChat - Advanced Component Tests", () => { - it("placeholder test", () => { - expect(true).toBe(true); - }); -}); \ No newline at end of file diff --git a/src/ui/TUIChat.test.tsx b/src/ui/TUIChat.test.tsx index 8fd40e712..a30b2f3dc 100644 --- a/src/ui/TUIChat.test.tsx +++ b/src/ui/TUIChat.test.tsx @@ -4,7 +4,6 @@ import "./__tests__/TUIChat.messages.test.js"; import "./__tests__/TUIChat.input.test.js"; import "./__tests__/TUIChat.fileSearch.test.js"; import "./__tests__/TUIChat.slashCommands.test.js"; -import "./TUIChat.advanced.test.js"; // Add a dummy test to satisfy Jest describe("TUIChat Test Suite", () => { diff --git a/src/ui/TUIChat.tsx b/src/ui/TUIChat.tsx index 6ac63eaff..61d64bbfd 100644 --- a/src/ui/TUIChat.tsx +++ b/src/ui/TUIChat.tsx @@ -135,10 +135,7 @@ const TUIChat: React.FC = ({ showOrganizationSelector, } = useOrganizationSelector({ configPath, - onAssistantChange: (newAssistant, newModel, newLlmApi, newMcpService) => { - // These will be updated automatically by the service system - // We just need to trigger a reload which will cause services to update - }, + onAssistantChange: (newAssistant, newModel, newLlmApi, newMcpService) => {}, onMessage: (message) => { setMessages((prev) => [...prev, message]); }, @@ -152,10 +149,7 @@ const TUIChat: React.FC = ({ showConfigSelectorUI, } = useConfigSelector({ configPath, - onAssistantChange: (newAssistant, newModel, newLlmApi, newMcpService) => { - // These will be updated automatically by the service system - // We just need to trigger a reload which will cause services to update - }, + onAssistantChange: (newAssistant, newModel, newLlmApi, newMcpService) => {}, onMessage: (message) => { setMessages((prev) => [...prev, message]); }, diff --git a/src/ui/__tests__/TUIChat.messages.dual.test.tsx b/src/ui/__tests__/TUIChat.messages.dual.test.tsx deleted file mode 100644 index 80dd07479..000000000 --- a/src/ui/__tests__/TUIChat.messages.dual.test.tsx +++ /dev/null @@ -1,6 +0,0 @@ -// This file has been removed - functionality merged into TUIChat.messages.test.tsx -describe('placeholder', () => { - it('exists', () => { - expect(true).toBe(true); - }); -}); \ No newline at end of file diff --git a/src/ui/__tests__/TUIChat.messages.local.test.tsx b/src/ui/__tests__/TUIChat.messages.local.test.tsx deleted file mode 100644 index 75bf205de..000000000 --- a/src/ui/__tests__/TUIChat.messages.local.test.tsx +++ /dev/null @@ -1,6 +0,0 @@ -// This file has been removed - tests migrated to TUIChat.messages.test.tsx -describe('placeholder', () => { - it('exists', () => { - expect(true).toBe(true); - }); -}); \ No newline at end of file