Skip to content

Commit 09c626f

Browse files
committed
chore(cleanup): remove all unused exports flagged by knip
knip reported 25 unused exports + 4 unused types (dead code from earlier stream-journal and third-party work); CI's knip step fails on them. - server: drop export keyword from internally-used helpers (streamJobStore getJob/createJob/appendChunk/flushToResponse/ attachJobStream, geminiProxy GEMINI_UPSTREAM_BASE_HEADER, mcpClient McpClientBridgeOptions, imageProxyFetch constants/type) - delete fully-unreferenced code: ThemeIcons.tsx (4 icons) + its index export, designTokens TYPE_* classes, runtimeConfig isThirdPartyProxyRelativePath, geminiApiBaseUrl resolveGeminiFrontendBaseUrl, liveArtifactsMode isLiveArtifactsModeActive, thirdPartyApiProviders getThirdPartyProviderModels/ModelId/ updateActiveThirdPartyProviderConfig, ModelIcon THIRD_PARTY_PROVIDER_ICON_COLOR - drop export from internally-used symbols: modelConfiguration REMOVED_MODEL_ID_MIGRATIONS, chatStoreSync SESSION_LOADING_STALE_CHECK_MS, chat-input/focus FocusChatInputOptions, lastActiveSession LastActiveSessionSnapshot knip now exits 0; all 2057 tests, typecheck, lint, format and both builds pass.
1 parent ab39c82 commit 09c626f

16 files changed

Lines changed: 15 additions & 221 deletions

File tree

server/src/geminiProxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { maybeStreamWithJob } from './streamJobs.js';
77
import { isPrivateNetworkHostname } from '../../shared/privateNetwork.js';
88

99
export const GEMINI_PROXY_PREFIX = '/api/gemini';
10-
export const GEMINI_UPSTREAM_BASE_HEADER = 'x-gemini-upstream-base-url';
10+
const GEMINI_UPSTREAM_BASE_HEADER = 'x-gemini-upstream-base-url';
1111

