chore: apply biome lint fixes
This commit is contained in:
@@ -81,8 +81,7 @@ export class GatewayChatClient {
|
||||
await this.readyPromise;
|
||||
}
|
||||
|
||||
async sendChat(opts: ChatSendOptions): Promise<{ runId: string }>
|
||||
{
|
||||
async sendChat(opts: ChatSendOptions): Promise<{ runId: string }> {
|
||||
const runId = randomUUID();
|
||||
await this.client.request("chat.send", {
|
||||
sessionKey: opts.sessionKey,
|
||||
|
||||
@@ -21,7 +21,8 @@ export class ChatLayout implements Component {
|
||||
const statusLines = this.status.render(width);
|
||||
const inputLines = this.input.render(width);
|
||||
|
||||
const reserved = headerLines.length + statusLines.length + inputLines.length;
|
||||
const reserved =
|
||||
headerLines.length + statusLines.length + inputLines.length;
|
||||
const available = Math.max(rows - reserved, 0);
|
||||
|
||||
const messageLines = this.messages.render(width);
|
||||
@@ -30,7 +31,12 @@ export class ChatLayout implements Component {
|
||||
? messageLines.slice(Math.max(0, messageLines.length - available))
|
||||
: [];
|
||||
|
||||
const lines = [...headerLines, ...slicedMessages, ...statusLines, ...inputLines];
|
||||
const lines = [
|
||||
...headerLines,
|
||||
...slicedMessages,
|
||||
...statusLines,
|
||||
...inputLines,
|
||||
];
|
||||
if (lines.length < rows) {
|
||||
const padding = Array.from({ length: rows - lines.length }, () => "");
|
||||
return [...lines, ...padding];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import crypto from "node:crypto";
|
||||
import type { DefaultTextStyle, MarkdownTheme } from "@mariozechner/pi-tui";
|
||||
import { Container, Markdown, Spacer, Text } from "@mariozechner/pi-tui";
|
||||
import type { MarkdownTheme, DefaultTextStyle } from "@mariozechner/pi-tui";
|
||||
import { theme } from "./theme.js";
|
||||
|
||||
export class MessageList extends Container {
|
||||
@@ -38,7 +38,13 @@ export class MessageList extends Container {
|
||||
addAssistant(text: string, id?: string): string {
|
||||
const messageId = id ?? crypto.randomUUID();
|
||||
const label = new Text(theme.assistant("clawd"), 1, 0);
|
||||
const body = new Markdown(text, 1, 0, this.markdownTheme, this.styles.assistant);
|
||||
const body = new Markdown(
|
||||
text,
|
||||
1,
|
||||
0,
|
||||
this.markdownTheme,
|
||||
this.styles.assistant,
|
||||
);
|
||||
const group = new Container();
|
||||
group.addChild(label);
|
||||
group.addChild(body);
|
||||
@@ -60,7 +66,6 @@ export class MessageList extends Container {
|
||||
text: string,
|
||||
style: DefaultTextStyle,
|
||||
) {
|
||||
const messageId = crypto.randomUUID();
|
||||
const label = new Text(
|
||||
role === "user"
|
||||
? theme.user("you")
|
||||
@@ -76,6 +81,5 @@ export class MessageList extends Container {
|
||||
group.addChild(body);
|
||||
this.addChild(group);
|
||||
this.addChild(new Spacer(1));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import chalk from "chalk";
|
||||
import type { MarkdownTheme } from "@mariozechner/pi-tui";
|
||||
import chalk from "chalk";
|
||||
|
||||
export const markdownTheme: MarkdownTheme = {
|
||||
heading: (text) => chalk.bold.cyan(text),
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {
|
||||
type Component,
|
||||
Input,
|
||||
isCtrlC,
|
||||
isEscape,
|
||||
ProcessTerminal,
|
||||
Text,
|
||||
TUI,
|
||||
isCtrlC,
|
||||
isEscape,
|
||||
} from "@mariozechner/pi-tui";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { GatewayChatClient } from "./gateway-chat.js";
|
||||
@@ -37,8 +37,7 @@ class InputWrapper implements Component {
|
||||
private input: Input,
|
||||
private onAbort: () => void,
|
||||
private onExit: () => void,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
handleInput(data: string): void {
|
||||
if (isCtrlC(data)) {
|
||||
@@ -76,10 +75,13 @@ function extractText(message?: unknown): string {
|
||||
return parts.join("\n").trim();
|
||||
}
|
||||
|
||||
function renderHistoryEntry(entry: unknown): { role: "user" | "assistant"; text: string } | null {
|
||||
function renderHistoryEntry(
|
||||
entry: unknown,
|
||||
): { role: "user" | "assistant"; text: string } | null {
|
||||
if (!entry || typeof entry !== "object") return null;
|
||||
const record = entry as Record<string, unknown>;
|
||||
const role = record.role === "user" || record.role === "assistant" ? record.role : null;
|
||||
const role =
|
||||
record.role === "user" || record.role === "assistant" ? record.role : null;
|
||||
if (!role) return null;
|
||||
const text = extractText(record);
|
||||
if (!text) return null;
|
||||
@@ -112,7 +114,10 @@ export async function runTui(opts: TuiOptions) {
|
||||
async () => {
|
||||
if (!activeRunId) return;
|
||||
try {
|
||||
await client.abortChat({ sessionKey: currentSession, runId: activeRunId });
|
||||
await client.abortChat({
|
||||
sessionKey: currentSession,
|
||||
runId: activeRunId,
|
||||
});
|
||||
} catch (err) {
|
||||
messages.addSystem(`Abort failed: ${String(err)}`);
|
||||
}
|
||||
@@ -245,14 +250,23 @@ export async function runTui(opts: TuiOptions) {
|
||||
messages.addSystem("no active run");
|
||||
break;
|
||||
}
|
||||
await client.abortChat({ sessionKey: currentSession, runId: activeRunId });
|
||||
await client.abortChat({
|
||||
sessionKey: currentSession,
|
||||
runId: activeRunId,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "exit": {
|
||||
client.stop();
|
||||
tui.stop();
|
||||
process.exit(0);
|
||||
break;
|
||||
}
|
||||
case "exit":
|
||||
case "quit": {
|
||||
client.stop();
|
||||
tui.stop();
|
||||
process.exit(0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
messages.addSystem(`unknown command: /${command}`);
|
||||
@@ -319,7 +333,9 @@ export async function runTui(opts: TuiOptions) {
|
||||
};
|
||||
|
||||
client.onGap = (info) => {
|
||||
messages.addSystem(`event gap: expected ${info.expected}, got ${info.received}`);
|
||||
messages.addSystem(
|
||||
`event gap: expected ${info.expected}, got ${info.received}`,
|
||||
);
|
||||
tui.requestRender();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user