chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -52,7 +52,9 @@ export function createEditorSubmitHandler(params: {
params.editor.setText("");
// Keep previous behavior: ignore empty/whitespace-only submissions.
if (!value) return;
if (!value) {
return;
}
// Bash mode: only if the very first character is '!' and it's not just '!'.
// IMPORTANT: use the raw (untrimmed) text so leading spaces do NOT trigger.
@@ -259,7 +261,9 @@ export async function runTui(opts: TuiOptions) {
tui.setFocus(editor);
const formatSessionKey = (key: string) => {
if (key === "global" || key === "unknown") return key;
if (key === "global" || key === "unknown") {
return key;
}
const parsed = parseAgentSessionKey(key);
return parsed?.rest ?? key;
};
@@ -271,15 +275,21 @@ export async function runTui(opts: TuiOptions) {
const resolveSessionKey = (raw?: string) => {
const trimmed = (raw ?? "").trim();
if (sessionScope === "global") return "global";
if (sessionScope === "global") {
return "global";
}
if (!trimmed) {
return buildAgentMainSessionKey({
agentId: currentAgentId,
mainKey: sessionMainKey,
});
}
if (trimmed === "global" || trimmed === "unknown") return trimmed;
if (trimmed.startsWith("agent:")) return trimmed;
if (trimmed === "global" || trimmed === "unknown") {
return trimmed;
}
if (trimmed.startsWith("agent:")) {
return trimmed;
}
return `agent:${currentAgentId}:${trimmed}`;
};
@@ -301,14 +311,18 @@ export async function runTui(opts: TuiOptions) {
const formatElapsed = (startMs: number) => {
const totalSeconds = Math.max(0, Math.floor((Date.now() - startMs) / 1000));
if (totalSeconds < 60) return `${totalSeconds}s`;
if (totalSeconds < 60) {
return `${totalSeconds}s`;
}
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
return `${minutes}m ${seconds}s`;
};
const ensureStatusText = () => {
if (statusText) return;
if (statusText) {
return;
}
statusContainer.clear();
statusLoader?.stop();
statusLoader = null;
@@ -317,7 +331,9 @@ export async function runTui(opts: TuiOptions) {
};
const ensureStatusLoader = () => {
if (statusLoader) return;
if (statusLoader) {
return;
}
statusContainer.clear();
statusText = null;
statusLoader = new Loader(
@@ -334,7 +350,9 @@ export async function runTui(opts: TuiOptions) {
let waitingPhrase: string | null = null;
const updateBusyStatusMessage = () => {
if (!statusLoader || !statusStartedAt) return;
if (!statusLoader || !statusStartedAt) {
return;
}
const elapsed = formatElapsed(statusStartedAt);
if (activityStatus === "waiting") {
@@ -355,21 +373,29 @@ export async function runTui(opts: TuiOptions) {
};
const startStatusTimer = () => {
if (statusTimer) return;
if (statusTimer) {
return;
}
statusTimer = setInterval(() => {
if (!busyStates.has(activityStatus)) return;
if (!busyStates.has(activityStatus)) {
return;
}
updateBusyStatusMessage();
}, 1000);
};
const stopStatusTimer = () => {
if (!statusTimer) return;
if (!statusTimer) {
return;
}
clearInterval(statusTimer);
statusTimer = null;
};
const startWaitingTimer = () => {
if (waitingTimer) return;
if (waitingTimer) {
return;
}
// Pick a phrase once per waiting session.
if (!waitingPhrase) {
@@ -380,13 +406,17 @@ export async function runTui(opts: TuiOptions) {
waitingTick = 0;
waitingTimer = setInterval(() => {
if (activityStatus !== "waiting") return;
if (activityStatus !== "waiting") {
return;
}
updateBusyStatusMessage();
}, 120);
};
const stopWaitingTimer = () => {
if (!waitingTimer) return;
if (!waitingTimer) {
return;
}
clearInterval(waitingTimer);
waitingTimer = null;
waitingPhrase = null;
@@ -423,7 +453,9 @@ export async function runTui(opts: TuiOptions) {
const setConnectionStatus = (text: string, ttlMs?: number) => {
connectionStatus = text;
renderStatus();
if (statusTimeout) clearTimeout(statusTimeout);
if (statusTimeout) {
clearTimeout(statusTimeout);
}
if (ttlMs && ttlMs > 0) {
statusTimeout = setTimeout(() => {
connectionStatus = isConnected ? "connected" : "disconnected";
@@ -469,7 +501,9 @@ export async function runTui(opts: TuiOptions) {
const { openOverlay, closeOverlay } = createOverlayHandlers(tui, editor);
const initialSessionAgentId = (() => {
if (!initialSessionInput) return null;
if (!initialSessionInput) {
return null;
}
const parsed = parseAgentSessionKey(initialSessionInput);
return parsed ? normalizeAgentId(parsed.agentId) : null;
})();
@@ -579,8 +613,12 @@ export async function runTui(opts: TuiOptions) {
};
client.onEvent = (evt) => {
if (evt.event === "chat") handleChatEvent(evt.payload);
if (evt.event === "agent") handleAgentEvent(evt.payload);
if (evt.event === "chat") {
handleChatEvent(evt.payload);
}
if (evt.event === "agent") {
handleAgentEvent(evt.payload);
}
};
client.onConnected = () => {