Clean up remaining dead code and dependencies

- Replace unused 'codemirror' barrel dep with explicit @codemirror/{state,
  view,commands,language} sub-packages that were imported but unlisted
- Remove unused exports: writeNamespacedQuery, targetWorkspacePathForRun,
  isWorkspaceDeletionRun, piWebConfigDir, duplicate parsePiWebRuntimeResponse
- Remove unused types: WorkspacePanelFiles, WorkspacePanelHost,
  GetActiveSession, SaveAttachmentsResponse, QueryValues
- Drop now-unused re-exports/imports cascading from the above
- Add knip config + 'npm run knip' script for ongoing dead-code detection
This commit is contained in:
Federico Jaramillo Martinez
2026-06-13 21:57:51 +02:00
parent 5d335a7e72
commit edae57b836
11 changed files with 929 additions and 88 deletions
-19
View File
@@ -1,5 +1,4 @@
export type QueryValue = string | number | boolean | readonly (string | number | boolean)[];
export type QueryValues = Record<string, QueryValue | undefined | null>;
export function queryNamespace(contributionId: string): string {
return contributionId.replaceAll(":", ".");
@@ -26,24 +25,6 @@ export function readNamespacedString(namespace: string, key: string): string | u
return value === "" ? undefined : value;
}
export function writeNamespacedQuery(namespace: string, values: QueryValues, options?: { replace?: boolean | undefined }): void {
const url = new URL(window.location.href);
const prefix = `${namespace}--`;
for (const key of Array.from(url.searchParams.keys())) {
if (key.startsWith(prefix)) url.searchParams.delete(key);
}
for (const [key, value] of Object.entries(values)) {
if (value === undefined || value === null || value === "") continue;
const namespacedKey = `${prefix}${key}`;
if (Array.isArray(value)) {
for (const item of value) url.searchParams.append(namespacedKey, String(item));
} else {
url.searchParams.set(namespacedKey, String(value));
}
}
commitUrl(url, options);
}
export function setNamespacedQueryKey(namespace: string, key: string, value: QueryValue | undefined | null, options?: { replace?: boolean | undefined }): void {
const url = new URL(window.location.href);
const namespacedKey = `${namespace}--${key}`;
-4
View File
@@ -52,14 +52,10 @@ export interface WorkspaceFiles {
readFile(path: string): Promise<FileContentResponse>;
}
export type WorkspacePanelFiles = WorkspaceFiles;
export interface WorkspaceHost {
requestRender(): void;
}
export type WorkspacePanelHost = WorkspaceHost;
export interface WorkspaceContext {
machine: PluginMachine;
workspace: Workspace;
+2 -9
View File
@@ -1,8 +1,8 @@
import { workspaceDeleteOperation, workspaceDeleteOperationMetadataKey, targetWorkspaceIdMetadataKey, targetWorkspacePathMetadataKey } from "../../shared/workspaceDeletion";
import { workspaceDeleteOperation, workspaceDeleteOperationMetadataKey, targetWorkspaceIdMetadataKey } from "../../shared/workspaceDeletion";
import type { AppState } from "./appState";
import type { TerminalCommandRun, Workspace } from "./api";
export { targetWorkspaceIdMetadataKey, targetWorkspacePathMetadataKey, workspaceDeleteOperation, workspaceDeleteOperationMetadataKey, workspaceDeletionMetadata } from "../../shared/workspaceDeletion";
export { targetWorkspaceIdMetadataKey, workspaceDeleteOperation, workspaceDeleteOperationMetadataKey, workspaceDeletionMetadata } from "../../shared/workspaceDeletion";
export function workspaceDeletionRunFilter(projectId?: string): { projectId?: string; metadata: Record<string, string> } {
return {
@@ -38,14 +38,7 @@ export function targetWorkspaceIdForRun(run: TerminalCommandRun): string | undef
return run.metadata[targetWorkspaceIdMetadataKey];
}
export function targetWorkspacePathForRun(run: TerminalCommandRun): string | undefined {
return run.metadata[targetWorkspacePathMetadataKey];
}
export function isWorkspaceDeletionRunPending(run: TerminalCommandRun): boolean {
return run.status === "queued" || run.status === "running";
}
export function isWorkspaceDeletionRun(run: TerminalCommandRun): boolean {
return run.metadata[workspaceDeleteOperationMetadataKey] === workspaceDeleteOperation;
}