fix(coding-agent): add earendil startup announcement
This commit is contained in:
BIN
packages/coding-agent/src/modes/interactive/assets/clankolas.png
Normal file
BIN
packages/coding-agent/src/modes/interactive/assets/clankolas.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 526 KiB |
@@ -0,0 +1,52 @@
|
||||
import * as fs from "node:fs";
|
||||
import { Container, Image, Spacer, Text } from "@mariozechner/pi-tui";
|
||||
import { getBundledInteractiveAssetPath } from "../../../config.js";
|
||||
import { theme } from "../theme/theme.js";
|
||||
import { DynamicBorder } from "./dynamic-border.js";
|
||||
|
||||
const BLOG_URL = "https://mariozechner.at/posts/2026-04-08-ive-sold-out/";
|
||||
const IMAGE_FILENAME = "clankolas.png";
|
||||
|
||||
let cachedImageBase64: string | undefined;
|
||||
let attemptedImageLoad = false;
|
||||
|
||||
function loadImageBase64(): string | undefined {
|
||||
if (attemptedImageLoad) {
|
||||
return cachedImageBase64;
|
||||
}
|
||||
|
||||
attemptedImageLoad = true;
|
||||
try {
|
||||
cachedImageBase64 = fs.readFileSync(getBundledInteractiveAssetPath(IMAGE_FILENAME)).toString("base64");
|
||||
} catch {
|
||||
cachedImageBase64 = undefined;
|
||||
}
|
||||
return cachedImageBase64;
|
||||
}
|
||||
|
||||
export class EarendilAnnouncementComponent extends Container {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
|
||||
this.addChild(new Text(theme.bold(theme.fg("accent", "pi has joined Earendil")), 1, 0));
|
||||
this.addChild(new Spacer(1));
|
||||
|
||||
const imageBase64 = loadImageBase64();
|
||||
if (imageBase64) {
|
||||
this.addChild(
|
||||
new Image(
|
||||
imageBase64,
|
||||
"image/png",
|
||||
{ fallbackColor: (text) => theme.fg("muted", text) },
|
||||
{ maxWidthCells: 56, filename: IMAGE_FILENAME },
|
||||
),
|
||||
);
|
||||
this.addChild(new Spacer(1));
|
||||
}
|
||||
|
||||
this.addChild(new Text(theme.fg("muted", "Read the blog post:"), 1, 0));
|
||||
this.addChild(new Text(theme.fg("mdLink", BLOG_URL), 1, 0));
|
||||
this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@ import { CustomEditor } from "./components/custom-editor.js";
|
||||
import { CustomMessageComponent } from "./components/custom-message.js";
|
||||
import { DaxnutsComponent } from "./components/daxnuts.js";
|
||||
import { DynamicBorder } from "./components/dynamic-border.js";
|
||||
import { EarendilAnnouncementComponent } from "./components/earendil-announcement.js";
|
||||
import { ExtensionEditorComponent } from "./components/extension-editor.js";
|
||||
import { ExtensionInputComponent } from "./components/extension-input.js";
|
||||
import { ExtensionSelectorComponent } from "./components/extension-selector.js";
|
||||
@@ -173,6 +174,7 @@ export class InteractiveMode {
|
||||
private lastSigintTime = 0;
|
||||
private lastEscapeTime = 0;
|
||||
private changelogMarkdown: string | undefined = undefined;
|
||||
private startupNoticesShown = false;
|
||||
|
||||
// Status line tracking (for mutating immediately-sequential status updates)
|
||||
private lastStatusSpacer: Spacer | undefined = undefined;
|
||||
@@ -427,6 +429,48 @@ export class InteractiveMode {
|
||||
}
|
||||
}
|
||||
|
||||
private shouldShowEarendilAnnouncement(): boolean {
|
||||
const now = new Date();
|
||||
return now.getFullYear() === 2026 && now.getMonth() === 3 && now.getDate() === 8;
|
||||
}
|
||||
|
||||
private showStartupNoticesIfNeeded(): void {
|
||||
if (this.startupNoticesShown) {
|
||||
return;
|
||||
}
|
||||
this.startupNoticesShown = true;
|
||||
|
||||
if (this.shouldShowEarendilAnnouncement()) {
|
||||
if (this.chatContainer.children.length > 0) {
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
}
|
||||
this.chatContainer.addChild(new EarendilAnnouncementComponent());
|
||||
}
|
||||
|
||||
if (!this.changelogMarkdown) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.chatContainer.children.length > 0) {
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
}
|
||||
this.chatContainer.addChild(new DynamicBorder());
|
||||
if (this.settingsManager.getCollapseChangelog()) {
|
||||
const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
|
||||
const latestVersion = versionMatch ? versionMatch[1] : this.version;
|
||||
const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
|
||||
this.chatContainer.addChild(new Text(condensedText, 1, 0));
|
||||
} else {
|
||||
this.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.chatContainer.addChild(
|
||||
new Markdown(this.changelogMarkdown.trim(), 1, 0, this.getMarkdownThemeWithSettings()),
|
||||
);
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
}
|
||||
this.chatContainer.addChild(new DynamicBorder());
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
if (this.isInitialized) return;
|
||||
|
||||
@@ -479,37 +523,10 @@ export class InteractiveMode {
|
||||
this.headerContainer.addChild(new Spacer(1));
|
||||
this.headerContainer.addChild(this.builtInHeader);
|
||||
this.headerContainer.addChild(new Spacer(1));
|
||||
|
||||
// Add changelog if provided
|
||||
if (this.changelogMarkdown) {
|
||||
this.headerContainer.addChild(new DynamicBorder());
|
||||
if (this.settingsManager.getCollapseChangelog()) {
|
||||
const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
|
||||
const latestVersion = versionMatch ? versionMatch[1] : this.version;
|
||||
const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
|
||||
this.headerContainer.addChild(new Text(condensedText, 1, 0));
|
||||
} else {
|
||||
this.headerContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
|
||||
this.headerContainer.addChild(new Spacer(1));
|
||||
this.headerContainer.addChild(
|
||||
new Markdown(this.changelogMarkdown.trim(), 1, 0, this.getMarkdownThemeWithSettings()),
|
||||
);
|
||||
this.headerContainer.addChild(new Spacer(1));
|
||||
}
|
||||
this.headerContainer.addChild(new DynamicBorder());
|
||||
}
|
||||
} else {
|
||||
// Minimal header when silenced
|
||||
this.builtInHeader = new Text("", 0, 0);
|
||||
this.headerContainer.addChild(this.builtInHeader);
|
||||
if (this.changelogMarkdown) {
|
||||
// Still show changelog notification even in silent mode
|
||||
this.headerContainer.addChild(new Spacer(1));
|
||||
const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
|
||||
const latestVersion = versionMatch ? versionMatch[1] : this.version;
|
||||
const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
|
||||
this.headerContainer.addChild(new Text(condensedText, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
this.ui.addChild(this.chatContainer);
|
||||
@@ -1249,11 +1266,13 @@ export class InteractiveMode {
|
||||
const extensionRunner = this.session.extensionRunner;
|
||||
if (!extensionRunner) {
|
||||
this.showLoadedResources({ extensions: [], force: false });
|
||||
this.showStartupNoticesIfNeeded();
|
||||
return;
|
||||
}
|
||||
|
||||
this.setupExtensionShortcuts(extensionRunner);
|
||||
this.showLoadedResources({ force: false });
|
||||
this.showStartupNoticesIfNeeded();
|
||||
}
|
||||
|
||||
private applyRuntimeSettings(): void {
|
||||
|
||||
Reference in New Issue
Block a user