From 2e87e127743b04cd2c5e125d30d8c1787cdc66c3 Mon Sep 17 00:00:00 2001 From: 777genius Date: Tue, 21 Apr 2026 19:02:15 +0300 Subject: [PATCH] fix(ci): satisfy runtime catalog lint gate --- .../domain/normalizeCodexAppServerModel.ts | 22 +++++++--- .../services/team/ReviewApplierService.ts | 40 +++++++++++-------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/features/codex-model-catalog/core/domain/normalizeCodexAppServerModel.ts b/src/features/codex-model-catalog/core/domain/normalizeCodexAppServerModel.ts index 075c81e4..ab7e50b3 100644 --- a/src/features/codex-model-catalog/core/domain/normalizeCodexAppServerModel.ts +++ b/src/features/codex-model-catalog/core/domain/normalizeCodexAppServerModel.ts @@ -1,15 +1,27 @@ -import { normalizeCodexReasoningEffort, CODEX_REASONING_EFFORTS } from './codexReasoningEffort'; +import { CODEX_REASONING_EFFORTS, normalizeCodexReasoningEffort } from './codexReasoningEffort'; -import type { CodexAppServerModel } from '@main/services/infrastructure/codexAppServer'; import type { CliProviderModelCatalogItem, CliProviderReasoningEffort } from '@shared/types'; +export interface CodexAppServerModelLike { + id?: string; + model?: string; + displayName?: string; + hidden?: boolean; + supportedReasoningEfforts?: unknown[]; + defaultReasoningEffort?: unknown; + inputModalities?: unknown; + supportsPersonality?: boolean; + isDefault?: boolean; + upgrade?: unknown; +} + export interface NormalizedCodexModelCatalogResult { models: CliProviderModelCatalogItem[]; defaultModelId: string | null; diagnostics: string[]; } -function normalizeModelId(model: CodexAppServerModel): string | null { +function normalizeModelId(model: CodexAppServerModelLike): string | null { const id = model.id?.trim() || model.model?.trim() || null; return id && id.length > 0 ? id : null; } @@ -26,7 +38,7 @@ function normalizeEffortOption(option: unknown): CliProviderReasoningEffort | nu return null; } -function normalizeEfforts(model: CodexAppServerModel): CliProviderReasoningEffort[] { +function normalizeEfforts(model: CodexAppServerModelLike): CliProviderReasoningEffort[] { const efforts = model.supportedReasoningEfforts?.flatMap((option) => { const normalized = normalizeEffortOption(option); return normalized ? [normalized] : []; @@ -82,7 +94,7 @@ function asBadgeLabel(modelId: string): string { } export function normalizeCodexAppServerModels( - models: readonly CodexAppServerModel[] | undefined, + models: readonly CodexAppServerModelLike[] | undefined, options: { includeHidden?: boolean; } = {} diff --git a/src/main/services/team/ReviewApplierService.ts b/src/main/services/team/ReviewApplierService.ts index 95fe585c..86050daf 100644 --- a/src/main/services/team/ReviewApplierService.ts +++ b/src/main/services/team/ReviewApplierService.ts @@ -27,6 +27,15 @@ type LedgerApplyOutcome = | { handled: true; status: 'applied' | 'skipped' } | { handled: true; status: 'conflict' | 'error'; error: string; code: ApplyErrorCode }; +type CurrentTextReadResult = + | { missing: true; content: '' } + | { missing: false; content: string } + | { missing: false; content: ''; error: string }; + +function getCurrentTextReadError(result: CurrentTextReadResult): string | null { + return 'error' in result ? result.error : null; +} + /** * Service for applying reject decisions from code review. * @@ -518,12 +527,13 @@ export class ReviewApplierService { if (current.missing) { return { handled: true, status: 'applied' }; } - if (current.error) { + const currentError = getCurrentTextReadError(current); + if (currentError) { return { handled: true, status: 'error', code: 'io-error', - error: current.error, + error: currentError, }; } if (!afterHash) { @@ -570,12 +580,13 @@ export class ReviewApplierService { } const current = await this.readCurrentText(filePath); if (!current.missing) { + const currentError = getCurrentTextReadError(current); return { handled: true, status: 'conflict', code: 'conflict', error: - current.error || 'File exists on disk; refusing to overwrite while rejecting delete.', + currentError || 'File exists on disk; refusing to overwrite while rejecting delete.', }; } try { @@ -672,12 +683,13 @@ export class ReviewApplierService { const newCurrent = await this.readCurrentText(newFilePath); if (!newCurrent.missing) { - if (newCurrent.error) { + const newCurrentError = getCurrentTextReadError(newCurrent); + if (newCurrentError) { return { handled: true, status: 'error', code: 'io-error', - error: newCurrent.error, + error: newCurrentError, }; } if (this.hashText(newCurrent.content) !== newHash) { @@ -692,12 +704,13 @@ export class ReviewApplierService { const oldCurrent = await this.readCurrentText(oldFilePath); if (!oldCurrent.missing) { - if (oldCurrent.error) { + const oldCurrentError = getCurrentTextReadError(oldCurrent); + if (oldCurrentError) { return { handled: true, status: 'error', code: 'io-error', - error: oldCurrent.error, + error: oldCurrentError, }; } if (!oldHash || this.hashText(oldCurrent.content) !== oldHash) { @@ -781,14 +794,15 @@ export class ReviewApplierService { }, }; } - if (current.error) { + const currentError = getCurrentTextReadError(current); + if (currentError) { return { ok: false, outcome: { handled: true, status: 'error', code: 'io-error', - error: current.error, + error: currentError, }, }; } @@ -806,13 +820,7 @@ export class ReviewApplierService { return { ok: true }; } - private async readCurrentText( - filePath: string - ): Promise< - | { missing: true; content: ''; error?: undefined } - | { missing: false; content: string; error?: undefined } - | { missing: false; content: ''; error: string } - > { + private async readCurrentText(filePath: string): Promise { try { return { missing: false, content: await readFile(filePath, 'utf8') }; } catch (err) {