Skip to content

chore: remove dead code — unused exports, components, and files#641

Merged
Astro-Han merged 2 commits into
Astro-Han:devfrom
Spongeacer:cleanup/dead-code
May 15, 2026
Merged

chore: remove dead code — unused exports, components, and files#641
Astro-Han merged 2 commits into
Astro-Han:devfrom
Spongeacer:cleanup/dead-code

Conversation

@Spongeacer

Copy link
Copy Markdown
Contributor

Summary

Removes dead code identified by knip and manual verification. See #640 for the full audit.

What Changed

Deleted entire files (zero references)

  • packages/app/src/components/dialog-manage-models.tsx — unused component
  • packages/app/src/custom-elements.d.ts — unused type declarations

Removed unused exported symbols

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

Demoted over-exported internals to local scope

These functions/constants are still used inside their own module but have no external importers. Removing export prevents accidental coupling and makes the public API surface honest.

  • agentColor → local (utils/agent.ts)
  • soundSrc, playSound → local (utils/sound.ts)
  • stripFileProtocol, decodeFilePath → local (context/file/path.ts)
  • getAvatarColors → local (context/layout.tsx)
  • MAX_TITLEBAR_HISTORY, pushPath, trimHistory → local (components/titlebar-history.ts)
  • patchFile → local (ui/components/apply-patch-file.ts)
  • enterWorktreeOwnerProject, enterWorktreeTarget, exitWorktreeProjectName, exitWorktreePreviousLabel, agentTitle → local (ui/components/tool-info.ts)

Test Results

Package Pass Fail Note
packages/app 1071 0 ✅ clean
packages/ui 418 3 3 failures are pre-existing CSS snapshot tests unrelated to this change (verified by running tests on dev without these changes)

Stats

15 files changed, 32 insertions(+), 368 deletions(-)

Related Issue

Closes #640

Removes dead code identified by knip and manual audit across app and ui
packages. Changes fall into three categories:

1. Deleted entire files with zero references:
   - dialog-manage-models.tsx (unused component)
   - custom-elements.d.ts (unused type declarations)

2. Removed unused exported symbols (zero external imports):
   - ConstrainDragXAxis (solid-dnd)
   - WorkspaceDragOverlay, SortableWorkspace, LocalWorkspace (sidebar)
   - useHighlights (highlights context)
   - getSessionKey (session helpers)
   - currentSession (session-link)
   - diff, code (storybook fixtures)

3. Demoted over-exported internals (used only within same module):
   - agentColor → local function
   - soundSrc, playSound → local functions
   - stripFileProtocol, decodeFilePath → local functions
   - getAvatarColors → local function
   - MAX_TITLEBAR_HISTORY, pushPath, trimHistory → local constants/functions
   - patchFile → local function
   - enterWorktreeOwnerProject, enterWorktreeTarget,
     exitWorktreeProjectName, exitWorktreePreviousLabel,
     agentTitle → local functions (still used by exported siblings)

Test results:
- packages/app: 1071 pass / 0 fail
- packages/ui: 418 pass / 3 fail (pre-existing CSS test failures unrelated to this change)
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Astro-Han has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7cb65c07-5866-4c4f-be8b-f18e0109efd0

📥 Commits

Reviewing files that changed from the base of the PR and between 84bb3ab and 55e82fc.

📒 Files selected for processing (15)
  • packages/app/src/components/dialog-manage-models.tsx
  • packages/app/src/components/titlebar-history.ts
  • packages/app/src/context/file/path.ts
  • packages/app/src/context/highlights.tsx
  • packages/app/src/context/layout.tsx
  • packages/app/src/custom-elements.d.ts
  • packages/app/src/pages/layout/sidebar-workspace.tsx
  • packages/app/src/pages/session/helpers.ts
  • packages/app/src/utils/agent.ts
  • packages/app/src/utils/solid-dnd.tsx
  • packages/app/src/utils/sound.ts
  • packages/ui/src/components/apply-patch-file.ts
  • packages/ui/src/components/message-part/session-link.ts
  • packages/ui/src/components/tool-info.ts
  • packages/ui/src/storybook/fixtures.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added app Application behavior and product flows ui Design system and user interface labels May 15, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested priority: P2 (includes user-path files (packages/app/src/components/dialog-manage-models.tsx, packages/app/src/components/titlebar-history.ts, packages/app/src/context/file/path.ts, packages/app/src/context/highlights.tsx, packages/app/src/context/layout.tsx, packages/app/src/custom-elements.d.ts, packages/app/src/pages/layout/sidebar-workspace.tsx, packages/app/src/pages/session/helpers.ts, packages/app/src/utils/agent.ts, packages/app/src/utils/solid-dnd.tsx, packages/app/src/utils/sound.ts)).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on code cleanup by removing unused exports, components, and constants across multiple packages. Significant changes include internalizing previously exported functions and deleting several UI components and helpers. Feedback highlights a critical issue in packages/ui/src/components/tool-info.ts where duplicate function definitions were introduced, which will likely cause a build error. Additionally, the reviewer suggests further cleanup in sidebar-workspace.tsx to remove helper components that have become dead code following the removal of their consumers.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/ui/src/components/tool-info.ts (34-50)

high

This block introduces duplicate definitions for enterWorktreeOwnerProject and enterWorktreeTarget, which are already defined and exported at lines 16 and 21. This will cause a redeclaration error and break the build.

To demote these functions to local scope as intended (consistent with how you handled exitWorktreeProjectName in this file), you should remove the export keyword from the existing definitions at lines 16 and 21 and remove this redundant block.

References
  1. Before suggesting to add a function, ensure it is not already defined within the same file or module.

packages/app/src/pages/layout/sidebar-workspace.tsx (278-462)

