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 16:27:22 +08:00
committed by GitHub
parent 340b0a48a3
commit 500d8b86f5
15 changed files with 27 additions and 27 deletions

View File

@@ -308,7 +308,7 @@ function HostPickerTrigger({
const pressableStyle = useCallback(
({ hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => [
styles.hostTrigger,
Boolean(hovered) && styles.hostTriggerHovered,
hovered && styles.hostTriggerHovered,
],
[],
);

View File

@@ -72,7 +72,7 @@ function AutocompleteRow({
const pressableStyle = useCallback(
({ hovered = false, pressed }: PressableStateCallbackType & { hovered?: boolean }) => [
styles.item,
(Boolean(hovered) || pressed || isSelected) && styles.itemActive,
(hovered || pressed || isSelected) && styles.itemActive,
],
[isSelected],
);

View File

@@ -315,7 +315,7 @@ export function DropdownMenuTrigger({
const pressableStyle = useCallback(
({ pressed, hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => {
if (typeof style === "function") {
return style({ pressed, hovered: Boolean(hovered), open: ctx.open });
return style({ pressed, hovered, open: ctx.open });
}
return style;
},
@@ -324,7 +324,7 @@ export function DropdownMenuTrigger({
const renderChildren = useCallback(
({ pressed, hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => {
const state: TriggerState = { pressed, hovered: Boolean(hovered), open: ctx.open };
const state: TriggerState = { pressed, hovered, open: ctx.open };
return typeof children === "function" ? children(state) : children;
},
[children, ctx.open],

View File

@@ -141,7 +141,7 @@ export function useAgentHistory(options: {
isLoading,
isInitialLoad,
isRevalidating,
hasMore: Boolean(hasNextPage),
hasMore: hasNextPage,
isLoadingMore: isFetchingNextPage,
refreshAll,
loadMore,

View File

@@ -100,7 +100,7 @@ function isAgentArchiving(input: IsAgentArchivingInput): boolean {
if (!key) {
return false;
}
return Boolean(readPendingState(input.queryClient)[key]);
return readPendingState(input.queryClient)[key] ?? false;
}
function removeAgentFromListPayload<T extends AgentsListQueryData | undefined>(
@@ -420,7 +420,7 @@ export function useArchiveAgent() {
if (!key) {
return false;
}
return Boolean((pendingQuery.data ?? {})[key]);
return (pendingQuery.data ?? {})[key] ?? false;
},
[pendingQuery.data],
);

View File

@@ -7,17 +7,17 @@ export interface PaneContextValue {
workspaceId: string;
tabId: string;
target: WorkspaceTabTarget;
openTab(target: WorkspaceTabTarget): void;
closeCurrentTab(): void;
retargetCurrentTab(target: WorkspaceTabTarget): void;
openFileInWorkspace(filePath: string): void;
openTab: (target: WorkspaceTabTarget) => void;
closeCurrentTab: () => void;
retargetCurrentTab: (target: WorkspaceTabTarget) => void;
openFileInWorkspace: (filePath: string) => void;
}
export interface PaneFocusContextValue {
isWorkspaceFocused: boolean;
isPaneFocused: boolean;
isInteractive: boolean;
focusPane(): void;
focusPane: () => void;
}
const PaneContext = createContext<PaneContextValue | null>(null);

View File

@@ -86,7 +86,7 @@ async function showDesktopConfirmDialog(input: ConfirmDialogInput): Promise<bool
const desktopAsk = desktopApi.dialog?.ask;
if (typeof desktopAsk === "function") {
return Boolean(await desktopAsk(input.message, options));
return await desktopAsk(input.message, options);
}
return null;

View File

@@ -112,7 +112,7 @@ export function getWorkspaceExecutionAuthority(
reason: "workspace_missing",
message:
"workspaces" in input
? `Workspace not found: ${String(input.workspaceId ?? "")}`
? `Workspace not found: ${input.workspaceId ?? ""}`
: "Workspace not found.",
};
}

View File

@@ -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),
};
}

View File

@@ -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 {

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> {

View File

@@ -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;

View File

@@ -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");

View File

@@ -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 = {

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.