From 287f75aa2bc84d931baccfb217dda0618be07ea9 Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 21:16:26 +0000 Subject: [PATCH 1/3] feat(vscode): use terminal.integrated font settings in Agent Manager xterm terminals Reads terminal.integrated.fontFamily and terminal.integrated.fontSize (with editor font fallback) instead of the editor font CSS var. A config watcher broadcasts fontChanged messages so live terminals update without a reload. Nerd Font glyphs now render correctly in Agent Manager terminal tabs. --- .changeset/terminal-integrated-font.md | 5 ++ .../src/agent-manager/AgentManagerProvider.ts | 7 +++ .../src/agent-manager/terminal-font.ts | 59 +++++++++++++++++++ .../src/agent-manager/terminal-routing.ts | 5 +- .../kilo-vscode/src/agent-manager/types.ts | 10 ++++ .../tests/unit/agent-manager-arch.test.ts | 4 ++ .../agent-manager/terminal/TerminalTab.tsx | 34 +++++++++-- .../agent-manager/terminal/render.tsx | 2 +- .../agent-manager/terminal/state.ts | 14 ++++- 9 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 .changeset/terminal-integrated-font.md create mode 100644 packages/kilo-vscode/src/agent-manager/terminal-font.ts diff --git a/.changeset/terminal-integrated-font.md b/.changeset/terminal-integrated-font.md new file mode 100644 index 000000000000..fae71fea107f --- /dev/null +++ b/.changeset/terminal-integrated-font.md @@ -0,0 +1,5 @@ +--- +"kilo-vscode": patch +--- + +Agent Manager terminals now use `terminal.integrated.fontFamily` and `terminal.integrated.fontSize` (including Nerd Font glyphs) instead of the editor font. diff --git a/packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts b/packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts index fe0c08b60c3c..2091211251c2 100644 --- a/packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts +++ b/packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts @@ -36,6 +36,7 @@ import { parseToolRequest, startFromTool, type ToolRequest } from "./tool-start" import { stopSessionProcesses } from "../kilo-provider/background-process" import { startSession } from "./mcp-warmup" +import { readTerminalFont, watchTerminalFont } from "./terminal-font" import { buildKeybindingMap } from "./format-keybinding" import { resolveVersionModels, buildInitialMessages, type CreatedVersion } from "./multi-version" import { Semaphore } from "./semaphore" @@ -73,6 +74,7 @@ export class AgentManagerProvider implements Disposable { private cachedWorktreeStats: { type: "agentManager.worktreeStats"; stats: WorktreeStats[] } | undefined private cachedLocalStats: { type: "agentManager.localStats"; stats: LocalStats } | undefined private unsubTool: (() => void) | undefined + private unsubFont: (() => void) | undefined private closing: Promise | undefined private onVisibilityChange: ((visible: boolean) => void) | undefined @@ -96,6 +98,10 @@ export class AgentManagerProvider implements Disposable { getWorktreePath: (id) => this.getStateManager()?.getWorktree(id)?.path, log: (...args) => this.log("[XTerm]", ...args), post: (msg) => this.postToWebview(msg), + getTerminalFont: () => readTerminalFont(), + }) + this.unsubFont = watchTerminalFont((font) => { + this.postToWebview({ type: "agentManager.terminal.fontChanged", font }) }) this.run = new RunController({ root: () => this.getRoot(), @@ -1791,6 +1797,7 @@ export class AgentManagerProvider implements Disposable { await this.stateReady?.catch((err) => this.log("dispose: stateReady rejected:", err)) await this.state?.flush().catch((err) => this.log("dispose: state flush failed:", err)) this.unsubTool?.() + this.unsubFont?.() this.connectionService.unregisterFocused("agent-manager") this.connectionService.registerOpen("agent-manager", []) this.diffs.stop() diff --git a/packages/kilo-vscode/src/agent-manager/terminal-font.ts b/packages/kilo-vscode/src/agent-manager/terminal-font.ts new file mode 100644 index 000000000000..d49f27ddba35 --- /dev/null +++ b/packages/kilo-vscode/src/agent-manager/terminal-font.ts @@ -0,0 +1,59 @@ +/** + * Helpers to read and watch the user's integrated-terminal font settings. + * + * VS Code's integrated terminal mirrors editor font settings when terminal + * font settings are unset. We replicate that same logic here so the Agent + * Manager xterm instances look identical to VS Code's own terminal. + */ + +import * as vscode from "vscode" + +export interface TerminalFont { + fontFamily: string + fontSize: number + fontWeight?: string + fontWeightBold?: string + lineHeight?: number + letterSpacing?: number +} + +const FALLBACK = "Menlo, Monaco, 'Courier New', monospace" + +/** Resolve the user's integrated-terminal font, mirroring VS Code's own + * fallback to the editor font when the terminal font is unset. */ +export function readTerminalFont(): TerminalFont { + const term = vscode.workspace.getConfiguration("terminal.integrated") + const editor = vscode.workspace.getConfiguration("editor") + const family = term.get("fontFamily")?.trim() || editor.get("fontFamily")?.trim() || FALLBACK + const size = term.get("fontSize") || editor.get("fontSize") || 13 + return { + fontFamily: family, + fontSize: size, + fontWeight: term.get("fontWeight") || undefined, + fontWeightBold: term.get("fontWeightBold") || undefined, + lineHeight: term.get("lineHeight") || undefined, + letterSpacing: term.get("letterSpacing") || undefined, + } +} + +/** True when a config change touches any terminal/editor font setting. */ +export function affectsTerminalFont(e: vscode.ConfigurationChangeEvent): boolean { + return ( + e.affectsConfiguration("terminal.integrated.fontFamily") || + e.affectsConfiguration("terminal.integrated.fontSize") || + e.affectsConfiguration("terminal.integrated.fontWeight") || + e.affectsConfiguration("terminal.integrated.fontWeightBold") || + e.affectsConfiguration("terminal.integrated.lineHeight") || + e.affectsConfiguration("terminal.integrated.letterSpacing") || + e.affectsConfiguration("editor.fontFamily") || + e.affectsConfiguration("editor.fontSize") + ) +} + +/** Subscribe to terminal-font config changes. Returns a cleanup function. */ +export function watchTerminalFont(callback: (font: TerminalFont) => void): () => void { + const sub = vscode.workspace.onDidChangeConfiguration((e) => { + if (affectsTerminalFont(e)) callback(readTerminalFont()) + }) + return () => sub.dispose() +} diff --git a/packages/kilo-vscode/src/agent-manager/terminal-routing.ts b/packages/kilo-vscode/src/agent-manager/terminal-routing.ts index 38082ab51ffa..7c8c7e46cc2c 100644 --- a/packages/kilo-vscode/src/agent-manager/terminal-routing.ts +++ b/packages/kilo-vscode/src/agent-manager/terminal-routing.ts @@ -15,7 +15,7 @@ */ import type { KiloClient } from "@kilocode/sdk/v2/client" -import type { AgentManagerInMessage, AgentManagerOutMessage } from "./types" +import type { AgentManagerInMessage, AgentManagerOutMessage, TerminalFont } from "./types" import { TerminalManager } from "./terminal-manager" interface ServerConfig { @@ -36,6 +36,8 @@ export interface TerminalRoutingDeps { log(...args: unknown[]): void /** Send a message back to the webview. */ post(message: AgentManagerOutMessage): void + /** Return the current terminal font settings. */ + getTerminalFont(): TerminalFont } /** True iff the message belongs to the terminal-tab subsystem. */ @@ -106,6 +108,7 @@ export class TerminalRouter { terminalId: created.terminalId, title: created.title, wsUrl: created.wsUrl, + font: this.deps.getTerminalFont(), }) } catch (err) { const message = err instanceof Error ? err.message : String(err) diff --git a/packages/kilo-vscode/src/agent-manager/types.ts b/packages/kilo-vscode/src/agent-manager/types.ts index f6f312fe4665..360b32c7217f 100644 --- a/packages/kilo-vscode/src/agent-manager/types.ts +++ b/packages/kilo-vscode/src/agent-manager/types.ts @@ -14,6 +14,9 @@ import type { ApplyConflict } from "./GitOps" import type { BranchListItem, WorktreeSetupErrorCode } from "./git-import" import type { ExternalWorktreeItem } from "./WorktreeManager" import type { RunStatus } from "./run/manager" +import type { TerminalFont } from "./terminal-font" + +export type { TerminalFont } // --------------------------------------------------------------------------- // Shared payload types @@ -147,6 +150,7 @@ interface TerminalCreatedMessage { terminalId: string title: string wsUrl: string + font: TerminalFont } interface TerminalClosedMessage { @@ -160,6 +164,11 @@ interface TerminalErrorMessage { message: string } +interface TerminalFontChangedMessage { + type: "agentManager.terminal.fontChanged" + font: TerminalFont +} + interface ErrorOutMessage { type: "error" message: string @@ -314,6 +323,7 @@ export type AgentManagerOutMessage = | TerminalCreatedMessage | TerminalClosedMessage | TerminalErrorMessage + | TerminalFontChangedMessage // --------------------------------------------------------------------------- // Webview → Extension messages (onMessage) diff --git a/packages/kilo-vscode/tests/unit/agent-manager-arch.test.ts b/packages/kilo-vscode/tests/unit/agent-manager-arch.test.ts index 71733ccdd94f..a0c196bfc095 100644 --- a/packages/kilo-vscode/tests/unit/agent-manager-arch.test.ts +++ b/packages/kilo-vscode/tests/unit/agent-manager-arch.test.ts @@ -653,6 +653,10 @@ const VSCODE_ALLOWED: Record = { "run/task.ts": { note: "vscode adapter for Agent Manager run scripts", }, + // Reads terminal.integrated.* and editor.font* config for xterm font settings + "terminal-font.ts": { + note: "vscode config reader for integrated terminal font settings", + }, } /** diff --git a/packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx b/packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx index 14cb63a4de83..8ad304f46ce3 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx @@ -11,7 +11,7 @@ */ import { Component, createEffect, onCleanup, onMount } from "solid-js" -import { Terminal } from "@xterm/xterm" +import { Terminal, type FontWeight } from "@xterm/xterm" import { FitAddon } from "@xterm/addon-fit" import { WebLinksAddon } from "@xterm/addon-web-links" import { ClipboardAddon } from "@xterm/addon-clipboard" @@ -20,10 +20,14 @@ import "@xterm/xterm/css/xterm.css" import { useVSCode } from "../../src/context/vscode" import { useLanguage } from "../../src/context/language" import { formatReviewCommentsMarkdown } from "../../src/utils/review-comment-markdown" +import type { TerminalFont } from "./state" interface Props { terminalId: string wsUrl: string + /** Terminal font settings forwarded from the extension host. Used on + * initial mount; live changes arrive via `agentManager.terminal.fontChanged`. */ + font: TerminalFont /** Whether this terminal is currently the focused tab. * * The xterm subtree always stays in the paint tree (see the layer / @@ -126,12 +130,16 @@ export const TerminalTab: Component = (props) => { const term = new Terminal({ convertEol: true, cursorBlink: true, - fontFamily: cssVar("--vscode-editor-font-family", "Menlo, Monaco, 'Courier New', monospace"), - fontSize: Number.parseFloat(cssVar("--font-size-base", "13px")), + fontFamily: props.font.fontFamily, + fontSize: props.font.fontSize, scrollback: 5000, theme: readTheme(), allowProposedApi: true, }) + if (props.font.fontWeight) term.options.fontWeight = props.font.fontWeight as FontWeight + if (props.font.fontWeightBold) term.options.fontWeightBold = props.font.fontWeightBold as FontWeight + if (props.font.lineHeight) term.options.lineHeight = props.font.lineHeight + if (props.font.letterSpacing) term.options.letterSpacing = props.font.letterSpacing const fit = new FitAddon() term.loadAddon(fit) // Clickable URLs in terminal output (Cmd/Ctrl+click to open). @@ -288,12 +296,26 @@ export const TerminalTab: Component = (props) => { return } + if (message.type === "agentManager.terminal.fontChanged") { + const font = message.font as TerminalFont + term.options.fontFamily = font.fontFamily + term.options.fontSize = font.fontSize + if (font.fontWeight) term.options.fontWeight = font.fontWeight as FontWeight + if (font.fontWeightBold) term.options.fontWeightBold = font.fontWeightBold as FontWeight + if (font.lineHeight) term.options.lineHeight = font.lineHeight + if (font.letterSpacing) term.options.letterSpacing = font.letterSpacing + fit.fit() + syncSize() + scheduleRepaint() + return + } + + // fontSizeChanged/ready control the Kilo chat UI font — do not apply + // them to the terminal, which has its own independent font settings. + // Keep the repaint for any downstream layout side-effects. const size = message.type === "fontSizeChanged" ? message.fontSize : message.type === "ready" ? message.fontSize : undefined if (size === undefined) return - term.options.fontSize = size - fit.fit() - syncSize() scheduleRepaint() }) diff --git a/packages/kilo-vscode/webview-ui/agent-manager/terminal/render.tsx b/packages/kilo-vscode/webview-ui/agent-manager/terminal/render.tsx index 976513140985..2fe5e2c44a03 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/terminal/render.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/terminal/render.tsx @@ -85,7 +85,7 @@ export function renderTerminalLayer(props: { state: TerminalStateControls }): JS const visible = () => slotVisible(term.id, term.contextKey) return (
- +
) }} diff --git a/packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts b/packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts index 7899c1f4d785..64604167ada0 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts +++ b/packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts @@ -11,6 +11,16 @@ import { createMemo, createSignal } from "solid-js" import type { Accessor } from "solid-js" import { LOCAL } from "../navigate" +/** Font settings forwarded from the extension host (mirrors terminal-font.ts). */ +export interface TerminalFont { + fontFamily: string + fontSize: number + fontWeight?: string + fontWeightBold?: string + lineHeight?: number + letterSpacing?: number +} + /** Prefix used for terminal tab IDs in the webview (mirrors terminal-manager.ts). */ export const TERMINAL_PREFIX = "terminal:" @@ -21,6 +31,7 @@ export interface TerminalTabState { id: string title: string wsUrl: string + font: TerminalFont } /** Terminal row enriched with the sidebar context it belongs to. Used by @@ -35,6 +46,7 @@ export interface TerminalCreatedEvent { terminalId: string title: string wsUrl: string + font: TerminalFont } export interface TerminalStateControls { @@ -335,7 +347,7 @@ export function createTerminalMessageHandler(deps: TerminalMessageHandlerDeps) { if (msg.type === "agentManager.terminal.created") { const ev = msg as unknown as TerminalCreatedEvent const contextKey = ev.worktreeId === null ? LOCAL : ev.worktreeId - deps.state.add(ev.worktreeId, { id: ev.terminalId, title: ev.title, wsUrl: ev.wsUrl }) + deps.state.add(ev.worktreeId, { id: ev.terminalId, title: ev.title, wsUrl: ev.wsUrl, font: ev.font }) deps.onCreated?.(contextKey, ev.terminalId) deps.saveTabMemory() deps.setSelection(contextKey) From 3cd4628a525dbc9f84b5947b75ae61519c659f11 Mon Sep 17 00:00:00 2001 From: marius-kilocode Date: Fri, 12 Jun 2026 08:55:45 +0200 Subject: [PATCH 2/3] fix(vscode): complete Agent Manager terminal font sync --- .../src/agent-manager/terminal-font.ts | 29 ++---- .../unit/agent-manager-terminal-font.test.ts | 93 +++++++++++++++++++ .../agent-manager/AgentManagerApp.tsx | 2 +- .../agent-manager/terminal/TerminalTab.tsx | 18 +--- .../agent-manager/terminal/state.ts | 44 ++++----- .../src/types/messages/agent-manager.ts | 5 + .../src/types/messages/extension-messages.ts | 8 ++ 7 files changed, 135 insertions(+), 64 deletions(-) create mode 100644 packages/kilo-vscode/tests/unit/agent-manager-terminal-font.test.ts diff --git a/packages/kilo-vscode/src/agent-manager/terminal-font.ts b/packages/kilo-vscode/src/agent-manager/terminal-font.ts index d49f27ddba35..69cfc06d73aa 100644 --- a/packages/kilo-vscode/src/agent-manager/terminal-font.ts +++ b/packages/kilo-vscode/src/agent-manager/terminal-font.ts @@ -1,9 +1,9 @@ /** * Helpers to read and watch the user's integrated-terminal font settings. * - * VS Code's integrated terminal mirrors editor font settings when terminal - * font settings are unset. We replicate that same logic here so the Agent - * Manager xterm instances look identical to VS Code's own terminal. + * VS Code's integrated terminal falls back to the editor font family when + * its own family is unset. Font size has a separate platform default. We + * replicate those settings for Agent Manager xterm instances. */ import * as vscode from "vscode" @@ -11,42 +11,29 @@ import * as vscode from "vscode" export interface TerminalFont { fontFamily: string fontSize: number - fontWeight?: string - fontWeightBold?: string - lineHeight?: number - letterSpacing?: number } const FALLBACK = "Menlo, Monaco, 'Courier New', monospace" +const SIZE = process.platform === "darwin" ? 12 : 14 /** Resolve the user's integrated-terminal font, mirroring VS Code's own - * fallback to the editor font when the terminal font is unset. */ + * family fallback while preserving the terminal's independent size. */ export function readTerminalFont(): TerminalFont { const term = vscode.workspace.getConfiguration("terminal.integrated") const editor = vscode.workspace.getConfiguration("editor") const family = term.get("fontFamily")?.trim() || editor.get("fontFamily")?.trim() || FALLBACK - const size = term.get("fontSize") || editor.get("fontSize") || 13 return { fontFamily: family, - fontSize: size, - fontWeight: term.get("fontWeight") || undefined, - fontWeightBold: term.get("fontWeightBold") || undefined, - lineHeight: term.get("lineHeight") || undefined, - letterSpacing: term.get("letterSpacing") || undefined, + fontSize: term.get("fontSize") ?? SIZE, } } -/** True when a config change touches any terminal/editor font setting. */ +/** True when a config change affects the effective terminal family or size. */ export function affectsTerminalFont(e: vscode.ConfigurationChangeEvent): boolean { return ( e.affectsConfiguration("terminal.integrated.fontFamily") || e.affectsConfiguration("terminal.integrated.fontSize") || - e.affectsConfiguration("terminal.integrated.fontWeight") || - e.affectsConfiguration("terminal.integrated.fontWeightBold") || - e.affectsConfiguration("terminal.integrated.lineHeight") || - e.affectsConfiguration("terminal.integrated.letterSpacing") || - e.affectsConfiguration("editor.fontFamily") || - e.affectsConfiguration("editor.fontSize") + e.affectsConfiguration("editor.fontFamily") ) } diff --git a/packages/kilo-vscode/tests/unit/agent-manager-terminal-font.test.ts b/packages/kilo-vscode/tests/unit/agent-manager-terminal-font.test.ts new file mode 100644 index 000000000000..14bee64105dc --- /dev/null +++ b/packages/kilo-vscode/tests/unit/agent-manager-terminal-font.test.ts @@ -0,0 +1,93 @@ +import { describe, expect, it } from "bun:test" +import type { KiloClient } from "@kilocode/sdk/v2/client" +import { createRoot } from "solid-js" +import { affectsTerminalFont, readTerminalFont } from "../../src/agent-manager/terminal-font" +import { TerminalRouter } from "../../src/agent-manager/terminal-routing" +import type { AgentManagerOutMessage, TerminalFont } from "../../src/agent-manager/types" +import { createTerminalMessageHandler, createTerminalState } from "../../webview-ui/agent-manager/terminal/state" +import { LOCAL } from "../../webview-ui/agent-manager/navigate" +import type { ExtensionMessage } from "../../webview-ui/src/types/messages/extension-messages" + +const font: TerminalFont = { + fontFamily: "MesloLGS NF", + fontSize: 18, +} + +describe("Agent Manager terminal font", () => { + it("uses the platform terminal size when configuration is unavailable", () => { + expect(readTerminalFont()).toEqual({ + fontFamily: "Menlo, Monaco, 'Courier New', monospace", + fontSize: process.platform === "darwin" ? 12 : 14, + }) + }) + + it("watches only settings that affect the terminal family or size", () => { + const event = (key: string) => + ({ + affectsConfiguration: (target: string) => target === key, + }) as Parameters[0] + + expect(affectsTerminalFont(event("terminal.integrated.fontFamily"))).toBe(true) + expect(affectsTerminalFont(event("terminal.integrated.fontSize"))).toBe(true) + expect(affectsTerminalFont(event("editor.fontFamily"))).toBe(true) + expect(affectsTerminalFont(event("editor.fontSize"))).toBe(false) + expect(affectsTerminalFont(event("terminal.integrated.letterSpacing"))).toBe(false) + }) + + it("includes the current font when creating a terminal", async () => { + const client = { + pty: { + create: async () => ({ data: { id: "pty-1", title: "Terminal 1" } }), + remove: async () => ({ data: true }), + update: async () => ({ data: true }), + }, + } as unknown as KiloClient + const message = new Promise((resolve) => { + const router = new TerminalRouter({ + getClient: () => client, + getServerConfig: () => ({ baseUrl: "http://127.0.0.1:4096", password: "secret" }), + getRoot: () => "/workspace", + getWorktreePath: () => undefined, + log: () => undefined, + post: resolve, + getTerminalFont: () => font, + }) + + expect(router.handle({ type: "agentManager.terminal.create", worktreeId: null })).toBe(true) + }) + + const created = await message + expect(created.type).toBe("agentManager.terminal.created") + if (created.type !== "agentManager.terminal.created") return + expect(created.font).toEqual(font) + expect(created.worktreeId).toBeNull() + expect(created.wsUrl).toContain("/pty/pty-1/connect") + }) + + it("keeps the created font in terminal state", () => { + createRoot((dispose) => { + const state = createTerminalState(() => LOCAL) + const activated: string[] = [] + const handler = createTerminalMessageHandler({ + state, + activate: (id) => activated.push(id), + saveTabMemory: () => undefined, + setSelection: () => undefined, + showError: () => undefined, + }) + const message = { + type: "agentManager.terminal.created", + worktreeId: null, + terminalId: "terminal-1", + title: "Terminal 1", + wsUrl: "ws://127.0.0.1/pty/pty-1/connect", + font, + } satisfies ExtensionMessage + + expect(handler(message)).toBe(true) + expect(state.forSelection(LOCAL)[0]?.font).toEqual(font) + expect(activated).toEqual(["terminal-1"]) + dispose() + }) + }) +}) diff --git a/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx b/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx index 3b178ef35a4f..f7026acfb255 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx @@ -1129,7 +1129,7 @@ const AgentManagerContent: Component = () => { onCreated: (contextKey, terminalId) => appendToTabOrder(contextKey, terminalId), }) const unsubTerminals = vscode.onMessage((msg) => { - terminalDispatch(msg as unknown as { type: string } & Record) + terminalDispatch(msg) }) const unsub = vscode.onMessage((msg) => { diff --git a/packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx b/packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx index 8ad304f46ce3..622fa5207052 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx @@ -11,7 +11,7 @@ */ import { Component, createEffect, onCleanup, onMount } from "solid-js" -import { Terminal, type FontWeight } from "@xterm/xterm" +import { Terminal } from "@xterm/xterm" import { FitAddon } from "@xterm/addon-fit" import { WebLinksAddon } from "@xterm/addon-web-links" import { ClipboardAddon } from "@xterm/addon-clipboard" @@ -136,10 +136,6 @@ export const TerminalTab: Component = (props) => { theme: readTheme(), allowProposedApi: true, }) - if (props.font.fontWeight) term.options.fontWeight = props.font.fontWeight as FontWeight - if (props.font.fontWeightBold) term.options.fontWeightBold = props.font.fontWeightBold as FontWeight - if (props.font.lineHeight) term.options.lineHeight = props.font.lineHeight - if (props.font.letterSpacing) term.options.letterSpacing = props.font.letterSpacing const fit = new FitAddon() term.loadAddon(fit) // Clickable URLs in terminal output (Cmd/Ctrl+click to open). @@ -276,6 +272,7 @@ export const TerminalTab: Component = (props) => { if (!isRenderable()) return try { fit.fit() + syncSize() } catch (err) { // Layout not settled yet; ResizeObserver retries on next change. log("repaint fit() threw", err) @@ -297,15 +294,8 @@ export const TerminalTab: Component = (props) => { } if (message.type === "agentManager.terminal.fontChanged") { - const font = message.font as TerminalFont - term.options.fontFamily = font.fontFamily - term.options.fontSize = font.fontSize - if (font.fontWeight) term.options.fontWeight = font.fontWeight as FontWeight - if (font.fontWeightBold) term.options.fontWeightBold = font.fontWeightBold as FontWeight - if (font.lineHeight) term.options.lineHeight = font.lineHeight - if (font.letterSpacing) term.options.letterSpacing = font.letterSpacing - fit.fit() - syncSize() + term.options.fontFamily = message.font.fontFamily + term.options.fontSize = message.font.fontSize scheduleRepaint() return } diff --git a/packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts b/packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts index 64604167ada0..f472623b287f 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts +++ b/packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts @@ -10,16 +10,10 @@ import { createMemo, createSignal } from "solid-js" import type { Accessor } from "solid-js" import { LOCAL } from "../navigate" +import type { ExtensionMessage } from "../../src/types/messages/extension-messages" +import type { TerminalFont } from "../../src/types/messages/agent-manager" -/** Font settings forwarded from the extension host (mirrors terminal-font.ts). */ -export interface TerminalFont { - fontFamily: string - fontSize: number - fontWeight?: string - fontWeightBold?: string - lineHeight?: number - letterSpacing?: number -} +export type { TerminalFont } /** Prefix used for terminal tab IDs in the webview (mirrors terminal-manager.ts). */ export const TERMINAL_PREFIX = "terminal:" @@ -41,14 +35,6 @@ export interface TerminalTabStateWithContext extends TerminalTabState { contextKey: string } -export interface TerminalCreatedEvent { - worktreeId: string | null - terminalId: string - title: string - wsUrl: string - font: TerminalFont -} - export interface TerminalStateControls { /** Record received from `terminal.created`. */ add(worktreeId: string | null, term: TerminalTabState): void @@ -343,26 +329,28 @@ export interface TerminalMessageHandlerDeps { * out of the main webview component. */ export function createTerminalMessageHandler(deps: TerminalMessageHandlerDeps) { - return (msg: { type: string } & Record): boolean => { + return (msg: ExtensionMessage): boolean => { if (msg.type === "agentManager.terminal.created") { - const ev = msg as unknown as TerminalCreatedEvent - const contextKey = ev.worktreeId === null ? LOCAL : ev.worktreeId - deps.state.add(ev.worktreeId, { id: ev.terminalId, title: ev.title, wsUrl: ev.wsUrl, font: ev.font }) - deps.onCreated?.(contextKey, ev.terminalId) + const contextKey = msg.worktreeId === null ? LOCAL : msg.worktreeId + deps.state.add(msg.worktreeId, { + id: msg.terminalId, + title: msg.title, + wsUrl: msg.wsUrl, + font: msg.font, + }) + deps.onCreated?.(contextKey, msg.terminalId) deps.saveTabMemory() deps.setSelection(contextKey) - deps.activate(ev.terminalId) + deps.activate(msg.terminalId) return true } if (msg.type === "agentManager.terminal.closed") { - const ev = msg as unknown as { terminalId: string } - deps.state.remove(ev.terminalId) - if (deps.state.activeId() === ev.terminalId) deps.state.setActiveId(undefined) + deps.state.remove(msg.terminalId) + if (deps.state.activeId() === msg.terminalId) deps.state.setActiveId(undefined) return true } if (msg.type === "agentManager.terminal.error") { - const ev = msg as unknown as { message: string } - deps.showError(ev.message) + deps.showError(msg.message) return true } return false diff --git a/packages/kilo-vscode/webview-ui/src/types/messages/agent-manager.ts b/packages/kilo-vscode/webview-ui/src/types/messages/agent-manager.ts index c19d22c9dd5a..d97e1fc955b2 100644 --- a/packages/kilo-vscode/webview-ui/src/types/messages/agent-manager.ts +++ b/packages/kilo-vscode/webview-ui/src/types/messages/agent-manager.ts @@ -1,5 +1,10 @@ export type WorktreeErrorCode = "git_not_found" | "not_git_repo" | "lfs_missing" +export interface TerminalFont { + fontFamily: string + fontSize: number +} + // Agent Manager worktree state types (mirrored from WorktreeStateManager) export interface WorktreeState { id: string diff --git a/packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts b/packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts index 161cc14ead04..d0d74bd4d92b 100644 --- a/packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts +++ b/packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts @@ -31,6 +31,7 @@ import type { ReviewComment, RunStatus, SectionState, + TerminalFont, WorktreeErrorCode, WorktreeFileDiff, WorktreeGitStats, @@ -582,6 +583,12 @@ export interface AgentManagerTerminalCreatedMessage { terminalId: string title: string wsUrl: string + font: TerminalFont +} + +export interface AgentManagerTerminalFontChangedMessage { + type: "agentManager.terminal.fontChanged" + font: TerminalFont } export interface AgentManagerTerminalClosedMessage { @@ -1033,6 +1040,7 @@ export type ExtensionMessage = | AgentManagerLocalStatsMessage | AgentManagerPRStatusMessage | AgentManagerTerminalCreatedMessage + | AgentManagerTerminalFontChangedMessage | AgentManagerTerminalClosedMessage | AgentManagerTerminalErrorMessage // legacy-migration start From a5f1514685e7542b956a4b5e22344826ea0342e4 Mon Sep 17 00:00:00 2001 From: marius-kilocode Date: Fri, 12 Jun 2026 09:08:04 +0200 Subject: [PATCH 3/3] test(vscode): isolate terminal font defaults --- .../src/agent-manager/terminal-font.ts | 21 ++++++++++++++----- .../unit/agent-manager-terminal-font.test.ts | 14 ++++++++++--- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/kilo-vscode/src/agent-manager/terminal-font.ts b/packages/kilo-vscode/src/agent-manager/terminal-font.ts index 69cfc06d73aa..474997eaa12a 100644 --- a/packages/kilo-vscode/src/agent-manager/terminal-font.ts +++ b/packages/kilo-vscode/src/agent-manager/terminal-font.ts @@ -16,16 +16,27 @@ export interface TerminalFont { const FALLBACK = "Menlo, Monaco, 'Courier New', monospace" const SIZE = process.platform === "darwin" ? 12 : 14 +export function resolveTerminalFont( + family: string | undefined, + size: number | undefined, + editor: string | undefined, +): TerminalFont { + return { + fontFamily: family?.trim() || editor?.trim() || FALLBACK, + fontSize: size ?? SIZE, + } +} + /** Resolve the user's integrated-terminal font, mirroring VS Code's own * family fallback while preserving the terminal's independent size. */ export function readTerminalFont(): TerminalFont { const term = vscode.workspace.getConfiguration("terminal.integrated") const editor = vscode.workspace.getConfiguration("editor") - const family = term.get("fontFamily")?.trim() || editor.get("fontFamily")?.trim() || FALLBACK - return { - fontFamily: family, - fontSize: term.get("fontSize") ?? SIZE, - } + return resolveTerminalFont( + term.get("fontFamily"), + term.get("fontSize"), + editor.get("fontFamily"), + ) } /** True when a config change affects the effective terminal family or size. */ diff --git a/packages/kilo-vscode/tests/unit/agent-manager-terminal-font.test.ts b/packages/kilo-vscode/tests/unit/agent-manager-terminal-font.test.ts index 14bee64105dc..9bf257a8c3b9 100644 --- a/packages/kilo-vscode/tests/unit/agent-manager-terminal-font.test.ts +++ b/packages/kilo-vscode/tests/unit/agent-manager-terminal-font.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "bun:test" import type { KiloClient } from "@kilocode/sdk/v2/client" import { createRoot } from "solid-js" -import { affectsTerminalFont, readTerminalFont } from "../../src/agent-manager/terminal-font" +import { affectsTerminalFont, resolveTerminalFont } from "../../src/agent-manager/terminal-font" import { TerminalRouter } from "../../src/agent-manager/terminal-routing" import type { AgentManagerOutMessage, TerminalFont } from "../../src/agent-manager/types" import { createTerminalMessageHandler, createTerminalState } from "../../webview-ui/agent-manager/terminal/state" @@ -14,11 +14,19 @@ const font: TerminalFont = { } describe("Agent Manager terminal font", () => { - it("uses the platform terminal size when configuration is unavailable", () => { - expect(readTerminalFont()).toEqual({ + it("resolves terminal settings without inheriting the editor size", () => { + expect(resolveTerminalFont(undefined, undefined, undefined)).toEqual({ fontFamily: "Menlo, Monaco, 'Courier New', monospace", fontSize: process.platform === "darwin" ? 12 : 14, }) + expect(resolveTerminalFont("MesloLGS NF", 16, "Menlo")).toEqual({ + fontFamily: "MesloLGS NF", + fontSize: 16, + }) + expect(resolveTerminalFont(undefined, 16, "Menlo")).toEqual({ + fontFamily: "Menlo", + fontSize: 16, + }) }) it("watches only settings that affect the terminal family or size", () => {