medium

With the removal of SortableWorkspace and LocalWorkspace, the helper components WorkspaceHeader, WorkspaceActions, and WorkspaceSessionList (defined in lines 54-249) no longer have any consumers in this file and are not exported. They should also be removed to complete the dead code cleanup.

Two typecheck failures from the dead-code cleanup:

- session-link.ts: currentSession was removed but taskSession still
  calls it; restore as a module-local function (drops only the export).
- tool-info.ts: enterWorktreeOwnerProject / enterWorktreeTarget were
  duplicated — the original exports were kept and local copies added
  underneath. Remove the duplicates and drop the export on the
  originals.

Also finishes the cleanup in sidebar-workspace.tsx: with
WorkspaceDragOverlay / SortableWorkspace / LocalWorkspace gone, the
internal WorkspaceHeader / WorkspaceActions / WorkspaceSessionList
helpers no longer have any callers. Reduce the file to the
WorkspaceSidebarContext type that layout.tsx still imports.

Verified:
- bun --cwd packages/ui run typecheck: clean
- bun --cwd packages/app run typecheck: clean
- packages/app test: 1071 pass / 0 fail
- packages/ui test: 418 pass / 3 fail (pre-existing CSS snapshots)
@Astro-Han

Copy link
Copy Markdown
Owner

Pushed a fixup commit (55e82fc) directly to this branch via maintainer-can-modify. Two typecheck failures from the cleanup needed addressing, plus a follow-on dead-code pass:

session-link.tscurrentSession was removed but taskSession in the same file still calls it. Restored it as a module-local function (the original export was the only thing that actually needed to go).

tool-info.tsenterWorktreeOwnerProject / enterWorktreeTarget ended up with both an exported version (kept from dev) and a duplicate local version (newly added), tripping TS2393. Removed the duplicates and dropped the export on the originals — same end state, no double implementation.

sidebar-workspace.tsx — once WorkspaceDragOverlay / SortableWorkspace / LocalWorkspace were removed, the internal WorkspaceHeader / WorkspaceActions / WorkspaceSessionList helpers were left with no callers (Gemini flagged this too). Reduced the file to the WorkspaceSidebarContext type that layout.tsx still imports.

Verified locally:

  • packages/ui typecheck: clean
  • packages/app typecheck: clean
  • packages/app tests: 1071 pass / 0 fail
  • packages/ui tests: 418 pass / 3 fail (the same pre-existing CSS snapshots you noted)

Feel free to amend or rewrite however you'd like; happy to revert if you'd rather take a different cut. CI should re-run on the push.

@Astro-Han Astro-Han added tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context P3 Low priority labels May 15, 2026
@Astro-Han Astro-Han merged commit 4a9506d into Astro-Han:dev May 15, 2026
22 checks passed
@Astro-Han

Copy link
Copy Markdown
Owner

Merged 🎉 — thanks for the cleanup!

One small followup: GitHub doesn't let me delete cleanup/dead-code on your fork via maintainer-can-modify (it covers pushes but not branch deletes). Could you delete it from your side at https://github.com/Spongeacer/pawwork/branches when you get a chance? No rush.

Astro-Han pushed a commit that referenced this pull request May 15, 2026
…dit (#646)

Fixes identified during full-stack bug hunt. Refs #643 #644 #645.

## app

- terminal.tsx: use strict equality (===) for the Enter key check; add .catch() to document.fonts.ready so a font-loading rejection cannot become unhandled.
- layout.tsx: add .catch() handlers to the three dynamic imports (provider, server, directory dialogs) so a chunk-load failure does not surface as an unhandled rejection.
- global-sync.tsx: add .catch() to the projectInit promise; guard the requestAnimationFrame callback with `if (!active) return` so it cannot schedule work after cleanup tore the owner down.
- sync.tsx: call clearOptimistic(directory, sessionID) when dropping sessions, so the optimistic Map no longer leaks entries for sessions that disappear.

## opencode

- tool/agent.ts: add a default case to the part.status switch so a new status value cannot leave header and body undefined.
- control-plane/workspace.ts: wrap the parseSSE call in try/catch so a malformed SSE event does not terminate the workspace sync loop.
- tool/apply_patch.ts: replace `(error as any)` in notFound() with a proper `Record<string, unknown>` narrowing.

## Rescue rebase notes

The PR originally bundled three additional commits that did not survive review and were dropped or partially reverted on rebase:

- A dead-code cleanup commit that was equivalently merged via #641 (with reviewer fixups for tool-info.ts and session-link.ts). Keeping it here would have re-introduced four TS2393 duplicate-definition errors on the worktree helpers; dropping the commit cleared them.
- A separate input-validation commit (SQL prefix allowlist, http(s) URL guard, config-path scoping, parseInt radix/NaN fallback). The DB connection is already readonly, fetch() already rejects non-http(s) schemes, downstream code already tolerates NaN, and the config-path rule is a user-visible behavioral break with no concrete threat model — dropped, can revisit any item individually in a follow-up.
- One line of the original race/error commit removed an `as any[]` cast in provider/transform.ts on the assumption that Array.isArray narrowed sufficiently. It does not: TS narrows the system-message branch union to `never`, so the cast is still required. Restored.

## Verification

- packages/ui typecheck clean.
- packages/app typecheck clean.
- packages/opencode typecheck clean.
- CI green across typecheck, unit-app, unit-desktop, unit-opencode, smoke-macos-arm64, e2e-artifacts, perf-probe-baseline, lint, analyze-js-ts, CodeQL.
- Both bot review threads resolved (Gemini manual, CodeRabbit auto-detected).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows P3 Low priority tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context ui Design system and user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit: dead code across app and ui packages

2 participants