Skip to content

Self-improving AI Employees for everyone

fix(client): green the typecheck gate and clear the last lint warning

trohitga36dc5d00cfd
diff --git a/client/src/components/output/AudioPreview.tsx b/client/src/components/output/AudioPreview.tsx
index 61cc1499..0fbfa92d 100644
--- a/client/src/components/output/AudioPreview.tsx
+++ b/client/src/components/output/AudioPreview.tsx
@@ -1,33 +1,12 @@
import { useState } from 'react';
import { AlertCircle } from 'lucide-react';
import { buildApiUrl } from '../../config/api';
+import type { AudioRef } from '../../types/workspaceFiles';
-/**
- * An AudioRef as the backend serializes it (`services/media/refs.py`).
- * Deliberately has no bytes/base64 field — audio travels as a reference,
- * never as data. See `services/media/limits.py` for the measured reason.
- */
-export interface AudioRef {
- kind: 'audio';
- path: string;
- workflow_id?: string | null;
- filename: string;
- mime_type?: string;
- format?: string;
- size_bytes?: number;
- duration_seconds?: number | null;
- sample_rate?: number | null;
- channels?: number | null;
- sha256?: string | null;
- url?: string | null;
-}
-
-/** Structural check — cheaper and more honest than trusting a uiHint alone. */
-export const isAudioRef = (value: unknown): value is AudioRef =>
- !!value &&
- typeof value === 'object' &&
- (value as AudioRef).kind === 'audio' &&
- typeof (value as AudioRef).path === 'string';
+// `AudioRef` / `isAudioRef` live in types/workspaceFiles.ts alongside the
+// `WorkspaceFileRef` they narrow. Keeping the value export here made this
+// file export both a component and a non-component, which breaks Fast
+// Refresh (react-refresh/only-export-components).
const formatDuration = (seconds?: number | null): string | null => {
if (seconds == null || !Number.isFinite(seconds)) return null;
diff --git a/client/src/components/output/OutputPanel.tsx b/client/src/components/output/OutputPanel.tsx
index 5cd019fb..da3dc375 100644
--- a/client/src/components/output/OutputPanel.tsx
+++ b/client/src/components/output/OutputPanel.tsx
@@ -23,7 +23,8 @@ import { ExecutionResult } from '@/services/executionService';
import { useNodeSpec } from '@/lib/nodeSpec';
import { copyToClipboard, tryParseJson } from '@/utils/formatters';
import { cn } from '@/lib/utils';
-import AudioPreview, { AudioRef, isAudioRef } from './AudioPreview';
+import AudioPreview from './AudioPreview';
+import { type AudioRef, isAudioRef } from '@/types/workspaceFiles';
/** Extract output data from ExecutionResult. */
const getData = (r: ExecutionResult) =>
diff --git a/client/src/lib/workspaceUpload.ts b/client/src/lib/workspaceUpload.ts
index 01eda1f7..9ecdceea 100644
--- a/client/src/lib/workspaceUpload.ts
+++ b/client/src/lib/workspaceUpload.ts
@@ -1,5 +1,5 @@
import { buildApiUrl } from '../config/api';
-import type { AudioRef } from '../components/output/AudioPreview';
+import type { AudioRef } from '../types/workspaceFiles';
/**
* Mirrors `MEDIA_MAX_UPLOAD_BYTES` in `server/services/media/limits.py`.
diff --git a/client/src/types/workspaceFiles.ts b/client/src/types/workspaceFiles.ts
index d8428d92..109ff1af 100644
--- a/client/src/types/workspaceFiles.ts
+++ b/client/src/types/workspaceFiles.ts
@@ -57,8 +57,32 @@ export interface WorkspaceFileRef {
url?: string | null;
}
+/**
+ * A serialized `AudioRef` (`server/services/media/refs.py::AudioRef`) — a
+ * `FileRef` narrowed to a container that `inspect_audio` actually probed.
+ *
+ * `kind: 'audio'` is an assertion, not a guess: it means the duration and
+ * sample rate below were read off the file, so a per-second provider can be
+ * billed against them. Note the deliberate absence of any bytes/base64 field —
+ * audio travels as a reference. See `services/media/limits.py`.
+ */
+export interface AudioRef extends WorkspaceFileRef {
+ kind: 'audio';
+ format?: string;
+ duration_seconds?: number | null;
+ sample_rate?: number | null;
+ channels?: number | null;
+}
+
const KIND_SET: ReadonlySet<string> = new Set(FILE_REF_KINDS);
+/** Structural check — cheaper and more honest than trusting a uiHint alone. */
+export const isAudioRef = (value: unknown): value is AudioRef =>
+ !!value &&
+ typeof value === 'object' &&
+ (value as AudioRef).kind === 'audio' &&
+ typeof (value as AudioRef).path === 'string';
+
/**
* Structural check for "this parameter value is a file reference".
*
diff --git a/client/src/vite-env.d.ts b/client/src/vite-env.d.ts
index ae8e86db..1320ca78 100644
--- a/client/src/vite-env.d.ts
+++ b/client/src/vite-env.d.ts
@@ -1,11 +1,18 @@
/// <reference types="vite/client" />
/// <reference types="google.maps" />
+/// <reference types="node" />
// `google.maps` namespace is exposed via @types/google.maps. tsc 5.x
// auto-loads all @types/* packages, but tsgo (TypeScript 7 native
// preview) does not pick the namespace up reliably under pnpm's
// symlinked node_modules layout — the explicit reference here is the
// canonical fix per https://developers.google.com/maps/documentation/javascript/using-typescript
// and works for both compilers.
+//
+// `node` is here for the same tsgo reason, not because browser code may
+// use Node APIs. Node-only tests under src/ (icons/index.test.ts reads
+// server/nodes/**/meta.json off disk) need `node:fs` / `node:path` /
+// `__dirname`; without this the root TS7 gate fails on them while
+// client's own tsc 5.x passes, because 5.x auto-loads @types/node.
interface ImportMetaEnv {
readonly VITE_ANDROID_RELAY_URL: string;