diff --git a/src/approvals/model.ts b/src/approvals/model.ts index 7a360fc4..47885c62 100644 --- a/src/approvals/model.ts +++ b/src/approvals/model.ts @@ -133,9 +133,9 @@ function approvalSummaryParts(approval: PendingApproval): ApprovalSummaryParts { return summaryParts(reason, null, fallback); } -export function approvalDetails(approval: PendingApproval): Array<{ key: string; value: string }> { +export function approvalDetails(approval: PendingApproval): { key: string; value: string }[] { const params = approval.params as Record; - const rows: Array<{ key: string; value: string }> = []; + const rows: { key: string; value: string }[] = []; addOptional(rows, "reason", params.reason); addOptional(rows, "command", Array.isArray(params.command) ? params.command.join(" ") : params.command); addOptional(rows, "cwd", params.cwd); diff --git a/src/approvals/permission-details.ts b/src/approvals/permission-details.ts index e7130f7a..41a73817 100644 --- a/src/approvals/permission-details.ts +++ b/src/approvals/permission-details.ts @@ -14,7 +14,7 @@ export function permissionRows(value: unknown): DetailRow[] { const fileSystem = permissions.fileSystem as { read?: unknown; write?: unknown; - entries?: Array<{ path?: unknown; access?: unknown }>; + entries?: { path?: unknown; access?: unknown }[]; globScanMaxDepth?: unknown; } | null; if (!fileSystem || typeof fileSystem !== "object") return rows; diff --git a/src/composer/slash-commands.ts b/src/composer/slash-commands.ts index 526224b4..b3f0e48c 100644 --- a/src/composer/slash-commands.ts +++ b/src/composer/slash-commands.ts @@ -25,6 +25,6 @@ export function slashCommandHelpLines(): string[] { return SLASH_COMMANDS.map((item) => `${item.command} - ${item.detail}`); } -export function slashCommandHelpRows(): Array<{ key: string; value: string }> { +export function slashCommandHelpRows(): { key: string; value: string }[] { return SLASH_COMMANDS.map((item) => ({ key: item.command, value: item.detail })); } diff --git a/src/display/review.ts b/src/display/review.ts index e493a36e..1b85f771 100644 --- a/src/display/review.ts +++ b/src/display/review.ts @@ -59,7 +59,7 @@ export function createAutoReviewResultItem(params: AutoReviewNotification): Disp function parseAutomaticApprovalReviewMessage( text: string, -): { status: string; summary: string; rows: Array<{ key: string; value: string }> } | null { +): { status: string; summary: string; rows: { key: string; value: string }[] } | null { const match = /^Automatic approval review\s+([a-zA-Z][\w-]*)(?:\s+\(([^)]*)\))?:\s*(.+)$/i.exec(text.trim()); if (!match) return null; diff --git a/src/display/thread-items.ts b/src/display/thread-items.ts index 2537e365..2fb5aea2 100644 --- a/src/display/thread-items.ts +++ b/src/display/thread-items.ts @@ -419,7 +419,7 @@ function webSearchQueryList( } function webSearchDetails(item: WebSearchItem): DisplayDetailSection[] { - const rows: Array<{ key: string; value: string }> = []; + const rows: { key: string; value: string }[] = []; if (item.action) rows.push({ key: "action", value: webSearchActionLabel(item.action.type) }); if (item.action?.type === "search") { const queries = webSearchQueryList(item.action.query, item.action.queries, item.query); diff --git a/src/display/tool-format.ts b/src/display/tool-format.ts index c8bc1c62..0626fffc 100644 --- a/src/display/tool-format.ts +++ b/src/display/tool-format.ts @@ -33,7 +33,7 @@ export function jsonDetail(title: string, value: unknown): DisplayDetailSection[ return value === null || value === undefined ? [] : [{ title, body: jsonPreview(value) }]; } -export function jsonDetails(entries: Array<[title: string, value: unknown]>): DisplayDetailSection[] { +export function jsonDetails(entries: [title: string, value: unknown][]): DisplayDetailSection[] { return entries.flatMap(([title, value]) => jsonDetail(title, value)); } diff --git a/src/display/tool-view.ts b/src/display/tool-view.ts index e9843581..ce0f1312 100644 --- a/src/display/tool-view.ts +++ b/src/display/tool-view.ts @@ -20,7 +20,7 @@ export type ToolResultDisplayItem = | ReviewResultDisplayItem; export type ToolResultDetailSection = - | { kind: "meta"; title?: string; rows: Array<{ key: string; value: string }> } + | { kind: "meta"; title?: string; rows: { key: string; value: string }[] } | { kind: "output"; title: string; body: string } | { kind: "diff"; title: string; diff: string }; @@ -159,7 +159,7 @@ function outputSection(title: string, body: string | null | undefined): ToolResu return body ? [{ kind: "output", title, body }] : []; } -function fileChangeSummary(item: DisplayItem, changes: Array): string { +function fileChangeSummary(item: DisplayItem, changes: (DisplayFileChange & { displayPath: string })[]): string { if (item.kind !== "fileChange") return item.text; if (changes.length === 0) return item.text; if (changes.length > 1) return item.text; diff --git a/src/runtime/view.ts b/src/runtime/view.ts index fed0fdc1..940f177e 100644 --- a/src/runtime/view.ts +++ b/src/runtime/view.ts @@ -41,7 +41,7 @@ export interface RateLimitSummaryRow { export interface EffectiveConfigSection { title: string; - rows: Array<{ key: string; value: string }>; + rows: { key: string; value: string }[]; } export function contextSummary(snapshot: RuntimeSnapshot): ContextSummary | null { diff --git a/src/ui/tool-result.ts b/src/ui/tool-result.ts index 982cfc5f..5a3a45dc 100644 --- a/src/ui/tool-result.ts +++ b/src/ui/tool-result.ts @@ -75,7 +75,7 @@ function renderDetailSection(parent: HTMLElement, section: ToolResultDetailSecti renderOutputBlock(parent, section.title, section.body); } -function renderMetaBlock(parent: HTMLElement, title: string | undefined, rows: Array<{ key: string; value: string }>): void { +function renderMetaBlock(parent: HTMLElement, title: string | undefined, rows: { key: string; value: string }[]): void { const section = title ? renderOutputSection(parent, title, "codex-panel__output codex-panel__output--meta") : parent; const meta = section.createEl("dl", { cls: "codex-panel__meta-grid" }); for (const row of rows) { diff --git a/tests/approvals/approvals.test.ts b/tests/approvals/approvals.test.ts index 90fe49de..bee630d1 100644 --- a/tests/approvals/approvals.test.ts +++ b/tests/approvals/approvals.test.ts @@ -185,7 +185,7 @@ describe("approval model", () => { }); it("builds action responses for current approval families", () => { - const requests: Array<{ request: ServerRequest; acceptSession: unknown; cancel: unknown }> = [ + const requests: { request: ServerRequest; acceptSession: unknown; cancel: unknown }[] = [ { request: { id: 3, diff --git a/tests/composer/obsidian-context.test.ts b/tests/composer/obsidian-context.test.ts index 97bcb0b4..f6bfc859 100644 --- a/tests/composer/obsidian-context.test.ts +++ b/tests/composer/obsidian-context.test.ts @@ -57,7 +57,7 @@ function appFixture(options: { activePath?: string; linkDestination?: TFile | null; getFirstLinkpathDest?: (target: string, sourcePath: string) => TFile | null; - markdownFiles?: Array<{ basename: string; path: string; stat: { mtime: number } }>; + markdownFiles?: { basename: string; path: string; stat: { mtime: number } }[]; abstractFiles?: Map; }): App { return { diff --git a/tests/panel/thread-naming.test.ts b/tests/panel/thread-naming.test.ts index 70cf8b59..9bb68047 100644 --- a/tests/panel/thread-naming.test.ts +++ b/tests/panel/thread-naming.test.ts @@ -67,7 +67,7 @@ describe("thread naming", () => { }); it("scans older thread pages until it finds a usable naming context", async () => { - const calls: Array<{ cursor: string | null; limit: number; sortDirection: string }> = []; + const calls: { cursor: string | null; limit: number; sortDirection: string }[] = []; const context = await findThreadNamingContext({ threadId: "thread", pageLimit: 2, diff --git a/tests/ui/dom-test-helpers.ts b/tests/ui/dom-test-helpers.ts index f859560a..41f05188 100644 --- a/tests/ui/dom-test-helpers.ts +++ b/tests/ui/dom-test-helpers.ts @@ -90,7 +90,13 @@ export function installObsidianDomShims(): void { }); } -export function topLevelDetailsSummaries(element: HTMLElement): Array { +function nodeConstructor(): typeof Node { + const defaultView = document.defaultView; + if (defaultView === null) throw new Error("Expected document.defaultView to install Obsidian DOM helpers."); + return (globalThis as typeof globalThis & { Node?: typeof Node }).Node ?? defaultView.Node; +} + +export function topLevelDetailsSummaries(element: HTMLElement): (string | null)[] { const candidates = [element, ...element.children]; return candidates .filter((child): child is HTMLDetailsElement => child instanceof HTMLDetailsElement)