diff --git a/node/chat/chat.spec.ts b/node/chat/chat.spec.ts index f635c73..af3013c 100644 --- a/node/chat/chat.spec.ts +++ b/node/chat/chat.spec.ts @@ -35,7 +35,7 @@ describe("tea/chat.spec.ts", () => { expect( await buffer.getLines({ start: 0, end: -1 }), "initial render of chat works", - ).toEqual(["Stopped (end_turn) [input: 0, output: 0]"] as Line[]); + ).toEqual(Chat.LOGO.split("\n") as Line[]); app.dispatch({ type: "add-message", @@ -144,7 +144,7 @@ describe("tea/chat.spec.ts", () => { expect( await buffer.getLines({ start: 0, end: -1 }), "initial render of chat works", - ).toEqual(["Stopped (end_turn) [input: 0, output: 0]"] as Line[]); + ).toEqual(Chat.LOGO.split("\n") as Line[]); app.dispatch({ type: "add-message", @@ -172,10 +172,6 @@ describe("tea/chat.spec.ts", () => { "Stopped (end_turn) [input: 0, output: 0]", ] as Line[]); - // expect( - // await extractMountTree(mountedApp.getMountedNode()), - // ).toMatchSnapshot(); - app.dispatch({ type: "clear", }); @@ -184,11 +180,7 @@ describe("tea/chat.spec.ts", () => { expect( await buffer.getLines({ start: 0, end: -1 }), "finished render is as expected", - ).toEqual(["Stopped (end_turn) [input: 0, output: 0]"] as Line[]); - - // expect( - // await extractMountTree(mountedApp.getMountedNode()), - // ).toMatchSnapshot(); + ).toEqual(Chat.LOGO.split("\n") as Line[]); }); }); }); diff --git a/node/chat/chat.ts b/node/chat/chat.ts index ef8c3a1..7ea1ee5 100644 --- a/node/chat/chat.ts +++ b/node/chat/chat.ts @@ -545,46 +545,45 @@ ${msg.error.stack}`, model, dispatch, }) => { - return d`${ - model.messages.length - ? model.messages.map( - (m, idx) => - d`${messageModel.view({ - model: m, - toolManager: model.toolManager, - dispatch: (msg) => { - dispatch({ type: "message-msg", msg, idx }); - }, - })}\n`, + if ( + model.messages.length == 0 && + Object.keys(model.contextManager.files).length == 0 + ) { + return d`${LOGO}`; + } + + return d`${model.messages.map( + (m, idx) => + d`${messageModel.view({ + model: m, + toolManager: model.toolManager, + dispatch: (msg) => { + dispatch({ type: "message-msg", msg, idx }); + }, + })}\n`, + )}${ + model.conversation.state == "message-in-flight" + ? d`Awaiting response ${ + MESSAGE_ANIMATION[ + Math.floor( + (new Date().getTime() - model.conversation.sendDate.getTime()) / + 333, + ) % MESSAGE_ANIMATION.length + ] + }` + : withBindings( + d`Stopped (${model.conversation.stopReason}) [input: ${model.conversation.usage.inputTokens.toString()}, output: ${model.conversation.usage.outputTokens.toString()}${ + model.conversation.usage.cacheHits !== undefined && + model.conversation.usage.cacheMisses !== undefined + ? d`, cache hits: ${model.conversation.usage.cacheHits.toString()}, cache misses: ${model.conversation.usage.cacheMisses.toString()}` + : "" + }]`, + { + "": () => dispatch({ type: "show-message-debug-info" }), + }, ) - : LOGO - }${ - model.messages.length - ? model.conversation.state == "message-in-flight" - ? d`Awaiting response ${ - MESSAGE_ANIMATION[ - Math.floor( - (new Date().getTime() - - model.conversation.sendDate.getTime()) / - 333, - ) % MESSAGE_ANIMATION.length - ] - }` - : withBindings( - d`Stopped (${model.conversation.stopReason}) [input: ${model.conversation.usage.inputTokens.toString()}, output: ${model.conversation.usage.outputTokens.toString()}${ - model.conversation.usage.cacheHits !== undefined && - model.conversation.usage.cacheMisses !== undefined - ? d`, cache hits: ${model.conversation.usage.cacheHits.toString()}, cache misses: ${model.conversation.usage.cacheMisses.toString()}` - : "" - }]`, - { - "": () => dispatch({ type: "show-message-debug-info" }), - }, - ) - : "" }${ model.conversation.state == "stopped" && - model.messages.length && !contextManagerModel.isContextEmpty(model.contextManager) ? d`\n${contextManagerModel.view({ model: model.contextManager, @@ -701,7 +700,7 @@ ${msg.error.stack}`, }; } -const LOGO = d`\ +export const LOGO = `\ ________ ╱ ╲ @@ -709,4 +708,4 @@ const LOGO = d`\ ╱ ╱ ╲__╱__╱__╱ -`; +# magenta.nvim`; diff --git a/node/magenta.spec.ts b/node/magenta.spec.ts index 0440bb1..6bea6fb 100644 --- a/node/magenta.spec.ts +++ b/node/magenta.spec.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest"; import { withDriver } from "./test/preamble"; import { pollUntil } from "./utils/async"; import type { Position0Indexed } from "./nvim/window"; +import { LOGO } from "./chat/chat"; describe("node/magenta.spec.ts", () => { it("clear command should work", async () => { @@ -25,9 +26,7 @@ sup? Stopped (end_turn) [input: 0, output: 0]`); await driver.clear(); - await driver.assertDisplayBufferContent( - `Stopped (end_turn) [input: 0, output: 0]`, - ); + await driver.assertDisplayBufferContent(LOGO); await driver.inputMagentaText(`hello again`); await driver.send(); await driver.mockAnthropic.respond({