Skip to content

Fix unused code, array mutation bug, and TypeScript errors - #291

Open
aadityakumarsah wants to merge 2 commits into
DenchHQ:mainfrom
aadityakumarsah:fix-unused-imports-and-types
Open

Fix unused code, array mutation bug, and TypeScript errors#291
aadityakumarsah wants to merge 2 commits into
DenchHQ:mainfrom
aadityakumarsah:fix-unused-imports-and-types

Conversation

@aadityakumarsah

@aadityakumarsah aadityakumarsah commented Jul 16, 2026

Copy link
Copy Markdown

Description

This issue addresses several bugs, code smells, and TypeScript errors discovered during static analysis (linting and type checking).

1. Unused Imports in Test Files

  • File: apps/web/lib/chat-agent-registry.test.ts
  • Issue: The imports existsSync and mkdirSync from node:fs are declared but never used in the file, cluttering the import block.

2. Dead Code (Unused Function and Variable)

  • File: apps/web/lib/denchclaw-state.ts
  • Issue: The function defaultEmailBodyHydrationAttempted is defined but never invoked anywhere in the codebase.
  • File: apps/web/lib/active-runs.ts
  • Issue: The variable everSentResponseActivity is declared and assigned values in the wireSubscribeOnlyProcess function, but it is never used in that scope.

3. Array Mutation Bug

  • File: apps/web/lib/denchclaw-state.ts
  • Issue: The code uses Array.from(current).sort(). The sort() method mutates the array in place. While Array.from creates a new array, using .toSorted() is the more modern, idiomatic, and safer approach to ensure arrays are sorted without unintended side effects (as flagged by eslint-plugin-unicorn(no-array-sort)).

4. TypeScript Error in AI Gateway

  • File: extensions/dench-ai-gateway/sync-trigger.ts
  • Issue: There is a TypeScript error: Element implicitly has an 'any' type because expression of type '"syncTrigger"' can't be used to index type '{}'. This occurs because pluginConfig?.config is not properly typed before attempting to access the ["syncTrigger"] property.

5. Arrow Function Body Formatting and Object Spreads

  • File: apps/web/lib/active-runs.test.ts
  • Issue: The linter flags single-line arrow function bodies (e.g. subscribeToRun(idA, (e) => { if (e) eventsA.push(e); }, { replay: false });) that lack curly braces after the if statement.
  • File: apps/web/lib/active-runs.ts
  • Issue: The linter flags a useless fallback in an object spread (...(details ?? {}) where details is already an object).

Proposed Solution

  • Remove the unused imports from chat-agent-registry.test.ts.
  • Delete the unused defaultEmailBodyHydrationAttempted function from denchclaw-state.ts and the everSentResponseActivity variable from active-runs.ts.
  • Replace .sort() with .toSorted() in denchclaw-state.ts.
  • Add proper type assertion (as Record<string, unknown>) when accessing the config in sync-trigger.ts to satisfy the TypeScript compiler.
  • Add curly braces to the arrow function bodies in active-runs.test.ts.
  • Remove the unnecessary ?? {} fallback in the object spread in active-runs.ts.

@aadityakumarsah aadityakumarsah changed the title Fix unused imports and type errors Fix unused code, array mutation bug, and TypeScript errors Jul 16, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit f333ff0. Configure here.


it("delivers events to the correct session without cross-contamination", async () => {
const { childA, childB, prefix, startRun, abortRun, subscribeToRun } =
const { childA, childB, prefix, startRun, _abortRun, subscribeToRun } =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect unused abort destructuring

Low Severity

These tests destructure _abortRun, but setupConcurrent returns abortRun. Unlike the childA: _childA rename nearby, this binds a missing property and leaves _abortRun always undefined, so the unused-binding cleanup does not actually reference the real export.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f333ff0. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant