refactor(typeaware): no-unnecessary-type-conversion + unbound-method sweep (T3.b partial) (#754)

* refactor: clear no-unnecessary-type-conversion + unbound-method (T3.b partial)

Fixes 15 files within the hard cap:

unbound-method (interface method shorthand → property function syntax):
- pane-context.tsx: PaneContextValue + PaneFocusContextValue (fixes agent-panel, browser-panel, draft-panel)
- provider-runner.ts: ProviderTurnRunner interface
- process-tree.ts: process.kill.bind(process)

no-unnecessary-type-conversion (remove redundant Boolean()/String() wraps):
- agent-timeline-store.ts, worktree-session.ts, pairing-qr.ts
- sherpa-realtime-session.ts, sherpa-stt.ts (String() → direct call chain)
- workspace-execution.ts, confirm-dialog.ts, use-archive-agent.ts
- use-agent-history.ts, left-sidebar.tsx, autocomplete.tsx, dropdown-menu.tsx

Deferred (9 errors across 7 files, all single-line Boolean(hovered) removals):
project-picker-modal.tsx, agent-list.tsx, branch-switcher.tsx,
file-explorer-pane.tsx, workspace-open-in-editor-button.tsx,
browser-pane.electron.tsx, sortable-inline-list.web.tsx

* fix(app): preserve Boolean coercion fallback in archive state lookups

readPendingState(...)[key] and (pendingQuery.data ?? {})[key] return
boolean | undefined at runtime — noUncheckedIndexedAccess is off so
TypeScript types this as boolean but the actual value can be undefined.
Add ?? false to maintain the explicit boolean return contract.
This commit is contained in:
Mohamed Boudra
2026-05-05 19:58:56 +07:00
parent 059d543c97
commit df5c59263e
15 changed files with 27 additions and 27 deletions
@@ -94,7 +94,7 @@ function fetchAfter(ctx: FetchContext): AgentTimelineFetchResult {
gap: false,
window,
hasOlder: selected[0].seq > minSeq,
hasNewer: Boolean(lastSelected && lastSelected.seq < maxSeq),
hasNewer: lastSelected !== null && lastSelected !== undefined && lastSelected.seq < maxSeq,
rows: selected.map(cloneRow),
};
}
@@ -12,9 +12,9 @@ export type ProviderFinalTextReducer = (params: {
}) => string;
export interface ProviderTurnRunner {
startTurn(prompt: AgentPromptInput, options?: AgentRunOptions): Promise<{ turnId: string }>;
subscribe(callback: (event: AgentStreamEvent) => void): () => void;
getSessionId(): string | Promise<string>;
startTurn: (prompt: AgentPromptInput, options?: AgentRunOptions) => Promise<{ turnId: string }>;
subscribe: (callback: (event: AgentStreamEvent) => void) => () => void;
getSessionId: () => string | Promise<string>;
}
export interface RunProviderTurnOptions extends ProviderTurnRunner {
+1 -1
View File
@@ -13,7 +13,7 @@ function parseBooleanEnv(value: string | undefined): boolean | undefined {
function shouldPrintPairingQr(): boolean {
const env = parseBooleanEnv(process.env.PASEO_PAIRING_QR);
if (env !== undefined) return env;
return Boolean(process.stdout.isTTY);
return process.stdout.isTTY ?? false;
}
export async function renderPairingQr(url: string): Promise<string> {
@@ -59,10 +59,10 @@ export class SherpaRealtimeTranscriptionSession
}
const rawResult = this.engine.recognizer.getResult(this.stream);
const text = String(
const text = (
(typeof rawResult === "object" && rawResult && "text" in rawResult
? rawResult.text
: undefined) ?? "",
: undefined) ?? ""
).trim();
if (text !== this.lastPartialText) {
this.lastPartialText = text;
@@ -97,10 +97,10 @@ export class SherpaRealtimeTranscriptionSession
}
const rawFinal = this.engine.recognizer.getResult(this.stream);
const finalText = String(
const finalText = (
(typeof rawFinal === "object" && rawFinal && "text" in rawFinal
? rawFinal.text
: undefined) ?? "",
: undefined) ?? ""
).trim();
const segmentId = this.currentSegmentId;
const previousSegmentId = this.previousSegmentId;
@@ -165,10 +165,10 @@ export class SherpaOnnxSTT implements SpeechToTextProvider {
}
const rawResult = this.engine.recognizer.getResult(stream);
const text = String(
const text = (
(typeof rawResult === "object" && rawResult && "text" in rawResult
? rawResult.text
: undefined) ?? "",
: undefined) ?? ""
).trim();
const duration = Date.now() - start;
this.logger.debug({ duration, textLength: text.length }, "Sherpa transcription complete");
@@ -662,7 +662,7 @@ export async function runWorktreeSetupInBackground(
let setupResults: WorktreeSetupCommandResult[] = [];
let setupStarted = false;
const progressAccumulator = createWorktreeSetupProgressAccumulator();
const workspaceId = String(options.workspaceId);
const workspaceId = options.workspaceId;
const emitSetupProgress = (status: "running" | "completed" | "failed", error: string | null) => {
const snapshot: WorkspaceSetupSnapshot = {
+1 -1
View File
@@ -75,7 +75,7 @@ export function signalProcessTree(
}
try {
(options.kill ?? process.kill)(-pid, signal);
(options.kill ?? process.kill.bind(process))(-pid, signal);
return;
} catch {
// Fall back to the direct child when no separate process group exists.