lint: add Biome (lint only) and fix its findings
This commit is contained in:
1 parent
d5b6406cae
commit
441d9d6ed3
14 files changed
+125
-22
No files matched your search
+6
-3
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bun
|
||||
import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts";
|
||||
import type { OrchestrationV2ShellSnapshot, ThreadId } from "@t3tools/contracts";
|
||||
|
||||
import { T3Session } from "./client/session.ts";
|
||||
import { findThread, lastActivity, relativeTime, rowTime, shortId, statusLabel, threadRows } from "./model/threads.ts";
|
||||
@@ -88,7 +88,10 @@ async function tmuxCommand(args: string[]) {
|
||||
let pending = false;
|
||||
let syncing = false;
|
||||
const sync = async () => {
|
||||
if (syncing) return void (pending = true);
|
||||
if (syncing) {
|
||||
pending = true;
|
||||
return;
|
||||
}
|
||||
syncing = true;
|
||||
try {
|
||||
const latest = session.getShell().snapshot;
|
||||
@@ -115,7 +118,7 @@ async function tmuxCommand(args: string[]) {
|
||||
|
||||
async function runUi(attachNeedle?: string) {
|
||||
const { session, snapshot } = await connectedSession();
|
||||
let attachThreadId;
|
||||
let attachThreadId: ThreadId | undefined;
|
||||
if (attachNeedle) {
|
||||
const thread = findThread(snapshot, attachNeedle);
|
||||
if (!thread) {
|
||||
|
||||
@@ -365,7 +365,10 @@ export class T3Session {
|
||||
watchCommandOutput(threadId: ThreadId, itemId: TurnItemId, listener: Listener<CommandOutputView>, onError: Listener<string>): () => void {
|
||||
let view = EMPTY_COMMAND_OUTPUT;
|
||||
const fiber = this.runInScope(this.requireConnection().rpc[ORCHESTRATION_V2_WS_METHODS.subscribeCommandOutput]({ threadId, itemId }).pipe(
|
||||
Stream.runForEach((frame) => Effect.sync(() => listener(view = applyCommandOutputFrame(view, frame)))),
|
||||
Stream.runForEach((frame) => Effect.sync(() => {
|
||||
view = applyCommandOutputFrame(view, frame);
|
||||
listener(view);
|
||||
})),
|
||||
Effect.catchCause((cause) => Effect.sync(() => onError(prettyCause(cause)))),
|
||||
));
|
||||
return () => { Effect.runFork(Fiber.interrupt(fiber)); };
|
||||
|
||||
@@ -228,7 +228,7 @@ function automationLine(task: ScheduledTask, now: number, timestampFormat: Tui3C
|
||||
task.schedule.type === "interval"
|
||||
? `every ${formatWorkingDurationLabel(task.schedule.everyMs)}`
|
||||
: task.schedule.type === "fixed_time"
|
||||
? `${task.schedule.weekdays && task.schedule.weekdays.length < 7 ? task.schedule.weekdays.map((day) => WEEKDAYS[day]).join(",") + " " : "daily "}${formatClock(task.schedule.timeOfDay, timestampFormat)}`
|
||||
? `${task.schedule.weekdays && task.schedule.weekdays.length < 7 ? `${task.schedule.weekdays.map((day) => WEEKDAYS[day]).join(",")} ` : "daily "}${formatClock(task.schedule.timeOfDay, timestampFormat)}`
|
||||
: "on webhook";
|
||||
if (!task.enabled) return { task, schedule, status: "off", tone: "muted" };
|
||||
if (task.lastRunStatus === "running") return { task, schedule, status: "running", tone: "info" };
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ export interface PatchFile {
|
||||
/** Retains both paths so renamed and deleted files expand against the right revisions. */
|
||||
export function splitPatch(patch: string): PatchFile[] {
|
||||
return patch.split(/^(?=diff --git )/m).filter((chunk) => chunk.startsWith("diff --git ")).map((chunk) => {
|
||||
let parsed;
|
||||
let parsed: ReturnType<typeof parsePatch>[number] | undefined;
|
||||
try { parsed = parsePatch(chunk.split(/^@@ /m)[0]!)[0]; } catch { /* A truncated preview can end inside a file header. */ }
|
||||
const oldPath = cleanPath(parsed?.oldFileName ?? /^diff --git a\/(.+?) b\//.exec(chunk)?.[1] ?? "file");
|
||||
const newPath = cleanPath(parsed?.newFileName ?? oldPath);
|
||||
|
||||
@@ -18,6 +18,7 @@ export function ring(): void {
|
||||
* either ignore it. In tmux it needs `set -g allow-passthrough on`.
|
||||
*/
|
||||
export function desktopNotify(title: string, body: string): void {
|
||||
// biome-ignore lint/suspicious/noControlCharactersInRegex: the control characters are what is being stripped
|
||||
const clean = (text: string) => text.replace(/[\x00-\x1f\x7f;]/g, " ").slice(0, 200);
|
||||
const sequence = process.env.KITTY_WINDOW_ID
|
||||
? `\x1b]99;i=tui3:d=0;${clean(title)}\x1b\\\x1b]99;i=tui3:p=body;${clean(body)}\x1b\\`
|
||||
|
||||
+24
-9
@@ -114,29 +114,44 @@ export function useQueue(input: {
|
||||
switch (event.name) {
|
||||
case "j":
|
||||
case "down":
|
||||
return setFocus(Math.min(queued.length - 1, focus + 1)), true;
|
||||
setFocus(Math.min(queued.length - 1, focus + 1));
|
||||
return true;
|
||||
case "k":
|
||||
case "up":
|
||||
return setFocus(Math.max(0, focus - 1)), true;
|
||||
setFocus(Math.max(0, focus - 1));
|
||||
return true;
|
||||
case "return":
|
||||
case "s":
|
||||
return sendNow(message), true;
|
||||
sendNow(message);
|
||||
return true;
|
||||
case "e":
|
||||
return beginEdit(message), true;
|
||||
beginEdit(message);
|
||||
return true;
|
||||
case "x":
|
||||
case "d":
|
||||
case "backspace":
|
||||
return remove(message), true;
|
||||
remove(message);
|
||||
return true;
|
||||
case "escape":
|
||||
case "q":
|
||||
return setFocus(null), true;
|
||||
setFocus(null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (mode === "nav" && event.name === "q" && event.shift && queued.length > 0) return setFocus(0), true;
|
||||
if (mode === "nav" && event.name === "q" && event.shift && queued.length > 0) {
|
||||
setFocus(0);
|
||||
return true;
|
||||
}
|
||||
// The web's alt+↑: edit the last queued message.
|
||||
if (mode === "input" && event.meta && event.name === "up" && !editing && queued.length > 0) return beginEdit(queued[queued.length - 1]!), true;
|
||||
if (mode === "input" && event.name === "escape" && editing) return cancelEdit(), true;
|
||||
if (mode === "input" && event.meta && event.name === "up" && !editing && queued.length > 0) {
|
||||
beginEdit(queued[queued.length - 1]!);
|
||||
return true;
|
||||
}
|
||||
if (mode === "input" && event.name === "escape" && editing) {
|
||||
cancelEdit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
@@ -47,8 +47,14 @@ export function useSecretRequest(input: { readonly session: T3Session; readonly
|
||||
if (!request) return false;
|
||||
if (value === null) {
|
||||
if (!nav) return false;
|
||||
if (event.name === "return") return setValue(""), true;
|
||||
if (event.name === "x" && !questionPending) return answer({ type: "decline" }), true;
|
||||
if (event.name === "return") {
|
||||
setValue("");
|
||||
return true;
|
||||
}
|
||||
if (event.name === "x" && !questionPending) {
|
||||
answer({ type: "decline" });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (event.ctrl && event.name === "c") return false;
|
||||
|
||||
Reference in new issue
Block a user