refactor: delete code nothing reaches - #7019
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Deletes the orphan Also drops a redundant Reviewed by Cursor Bugbot for commit 34528af. Configure here. |
Greptile SummaryThis PR removes declarations, imports, local variables, and helper code that are no longer referenced, while simplifying one redundant workflow-diff check.
Confidence Score: 5/5The PR appears safe to merge because the removed code has no remaining repository consumers and no concrete behavioral regression was identified. The changes are confined to unreachable declarations, unread bindings, unused imports, and a redundant comparison whose remaining check preserves behavior for established workflow inputs.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/copilot/application/execute-platform-context-use-case.ts | Deletes an unreferenced private application adapter with no remaining importers or re-exports. |
| apps/sim/lib/copilot/tool-executor/router.ts | Removes unused route projection types and helper while retaining every export used by current callers. |
| apps/sim/lib/copilot/chat/process-contents.ts | Removes the superseded API-based past-chat processor; the database-backed implementation remains. |
| apps/sim/lib/workflows/diff/diff-engine.ts | Removes a redundant own-key membership check; no reachable workflow input was found for the only semantic edge case. |
| apps/sim/lib/workflows/executor/execution-core.ts | Drops an unread workflow binding from snapshot destructuring without changing execution behavior. |
| apps/sim/lib/uploads/utils/validation.ts | Removes two unreferenced derived MIME-type arrays while preserving upload validation and accept attributes. |
| apps/sim/lib/copilot/chat/effective-transcript.ts | Removes a write-only subagent variable while retaining scoped lane attribution state. |
Reviews (1): Last reviewed commit: "refactor: delete code nothing reaches" | Re-trigger Greptile
50594b8 to
fdc4038
Compare
`biome.json:101-102` turns off `noUnusedVariables` and `noUnusedFunctionParameters`, so none of this was ever going to be flagged. Everything here was confirmed by grepping the symbol across `apps/` and `packages/` and finding only its own declaration; `tsc --noEmit` then proves each deleted binding was unread, since a read one fails to compile. - Eleven module-scope loggers that nothing logs through, with the now-orphaned `createLogger` import each left behind. - `execute-platform-context-use-case.ts` — the whole file. No importer, no barrel, and neither export is named anywhere. - `routeToolCall` and, once it goes, `ToolRoute` and `ToolRouteTarget` with it. The catalog accessors around them stay live. - `processPastChat`, superseded by `processPastChatFromDb`. It carried the last `boundary-raw-fetch` exemption in the file. - `withMessageId`, pasted into three server tools and called in none. - Write-only locals: `activeSubagent` (assigned twice, read never — the scoped maps replaced it), `resolvedReadPath`, `workflowPath`, and `workflow` in an execution-core destructure. - `ACCEPTED_AUDIO_TYPES` / `ACCEPTED_VIDEO_TYPES`, never wired to an accept attribute the way their live sibling is. - Unused `catch` bindings in `error-extractors.ts` and `defaults.ts`. `diff-engine.ts` drops a `proposedSubKeys.includes(key)` guard that the `!proposedSub` check three lines down already covers: a key absent from the proposed block reads back `undefined` there, and so does a key present with a nullish value. Same answer on every input, without the O(n) scan per iteration.
34528af to
e11ae5d
Compare
Why this accumulated
biome.json:101-102disablesnoUnusedVariablesandnoUnusedFunctionParameters. None of this was ever going to be flagged.How each item was proven dead
A repo-wide grep for the symbol across
apps/andpackages/returning only its own declaration — not "no importer found", but no occurrence at all, which also rules out barrel re-exports, dynamic string keys, and config references.tsc --noEmitthen proves each deleted binding was unread, since a binding that is actually read fails to compile.What went
createLoggerimport each left behindexecute-platform-context-use-case.tsrouteToolCallToolRoute, thenToolRouteTarget— a three-step cascadeprocessPastChatprocessPastChatFromDb; carried the file's lastboundary-raw-fetchexemptionwithMessageIdactiveSubagent,resolvedReadPath,workflowPath, andworkflowin a destructureACCEPTED_AUDIO_TYPES/ACCEPTED_VIDEO_TYPEScatchbindingserror-extractors.ts×2,defaults.tsactiveSubagentis the interesting one: it was assigned twice and read never, because the scopedsubagentBySpanId/subagentByParentToolCallIdmaps replaced it. The comment explaining why the name-match fallback was abandoned is kept — it just no longer names a symbol that does not exist.One redundant guard
diff-engine.tsdropsif (!proposedSubKeys.includes(key)) return true. The!proposedSubcheck three lines down already covers it: a key absent from the proposed block reads backundefinedthere, and so does a key present with a nullish value. Same answer on every input, minus an O(n) scan per iteration.Deliberately NOT included
checkChunkWriteAccesslooked like a missing-authz bug — its TSDoc says chunk update/delete require write permission, and nothing calls it. It is not a bug: those routes were migrated toknowledgeOperations.updateChunk/deleteChunk, bothminimumRole: 'write'. The wider cluster of superseded knowledge authz helpers is worth removing, but it deserves its own PR rather than riding along in a mechanical sweep.normalize.ts:203,295— biome flagsconst { isExpanded, ...rest }as unused, but the destructure is the omit. Removing it would silently change the normalized payload and break diff comparison.success === truecoercions — TS calls them redundant, but the values come from third-party tool handlers that can return a truthy non-boolean.exportkeywords undertools/**— dropping the keyword is inert but it is thousands of lines of churn for no behavioral or bundle win.Testing
lib/copilot,lib/workflows,tools,triggers,lib/uploadsbun run type-checkclean;bun run check:api-validationpasses