Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export class FooterComponent implements Component {
const modelName = state.model?.id || "no-model";
const thinkingLevel = state.thinkingLevel || "off";
const windowDisplay = `${formatTokens(contextWindow)} window`;
let statsLine = `${modelName} ${thinkingLevel} • ${contextPercentStr} • ${windowDisplay}`;
const planStatus = this.session.collaborationMode === "plan" ? "[plan] " : "";
let statsLine = `${planStatus}${modelName} ${thinkingLevel} • ${contextPercentStr} • ${windowDisplay}`;

if (visibleWidth(statsLine) > width) {
statsLine = truncateToWidth(statsLine, width, "...");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
Box,
Container,
Markdown,
type MarkdownTheme,
Spacer,
stripTerminalSequences,
Text,
} from "@earendil-works/diffex-tui";
import type { MarkdownTransformer } from "../../../core/extensions/types.ts";
import type { PlanArtifact } from "../../../core/plan-mode.ts";
import { getMarkdownTheme, theme } from "../theme/theme.ts";
import { createMarkdownTransform } from "./markdown-transform.ts";

/** Renders a submitted plan as a first-class transcript artifact. */
export class PlanMessageComponent extends Container {
constructor(
plan: PlanArtifact,
markdownTheme: MarkdownTheme = getMarkdownTheme(),
outputPad = 1,
markdownTransformers: readonly MarkdownTransformer[] = [],
) {
super();
this.addChild(new Spacer(1));

const box = new Box(outputPad, 1, (content) => theme.bg("customMessageBg", content));
const title = stripTerminalSequences(plan.title).replace(/\s+/gu, " ").trim() || "Untitled plan";
box.addChild(new Text(theme.bold(theme.fg("customMessageLabel", `Plan: ${title}`)), 0, 0));
box.addChild(new Spacer(1));
box.addChild(
new Markdown(
plan.markdown,
0,
0,
markdownTheme,
{ color: (content) => theme.fg("customMessageText", content) },
{
preserveOrderedListMarkers: true,
preserveBackslashEscapes: true,
transform: createMarkdownTransform("assistant", false, markdownTransformers),
},
),
);
this.addChild(box);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ class TreeList implements Component {
entry.type === "custom" ||
entry.type === "model_change" ||
entry.type === "thinking_level_change" ||
entry.type === "collaboration_mode_change" ||
entry.type === "plan_resolution" ||
entry.type === "session_info";

switch (this.filterMode) {
Expand Down Expand Up @@ -605,6 +607,15 @@ class TreeList implements Component {
case "thinking_level_change":
parts.push("thinking", entry.thinkingLevel);
break;
case "collaboration_mode_change":
parts.push("collaboration mode", entry.mode);
break;
case "plan":
parts.push("plan", entry.plan.title, entry.plan.markdown);
break;
case "plan_resolution":
parts.push("plan resolution", entry.resolution, entry.planId);
break;
case "custom":
parts.push("custom", entry.customType);
break;
Expand Down Expand Up @@ -835,6 +846,15 @@ class TreeList implements Component {
case "thinking_level_change":
result = theme.fg("dim", `[thinking: ${entry.thinkingLevel}]`);
break;
case "collaboration_mode_change":
result = theme.fg("dim", `[collaboration mode: ${entry.mode}]`);
break;
case "plan":
result = theme.fg("accent", "[plan]: ") + normalize(entry.plan.title);
break;
case "plan_resolution":
result = theme.fg("dim", `[plan resolution: ${entry.resolution}]`);
break;
case "custom":
result = theme.fg("dim", `[custom: ${entry.customType}]`);
break;
Expand Down Expand Up @@ -919,6 +939,15 @@ class TreeList implements Component {
case "branch_summary":
text = entry.summary;
break;
case "collaboration_mode_change":
text = `Collaboration mode: ${entry.mode}`;
break;
case "plan":
text = `${entry.plan.title}\n\n${entry.plan.markdown}`;
break;
case "plan_resolution":
text = `Plan ${entry.planId}: ${entry.resolution}`;
break;
}

return text?.trim() ? text : undefined;
Expand Down
Loading