1212
const HOP_BY_HOP_HEADERS = new Set([
1313
'connection',

server/src/mcpClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const APP_VERSION = (() => {
3030
}
3131
})();
3232

33-
export interface McpClientBridgeOptions {
33+
interface McpClientBridgeOptions {
3434
allowPrivateHttp?: boolean;
3535
fetchImpl?: FetchLike;
3636
/** Override idle eviction for tests. */

server/src/streamJobStore.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ sweeper.unref();
6565

6666
// ── CRUD ────────────────────────────────────────────────────────────────────
6767

68-
export const getJob = (id: string): StreamJob | undefined => jobs.get(id);
68+
const getJob = (id: string): StreamJob | undefined => jobs.get(id);
6969

70-
export const createJob = (id: string): StreamJob => {
70+
const createJob = (id: string): StreamJob => {
7171
const job: StreamJob = {
7272
id,
7373
firstSeq: 1,
@@ -83,7 +83,7 @@ export const createJob = (id: string): StreamJob => {
8383
return job;
8484
};
8585

86-
export const appendChunk = (job: StreamJob, data: string): void => {
86+
const appendChunk = (job: StreamJob, data: string): void => {
8787
const seq = job.firstSeq + job.chunks.length;
8888
job.chunks.push({ seq, data });
8989
job.updatedAt = Date.now();
@@ -184,7 +184,7 @@ export function pumpUpstreamBodyIntoJob(job: StreamJob, upstreamResponse: Respon
184184
* onward. Each call drains everything currently buffered. When the job is
185185
* done, the response is closed. Returns the new cursor.
186186
*/
187-
export function flushToResponse(job: StreamJob, response: ServerResponse, cursor: number): number {
187+
function flushToResponse(job: StreamJob, response: ServerResponse, cursor: number): number {
188188
let nextCursor = cursor;
189189
for (const chunk of job.chunks) {
190190
if (chunk.seq > nextCursor && chunk.seq >= job.firstSeq) {
@@ -247,7 +247,7 @@ export async function maybeStreamWithSharedJob(
247247
* (for a new job) started the upstream fetch; this function only manages the
248248
* browser-side subscription. Returns true when handled.
249249
*/
250-
export async function attachJobStream(
250+
async function attachJobStream(
251251
request: IncomingMessage,
252252
response: ServerResponse,
253253
config: AttachJobStreamConfig,

shared/imageProxyFetch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { assertImageProxyHostResolvesPublic, type ImageProxyDnsLookup } from './
22
import { isPrivateNetworkHostname } from './privateNetwork.js';
33

44
/** Max redirects followed while re-validating each hop (CDN signed URLs often 302 once). */
5-
export const IMAGE_PROXY_MAX_REDIRECTS = 3;
5+
const IMAGE_PROXY_MAX_REDIRECTS = 3;
66

7-
export const IMAGE_PROXY_REQUEST_HEADERS = {
7+
const IMAGE_PROXY_REQUEST_HEADERS = {
88
accept: 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8',
99
'user-agent': 'AMC-WebUI image proxy',
1010
} as const;
@@ -24,7 +24,7 @@ export const isUnsafeImageProxyRedirect = (redirectUrl: URL): boolean => {
2424
}
2525
};
2626

27-
export type ImageProxyFetchResult =
27+
type ImageProxyFetchResult =
2828
| { ok: true; response: Response }
2929
| { ok: false; kind: 'unsafe_redirect' }
3030
| { ok: false; kind: 'blocked'; message: string }

src/components/icons/groups/ThemeIcons.tsx

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/components/icons/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './groups/SettingsIcons';
2-
export * from './groups/ThemeIcons';
32
export * from './groups/AttachmentIcons';
43
export * from './groups/GeneralIcons';
54
export * from './groups/LanguageIcons';

src/components/shared/ModelIcon.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ const THIRD_PARTY_PROVIDER_LOGO: Record<ThirdPartyProviderId, string> = {
2929
custom: customLogoUrl,
3030
};
3131

32-
const THIRD_PARTY_PROVIDER_ICON_COLOR: Partial<Record<ThirdPartyProviderId, string>> = {
33-
openai: 'text-emerald-500 dark:text-emerald-400',
34-
deepseek: 'text-blue-500 dark:text-blue-400',
35-
anthropic: 'text-orange-500 dark:text-orange-400',
36-
openrouter: 'text-fuchsia-500 dark:text-fuchsia-400',
37-
qwen: 'text-violet-500 dark:text-violet-400',
38-
kimi: 'text-cyan-500 dark:text-cyan-400',
39-
glm: 'text-rose-500 dark:text-rose-400',
40-
custom: 'text-slate-500 dark:text-slate-400',
41-
};
42-
4332
type ModelBrandIconKey = 'gemini' | 'gemma' | 'nanobanana';
4433

4534
const BRAND_ICON_SRC: Record<ModelBrandIconKey, string> = {
@@ -141,4 +130,4 @@ export const getModelIcon = (model: ModelOption | undefined) => {
141130
);
142131
};
143132

144-
export { THIRD_PARTY_PROVIDER_LOGO, THIRD_PARTY_PROVIDER_ICON_COLOR };
133+
export { THIRD_PARTY_PROVIDER_LOGO };

src/constants/designTokens.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,6 @@
33
* Prefer these over ad-hoc radius / chip classes so composer, sidebar, and chips stay aligned.
44
*/
55

6-
/** Caption / meta line — minimum practical UI size (12px at default root). */
7-
export const TYPE_CAPTION_CLASS = 'text-xs leading-tight';
8-
9-
/** Dense mono meta (ids, timestamps) — same floor as caption. */
10-
export const TYPE_CAPTION_MONO_CLASS = 'text-xs font-mono leading-tight tabular-nums';
11-
12-
/** Section overline labels (uppercase groups, code headers). Prefer secondary for contrast. */
13-
export const TYPE_OVERLINE_CLASS = 'text-xs font-bold uppercase tracking-wider text-[var(--theme-text-secondary)]';
14-
15-
/** Muted overline when hierarchy needs more de-emphasis than TYPE_OVERLINE_CLASS. */
16-
export const TYPE_OVERLINE_MUTED_CLASS = 'text-xs font-bold uppercase tracking-wider text-[var(--theme-text-tertiary)]';
17-
186
const RADIUS_CLASS = {
197
/** 6px — dense controls, inline badges */
208
sm: 'rounded-md',

src/constants/modelConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const MODELS_SUPPORTING_RAW_MODE = [
2222
];
2323

2424
/** Built-in model IDs removed from the app; remap saved settings to a supported replacement. */
25-
export const REMOVED_MODEL_ID_MIGRATIONS: Readonly<Record<string, string>> = {
25+
const REMOVED_MODEL_ID_MIGRATIONS: Readonly<Record<string, string>> = {
2626
'gemini-3.1-flash-lite': 'gemini-3.5-flash-lite',
2727
'models/gemini-3.1-flash-lite': 'gemini-3.5-flash-lite',
2828
// Exact IDs only — must not match gemini-3.5-flash-lite.

src/runtime/runtimeConfig.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,6 @@ export function getThirdPartyProxyBaseUrl(): string | null {
7474
return readNullableString(getRuntimeConfig()?.thirdPartyProxyUrl) ?? null;
7575
}
7676

77-
/**
78-
* Whether the deployment routes third-party (OpenAI-compatible / Anthropic)
79-
* requests through our own api container where the stream-journal lives. True
80-
* only when the Docker web container injected a relative third-party proxy URL
81-
* (e.g. "/api/openai"). False in static/Pages deploys where the browser calls
82-
* the upstream directly and journaling is impossible — there is no container
83-
* to buffer the upstream independent of the browser connection.
84-
*
85-
* This gates x-amc-job-id stamping and resume for third-party streams, the same
86-
* way isGeminiProxyRelativePath gates the Gemini path.
87-
*/
88-
export function isThirdPartyProxyRelativePath(): boolean {
89-
const proxyUrl = getThirdPartyProxyBaseUrl();
90-
return Boolean(proxyUrl) && !/^https?:\/\//i.test((proxyUrl ?? '').trim());
91-
}
92-
9377
/**
9478
* Whether the deployment provides an api container that can proxy /api/gemini
9579
* requests. True only when the runtime config (Docker web-server.js) explicitly

0 commit comments

Comments
 (0)