import { beforeAll, describe, expect, it } from "bun:test"; import type { SegmentContext } from "@oh-my-pi/pi-coding-agent/modes/components/status-line/segments"; import { renderSegment } from "@oh-my-pi/pi-coding-agent/modes/components/status-line/segments"; import { initTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; beforeAll(async () => { await initTheme(); }); function createModelContext(advisorActive: boolean): SegmentContext { return { session: { state: { model: { id: "test-model", name: "Test Model" } }, isFastModeActive: () => false, isAutoThinking: false, autoResolvedThinkingLevel: () => undefined, isAdvisorActive: () => advisorActive, } as unknown as SegmentContext["session"], width: 120, options: {}, planMode: null, loopMode: null, goalMode: null, collab: null, usageStats: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, premiumRequests: 0, cost: 0, tokensPerSecond: null, }, contextPercent: 0, contextTokens: 0, contextWindow: 0, autoCompactEnabled: false, subagentCount: 0, sessionStartTime: Date.now(), activeRepo: null, git: { branch: null, status: null, pr: null }, usage: null, }; } describe("status line model segment advisor badge", () => { it("appends a success-colored ++ badge when the advisor is active", () => { const rendered = renderSegment("model", createModelContext(true)); expect(rendered.content).toContain("Test Model"); // The badge carries the success color, kept distinct from the statusLineModel // name color (which several themes alias to `accent`). expect(rendered.content).toContain(theme.fg("success", "++")); }); it("omits the badge when the advisor is inactive", () => { const rendered = renderSegment("model", createModelContext(false)); expect(rendered.content).toContain("Test Model"); expect(rendered.content).not.toContain("++"); }); });