refactor: prune the unused exported types knip recorded
Summary
Completes the knip backlog: after #556 cleared the value-level export warnings, this clears all 58 type-level warnings across 26 files (−48 net lines). The only remaining knip warnings on the whole tree are the one documented keeper from #556 and the nine AuditAction enum members kept on purpose here.
Stacked on #556 → #555 → #554. Merge in order; this PR then shows only the type-prune commit.
What was done
- 41 types/interfaces un-exported — used inside their own module only: the settings-panel action unions, CLI option shapes (
UninstallCliOptions,DoctorCliOptions, …), forecast and runtime-current-account unions, recovery'sStored*Partinterfaces, first-run outcome types, ui theme shapes, and more. Perlib/AGENTS.md, none are reachable from any entry, so they were never public API. - Type re-export shims trimmed:
recovery.tsnow re-exports onlyRecoveryErrorType(MessageInfo/MessageData/ResumeConfigremain as in-file imports — the first classification pass missed their deeper usages, which typecheck caught and corrected),quota-headers.tsdrops the unusedCodexQuotaWindowpassthrough, androtation.tsloses its routing-mutex type re-export block entirely — every consumer imports those types fromrouting-mutex.jsdirectly. - Dead type declarations deleted:
ErrorCodeType, recovery'sThinkingPartType/MetaPartType/ContentPartTypealiases plus theToolUsePartinterface, and ninez.inferone-liner*FromSchemaaliases inschemas.tswhose consumers all use thestorage/public-typesdefinitions instead. - Kept deliberately: the nine unused
AuditActionenum members — they're the forward-looking audit-event taxonomy (the vocabulary of events the audit log is designed to carry), not dead code. knip'senumMembersrule is warn-level, so they stay visible without blocking.
Validation
- [x]
npm run typecheckclean — the primary gate for type-only changes - [x]
npx eslint <all changed files> --max-warnings=0 - [x]
npx knip: type warnings 58 → 0 - [x] rotation/recovery/forecast/schemas/errors suites: 321/321 — covering every file whose runtime re-export statements were touched
Risk / Rollback
Type-only visibility changes plus deletions of unreferenced declarations; zero emitted-code impact. Revert the single commit.
https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Generated by Claude Code
note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.
Greptile Summary
clears the remaining 58 type-level knip warnings across 26 files by un-exporting module-internal types, deleting dead type aliases, and trimming re-export shims — zero emitted-code impact and typecheck is clean throughout.
- 41 types/interfaces made module-private across settings panels, cli option shapes, forecast/runtime unions, and recovery storage parts;
rotation.tsdrops its routing-mutex re-export block entirely since every consumer already imports directly fromrouting-mutex.js. - dead type aliases deleted: nine
z.infer*FromSchemaone-liners inschemas.ts,ErrorCodeTypeinerrors.ts, and theThinkingPartType/MetaPartType/ContentPartType/ToolUsePartaliases inrecovery/types.ts— all confirmed unreferenced by typecheck. - two cases where unexported types still appear in exported shapes need attention:
OcChatgptAccountRef(now private) is referenced in five fields of the exportedOcChatgptMergePreviewandOcChatgptPreviewPayload, andDashboardLayoutMode/DashboardFocusStyle(now private) appear in the exportedDashboardDisplaySettingsinterface — consumers lose the ability to name these types explicitly.
Confidence Score: 4/5
safe to merge — all changes are type-visibility only with zero emitted-code impact, typecheck is clean, and the 321-test suite covers the touched runtime paths.
two files — oc-chatgpt-import-adapter.ts and dashboard-settings.ts — now export shapes whose member types can no longer be named by consumers; this quietly narrows the public api surface in a way knip won't catch going forward, but it doesn't break any existing consumer since typecheck passed.
lib/oc-chatgpt-import-adapter.ts and lib/dashboard-settings.ts — both expose unexported types through their exported shapes, which may trip up future consumers of the import/merge api or settings serialization layer.
Important Files Changed
| Filename | Overview |
|---|---|
| lib/oc-chatgpt-import-adapter.ts | OcChatgptAccountRef un-exported while still referenced in five fields of the exported OcChatgptMergePreview and OcChatgptPreviewPayload — degrades public API ergonomics; vitest coverage not confirmed for this file |
| lib/dashboard-settings.ts | DashboardLayoutMode and DashboardFocusStyle made private while still typed in exported DashboardDisplaySettings fields; consumers serializing/deserializing settings to Windows disk can't annotate these fields explicitly |
| lib/rotation.ts | Removes re-export block for SelectionRecord/RoutingMutexMode/AsyncMutex; PR confirms all consumers import directly from routing-mutex.js, typecheck clean |
| lib/recovery.ts | Re-export trimmed to RecoveryErrorType only; MessageInfo/MessageData/ResumeConfig kept as in-file imports, consumers updated to import from recovery/types.ts directly, typecheck confirms correctness |
| lib/recovery/types.ts | ThinkingPartType/MetaPartType/ContentPartType aliases deleted, ToolUsePart deleted, StoredToolPart/StoredReasoningPart/StoredStepPart made private; recovery suite 321/321 confirms no runtime impact |
| lib/schemas.ts | Nine z.infer *FromSchema one-liners deleted; consumers already use storage/public-types definitions, typecheck clean, schemas suite confirms no regressions |
| lib/errors.ts | ErrorCodeType alias deleted entirely; no external consumer references it per typecheck, errors suite clean |
| lib/runtime/quota-headers.ts | CodexQuotaWindow passthrough re-export dropped; CodexQuotaSnapshot re-export retained, no consumer breakage detected |
| lib/oc-chatgpt-target-detection.ts | OcChatgptTargetFound made private; still used in exported OcChatgptTargetDetectionResult union but TS discriminated-union narrowing works structurally, no explicit annotation needed; vitest coverage not confirmed |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph public["Public Exports (still exported)"]
MPP["OcChatgptPreviewPayload"]
MMP["OcChatgptMergePreview"]
DDS["DashboardDisplaySettings"]
TDR["OcChatgptTargetDetectionResult"]
end
subgraph pruned["Now Module-Private"]
AR["OcChatgptAccountRef ⚠️"]
LM["DashboardLayoutMode ⚠️"]
FS["DashboardFocusStyle ⚠️"]
TF["OcChatgptTargetFound"]
STP["StoredToolPart / StoredReasoningPart"]
CLI["CliOptions shapes"]
end
subgraph deleted["Deleted Entirely"]
ECT["ErrorCodeType"]
TPT["ThinkingPartType / MetaPartType"]
FSC["9x FromSchema aliases"]
end
MPP -->|"accounts field"| AR
MMP -->|"toAdd / toUpdate / toSkip"| AR
DDS -->|"menuLayoutMode"| LM
DDS -->|"menuFocusStyle"| FS
TDR -->|"union member"| TF
Comments Outside Diff (1)
-
lib/oc-chatgpt-import-adapter.ts, line 1 (link)missing vitest coverage for changed files
the pr's validation matrix lists rotation/recovery/forecast/schemas/errors suites (321/321), but
oc-chatgpt-import-adapter.tsandoc-chatgpt-target-detection.tsaren't mentioned. both files had exports visibility-changed and the import-adapter hosts the merge/dedup logic that touches rawrefreshTokenvalues — worth confirming a vitest suite coversbuildOcChatgptImportPayloadandpreviewOcChatgptImportMergeso regressions in token-handling paths don't go undetected.Prompt To Fix With AI
This is a comment left during a code review. Path: lib/oc-chatgpt-import-adapter.ts Line: 1 Comment: **missing vitest coverage for changed files** the pr's validation matrix lists rotation/recovery/forecast/schemas/errors suites (321/321), but `oc-chatgpt-import-adapter.ts` and `oc-chatgpt-target-detection.ts` aren't mentioned. both files had exports visibility-changed and the import-adapter hosts the merge/dedup logic that touches raw `refreshToken` values — worth confirming a vitest suite covers `buildOcChatgptImportPayload` and `previewOcChatgptImportMerge` so regressions in token-handling paths don't go undetected. How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
lib/oc-chatgpt-import-adapter.ts:21-25
**unexported type leaked through multiple exported shapes**
`OcChatgptAccountRef` is now module-private but appears directly in five fields of the still-exported `OcChatgptMergePreview` (`toAdd`, `toUpdate.previous/next`, `toSkip.source`, `unchangedDestinationOnly`) and in `OcChatgptPreviewPayload.accounts`. consumers of those exported types can work with instances via structural inference, but cannot explicitly annotate a variable as `OcChatgptAccountRef` or import it in a type assertion — this quietly degrades the public API of the import/merge surface.
### Issue 2 of 3
lib/dashboard-settings.ts:15-16
**unexported types surfaced through exported interface**
`DashboardLayoutMode` and `DashboardFocusStyle` are now module-private but are referenced directly by the exported `DashboardDisplaySettings` fields `menuLayoutMode` and `menuFocusStyle`. any consumer that reads settings from disk on windows (e.g. to re-persist after migration) and wants to explicitly annotate these fields can't do so without inlining the literal union — same ergonomic gap as `OcChatgptAccountRef` in the import adapter.
### Issue 3 of 3
lib/oc-chatgpt-import-adapter.ts:1
**missing vitest coverage for changed files**
the pr's validation matrix lists rotation/recovery/forecast/schemas/errors suites (321/321), but `oc-chatgpt-import-adapter.ts` and `oc-chatgpt-target-detection.ts` aren't mentioned. both files had exports visibility-changed and the import-adapter hosts the merge/dedup logic that touches raw `refreshToken` values — worth confirming a vitest suite covers `buildOcChatgptImportPayload` and `previewOcChatgptImportMerge` so regressions in token-handling paths don't go undetected.
Reviews (1): Last reviewed commit: "refactor: prune the unused exported type..." | Re-trigger Greptile
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. Credits must be used to enable repository wide code reviews.
[!WARNING]
Review limit reached
@ndycode, we couldn't start this review because you've reached your PR review rate limit.More reviews will be available in 14 minutes and 33 seconds. Learn how PR review limits work.
Your organization has run out of usage credits. Purchase more in the billing tab.
⌛ How to resolve this issue?
After more reviews become available, a review can be triggered using the
@coderabbitai reviewcommand 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.
Please see our Fair Usage Limits Policy for further information.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID:
dbcd17b7-f78b-431d-bf8e-ba4c8b6b7834📥 Commits
Reviewing files that changed from the base of the PR and between 00b060c490670aa1cd05e65b5b2f2c244a4a0af6 and 3ac7871e02d94245a82f935d48506d18abf5a572.
📒 Files selected for processing (28)
lib/audit.tslib/auth/device-auth.tslib/codex-manager/behavior-settings-panel.tslib/codex-manager/commands/uninstall.tslib/codex-manager/commands/verify.tslib/codex-manager/commands/why-selected.tslib/codex-manager/dashboard-display-panel.tslib/codex-manager/experimental-settings-prompt.tslib/codex-manager/help.tslib/codex-manager/repair-commands.tslib/codex-manager/statusline-settings-panel.tslib/codex-manager/theme-settings-panel.tslib/dashboard-settings.tslib/errors.tslib/forecast.tslib/oc-chatgpt-import-adapter.tslib/oc-chatgpt-target-detection.tslib/recovery.tslib/recovery/types.tslib/request/response-compaction.tslib/rotation.tslib/runtime/first-run.tslib/runtime/quota-headers.tslib/runtime/runtime-current-account.tslib/runtime/runtime-observability.tslib/schemas.tslib/storage/migrations.tslib/ui/theme.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Commit unit tests in branch
claude/audit-40-type-prune
✨ Simplify code
- [ ] Create PR with simplified code
- [ ] Commit simplified code in branch
claude/audit-40-type-prune
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
Closing as superseded — the substance of this stack is already on main:
knip.jsoncis present onmain(byte-identical to what #555 proposed).@fast-check/vitesthas already been removed fromdevDependencies.- The unused-export / unused-type backlog that #556 and #557 pruned is already clean on current
main(verified by running knip against today's tree — no unused files, no unused deps; only a handful of intentional warn-level export/type/enum keepers remain).
Because the bases were ~159 commits behind main, replaying the original deletions would risk removing code that has since become live, with no net benefit. The one genuinely still-valid finding from reviewing this stack — a broken dashboard-settings.js import in test/settings-preview.test.ts that knip surfaced — has been split out into #616. Thanks!