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:
@@ -308,7 +308,7 @@ function HostPickerTrigger({
|
|||||||
const pressableStyle = useCallback(
|
const pressableStyle = useCallback(
|
||||||
({ hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => [
|
({ hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => [
|
||||||
styles.hostTrigger,
|
styles.hostTrigger,
|
||||||
Boolean(hovered) && styles.hostTriggerHovered,
|
hovered && styles.hostTriggerHovered,
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ function AutocompleteRow({
|
|||||||
const pressableStyle = useCallback(
|
const pressableStyle = useCallback(
|
||||||
({ hovered = false, pressed }: PressableStateCallbackType & { hovered?: boolean }) => [
|
({ hovered = false, pressed }: PressableStateCallbackType & { hovered?: boolean }) => [
|
||||||
styles.item,
|
styles.item,
|
||||||
(Boolean(hovered) || pressed || isSelected) && styles.itemActive,
|
(hovered || pressed || isSelected) && styles.itemActive,
|
||||||
],
|
],
|
||||||
[isSelected],
|
[isSelected],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ export function DropdownMenuTrigger({
|
|||||||
const pressableStyle = useCallback(
|
const pressableStyle = useCallback(
|
||||||
({ pressed, hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => {
|
({ pressed, hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => {
|
||||||
if (typeof style === "function") {
|
if (typeof style === "function") {
|
||||||
return style({ pressed, hovered: Boolean(hovered), open: ctx.open });
|
return style({ pressed, hovered, open: ctx.open });
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
},
|
},
|
||||||
@@ -324,7 +324,7 @@ export function DropdownMenuTrigger({
|
|||||||
|
|
||||||
const renderChildren = useCallback(
|
const renderChildren = useCallback(
|
||||||
({ pressed, hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => {
|
({ 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;
|
return typeof children === "function" ? children(state) : children;
|
||||||
},
|
},
|
||||||
[children, ctx.open],
|
[children, ctx.open],
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export function useAgentHistory(options: {
|
|||||||
isLoading,
|
isLoading,
|
||||||
isInitialLoad,
|
isInitialLoad,
|
||||||
isRevalidating,
|
isRevalidating,
|
||||||
hasMore: Boolean(hasNextPage),
|
hasMore: hasNextPage,
|
||||||
isLoadingMore: isFetchingNextPage,
|
isLoadingMore: isFetchingNextPage,
|
||||||
refreshAll,
|
refreshAll,
|
||||||
loadMore,
|
loadMore,
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ function isAgentArchiving(input: IsAgentArchivingInput): boolean {
|
|||||||
if (!key) {
|
if (!key) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Boolean(readPendingState(input.queryClient)[key]);
|
return readPendingState(input.queryClient)[key] ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAgentFromListPayload<T extends AgentsListQueryData | undefined>(
|
function removeAgentFromListPayload<T extends AgentsListQueryData | undefined>(
|
||||||
@@ -420,7 +420,7 @@ export function useArchiveAgent() {
|
|||||||
if (!key) {
|
if (!key) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Boolean((pendingQuery.data ?? {})[key]);
|
return (pendingQuery.data ?? {})[key] ?? false;
|
||||||
},
|
},
|
||||||
[pendingQuery.data],
|
[pendingQuery.data],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,17 +7,17 @@ export interface PaneContextValue {
|
|||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
tabId: string;
|
tabId: string;
|
||||||
target: WorkspaceTabTarget;
|
target: WorkspaceTabTarget;
|
||||||
openTab(target: WorkspaceTabTarget): void;
|
openTab: (target: WorkspaceTabTarget) => void;
|
||||||
closeCurrentTab(): void;
|
closeCurrentTab: () => void;
|
||||||
retargetCurrentTab(target: WorkspaceTabTarget): void;
|
retargetCurrentTab: (target: WorkspaceTabTarget) => void;
|
||||||
openFileInWorkspace(filePath: string): void;
|
openFileInWorkspace: (filePath: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaneFocusContextValue {
|
export interface PaneFocusContextValue {
|
||||||
isWorkspaceFocused: boolean;
|
isWorkspaceFocused: boolean;
|
||||||
isPaneFocused: boolean;
|
isPaneFocused: boolean;
|
||||||
isInteractive: boolean;
|
isInteractive: boolean;
|
||||||
focusPane(): void;
|
focusPane: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PaneContext = createContext<PaneContextValue | null>(null);
|
const PaneContext = createContext<PaneContextValue | null>(null);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ async function showDesktopConfirmDialog(input: ConfirmDialogInput): Promise<bool
|
|||||||
const desktopAsk = desktopApi.dialog?.ask;
|
const desktopAsk = desktopApi.dialog?.ask;
|
||||||
|
|
||||||
if (typeof desktopAsk === "function") {
|
if (typeof desktopAsk === "function") {
|
||||||
return Boolean(await desktopAsk(input.message, options));
|
return await desktopAsk(input.message, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export function getWorkspaceExecutionAuthority(
|
|||||||
reason: "workspace_missing",
|
reason: "workspace_missing",
|
||||||
message:
|
message:
|
||||||
"workspaces" in input
|
"workspaces" in input
|
||||||
? `Workspace not found: ${String(input.workspaceId ?? "")}`
|
? `Workspace not found: ${input.workspaceId ?? ""}`
|
||||||
: "Workspace not found.",
|
: "Workspace not found.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ function fetchAfter(ctx: FetchContext): AgentTimelineFetchResult {
|
|||||||
gap: false,
|
gap: false,
|
||||||
window,
|
window,
|
||||||
hasOlder: selected[0].seq > minSeq,
|
hasOlder: selected[0].seq > minSeq,
|
||||||
hasNewer: Boolean(lastSelected && lastSelected.seq < maxSeq),
|
hasNewer: lastSelected !== null && lastSelected !== undefined && lastSelected.seq < maxSeq,
|
||||||
rows: selected.map(cloneRow),
|
rows: selected.map(cloneRow),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ export type ProviderFinalTextReducer = (params: {
|
|||||||
}) => string;
|
}) => string;
|
||||||
|
|
||||||
export interface ProviderTurnRunner {
|
export interface ProviderTurnRunner {
|
||||||
startTurn(prompt: AgentPromptInput, options?: AgentRunOptions): Promise<{ turnId: string }>;
|
startTurn: (prompt: AgentPromptInput, options?: AgentRunOptions) => Promise<{ turnId: string }>;
|
||||||
subscribe(callback: (event: AgentStreamEvent) => void): () => void;
|
subscribe: (callback: (event: AgentStreamEvent) => void) => () => void;
|
||||||
getSessionId(): string | Promise<string>;
|
getSessionId: () => string | Promise<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RunProviderTurnOptions extends ProviderTurnRunner {
|
export interface RunProviderTurnOptions extends ProviderTurnRunner {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ function parseBooleanEnv(value: string | undefined): boolean | undefined {
|
|||||||
function shouldPrintPairingQr(): boolean {
|
function shouldPrintPairingQr(): boolean {
|
||||||
const env = parseBooleanEnv(process.env.PASEO_PAIRING_QR);
|
const env = parseBooleanEnv(process.env.PASEO_PAIRING_QR);
|
||||||
if (env !== undefined) return env;
|
if (env !== undefined) return env;
|
||||||
return Boolean(process.stdout.isTTY);
|
return process.stdout.isTTY ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function renderPairingQr(url: string): Promise<string> {
|
export async function renderPairingQr(url: string): Promise<string> {
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ export class SherpaRealtimeTranscriptionSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rawResult = this.engine.recognizer.getResult(this.stream);
|
const rawResult = this.engine.recognizer.getResult(this.stream);
|
||||||
const text = String(
|
const text = (
|
||||||
(typeof rawResult === "object" && rawResult && "text" in rawResult
|
(typeof rawResult === "object" && rawResult && "text" in rawResult
|
||||||
? rawResult.text
|
? rawResult.text
|
||||||
: undefined) ?? "",
|
: undefined) ?? ""
|
||||||
).trim();
|
).trim();
|
||||||
if (text !== this.lastPartialText) {
|
if (text !== this.lastPartialText) {
|
||||||
this.lastPartialText = text;
|
this.lastPartialText = text;
|
||||||
@@ -97,10 +97,10 @@ export class SherpaRealtimeTranscriptionSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rawFinal = this.engine.recognizer.getResult(this.stream);
|
const rawFinal = this.engine.recognizer.getResult(this.stream);
|
||||||
const finalText = String(
|
const finalText = (
|
||||||
(typeof rawFinal === "object" && rawFinal && "text" in rawFinal
|
(typeof rawFinal === "object" && rawFinal && "text" in rawFinal
|
||||||
? rawFinal.text
|
? rawFinal.text
|
||||||
: undefined) ?? "",
|
: undefined) ?? ""
|
||||||
).trim();
|
).trim();
|
||||||
const segmentId = this.currentSegmentId;
|
const segmentId = this.currentSegmentId;
|
||||||
const previousSegmentId = this.previousSegmentId;
|
const previousSegmentId = this.previousSegmentId;
|
||||||
|
|||||||
@@ -165,10 +165,10 @@ export class SherpaOnnxSTT implements SpeechToTextProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rawResult = this.engine.recognizer.getResult(stream);
|
const rawResult = this.engine.recognizer.getResult(stream);
|
||||||
const text = String(
|
const text = (
|
||||||
(typeof rawResult === "object" && rawResult && "text" in rawResult
|
(typeof rawResult === "object" && rawResult && "text" in rawResult
|
||||||
? rawResult.text
|
? rawResult.text
|
||||||
: undefined) ?? "",
|
: undefined) ?? ""
|
||||||
).trim();
|
).trim();
|
||||||
const duration = Date.now() - start;
|
const duration = Date.now() - start;
|
||||||
this.logger.debug({ duration, textLength: text.length }, "Sherpa transcription complete");
|
this.logger.debug({ duration, textLength: text.length }, "Sherpa transcription complete");
|
||||||
|
|||||||
@@ -662,7 +662,7 @@ export async function runWorktreeSetupInBackground(
|
|||||||
let setupResults: WorktreeSetupCommandResult[] = [];
|
let setupResults: WorktreeSetupCommandResult[] = [];
|
||||||
let setupStarted = false;
|
let setupStarted = false;
|
||||||
const progressAccumulator = createWorktreeSetupProgressAccumulator();
|
const progressAccumulator = createWorktreeSetupProgressAccumulator();
|
||||||
const workspaceId = String(options.workspaceId);
|
const workspaceId = options.workspaceId;
|
||||||
|
|
||||||
const emitSetupProgress = (status: "running" | "completed" | "failed", error: string | null) => {
|
const emitSetupProgress = (status: "running" | "completed" | "failed", error: string | null) => {
|
||||||
const snapshot: WorkspaceSetupSnapshot = {
|
const snapshot: WorkspaceSetupSnapshot = {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export function signalProcessTree(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(options.kill ?? process.kill)(-pid, signal);
|
(options.kill ?? process.kill.bind(process))(-pid, signal);
|
||||||
return;
|
return;
|
||||||
} catch {
|
} catch {
|
||||||
// Fall back to the direct child when no separate process group exists.
|
// Fall back to the direct child when no separate process group exists.
|
||||||
|
|||||||
Reference in New Issue
Block a user