Skip to content

Audit: dead code across app and ui packages #640

@Spongeacer

Description

@Spongeacer

Summary

A knip + manual audit identified approximately 60+ locations of dead code across the app and ui packages — unused exports, entire unused files, and symbols that are only used inside their own module but unnecessarily carry export.

Audit Method

  1. Ran npx knip to detect unused files, exports, dependencies, and devDependencies.
  2. Manually verified each flagged symbol with grep to confirm zero external references.
  3. Stashed changes and re-ran the test suite to confirm pre-existing failures vs. regression.

Findings by Category

A. Entire files with zero references — safe to delete

File Package Lines
src/components/dialog-manage-models.tsx app 102
src/custom-elements.d.ts app 1

B. Exported symbols with zero external imports — safe to delete

Symbol File Package
ConstrainDragXAxis utils/solid-dnd.tsx app
WorkspaceDragOverlay pages/layout/sidebar-workspace.tsx app
SortableWorkspace pages/layout/sidebar-workspace.tsx app
LocalWorkspace pages/layout/sidebar-workspace.tsx app
useHighlights context/highlights.tsx app
getSessionKey pages/session/helpers.ts app
currentSession components/message-part/session-link.ts ui
diff storybook/fixtures.ts ui
code storybook/fixtures.ts ui

C. Over-exported internals — used only within same module

These functions are called by other functions in the same file, but no external file imports them. They should lose export.

Symbol File Internal caller
agentColor utils/agent.ts messageAgentColor
soundSrc utils/sound.ts playSoundById
playSound utils/sound.ts playSoundById
stripFileProtocol context/file/path.ts createPathHelpers chain
decodeFilePath context/file/path.ts createPathHelpers chain
getAvatarColors context/layout.tsx (internal only)
MAX_TITLEBAR_HISTORY components/titlebar-history.ts applyPath, pushPath, trimHistory
pushPath components/titlebar-history.ts applyPath
trimHistory components/titlebar-history.ts pushPath
patchFile components/apply-patch-file.ts patchFiles
enterWorktreeOwnerProject components/tool-info.ts enterWorktreeSubtitle
enterWorktreeTarget components/tool-info.ts enterWorktreeSubtitle
exitWorktreeProjectName components/tool-info.ts exitWorktreeSubtitle
exitWorktreePreviousLabel components/tool-info.ts exitWorktreeSubtitle
agentTitle components/tool-info.ts toolInfoForInput

D. Console debugging statements (25+)

Scattered console.debug / console.warn / console.error calls in production source files, e.g.:

// app/src/components/terminal.tsx:69
console.debug("[terminal]", ...values)

// app/src/pages/session/review-tab.tsx:59
console.debug("[session-review] failed to read file", { path, error })

E. SDK-generated dead code (not addressed in PR)

Knip flagged ~20 unused exports in packages/sdk/js/src/v2/gen/core/*.gen.ts (serializers, query key helpers, etc.). These are generated files and should be handled by the code generator, not manual deletion.

F. Deprecated fields (not addressed in PR)

@deprecated annotations in opencode/src/config/agent.ts, opencode/src/config/config.ts, and opencode/src/session/message-v2.ts. These require careful migration planning before removal.


Recommended Next Steps

Priority Action
P0 Merge the PR for A+B+C (low risk, high cleanup value)
P1 Audit and remove console.* debug statements or replace with formal logger
P2 Configure knip in CI to prevent re-accumulation
P3 Address deprecated config fields with migration paths
P4 Tune SDK generator to skip unused serializer helpers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions