Skip to content

refactor: prune the unused exported types knip recorded#557

Open
ndycode wants to merge 1 commit into
claude/audit-39-export-prunefrom
claude/audit-40-type-prune
Open

refactor: prune the unused exported types knip recorded#557
ndycode wants to merge 1 commit into
claude/audit-39-export-prunefrom
claude/audit-40-type-prune

Conversation

@ndycode

@ndycode ndycode commented Jun 10, 2026

Copy link
Copy Markdown
Owner

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's Stored*Part interfaces, first-run outcome types, ui theme shapes, and more. Per lib/AGENTS.md, none are reachable from any entry, so they were never public API.
  • Type re-export shims trimmed: recovery.ts now re-exports only RecoveryErrorType (MessageInfo/MessageData/ResumeConfig remain as in-file imports — the first classification pass missed their deeper usages, which typecheck caught and corrected), quota-headers.ts drops the unused CodexQuotaWindow passthrough, and rotation.ts loses its routing-mutex type re-export block entirely — every consumer imports those types from routing-mutex.js directly.
  • Dead type declarations deleted: ErrorCodeType, recovery's ThinkingPartType/MetaPartType/ContentPartType aliases plus the ToolUsePart interface, and nine z.infer one-liner *FromSchema aliases in schemas.ts whose consumers all use the storage/public-types definitions instead.
  • Kept deliberately: the nine unused AuditAction enum members — they're the forward-looking audit-event taxonomy (the vocabulary of events the audit log is designed to carry), not dead code. knip's enumMembers rule is warn-level, so they stay visible without blocking.

Validation

  • npm run typecheck clean — the primary gate for type-only changes
  • npx eslint <all changed files> --max-warnings=0
  • npx knip: type warnings 58 → 0
  • 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.ts drops its routing-mutex re-export block entirely since every consumer already imports directly from routing-mutex.js.
  • dead type aliases deleted: nine z.infer *FromSchema one-liners in schemas.ts, ErrorCodeType in errors.ts, and the ThinkingPartType/MetaPartType/ContentPartType/ToolUsePart aliases in recovery/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 exported OcChatgptMergePreview and OcChatgptPreviewPayload, and DashboardLayoutMode/DashboardFocusStyle (now private) appear in the exported DashboardDisplaySettings interface — 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
Loading

Comments Outside Diff (1)

  1. lib/oc-chatgpt-import-adapter.ts, line 1 (link)

    P2 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.

    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!

    Fix in Codex

Fix All in Codex

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

Completes the export backlog: all 58 type-level warnings resolved across
26 files.

- 41 types/interfaces un-exported (used inside their module only): the
  settings-panel action unions, CLI option shapes, forecast and
  runtime-current-account unions, recovery's Stored*Part interfaces,
  first-run outcome types, ui theme shapes, and more.
- Re-export shims trimmed: recovery.ts now re-exports only
  RecoveryErrorType (MessageInfo/MessageData/ResumeConfig stay as
  in-file imports), quota-headers.ts drops the unused CodexQuotaWindow
  passthrough, and rotation.ts loses its routing-mutex type re-export
  block — nothing imports those names from rotation anymore.
- Dead type declarations deleted: ErrorCodeType, recovery's
  ThinkingPartType/MetaPartType/ContentPartType aliases and the
  ToolUsePart interface, and nine z.infer one-liner *FromSchema aliases
  in schemas.ts whose consumers all use the storage/public-types
  definitions instead.
- The nine AuditAction enum members stay: they are the forward-looking
  audit-event taxonomy, not dead code; knip's enumMembers rule is
  already warn-level.

Verified: typecheck clean (the gate for type-only changes), eslint
--max-warnings=0 on all changed files, knip type warnings 58 -> 0, and
the rotation/recovery/forecast/schemas/errors suites all pass (321/321)
covering every trimmed runtime re-export.

https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
@chatgpt-codex-connector

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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 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 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 00b060c and 3ac7871.

📒 Files selected for processing (28)
  • lib/audit.ts
  • lib/auth/device-auth.ts
  • lib/codex-manager/behavior-settings-panel.ts
  • lib/codex-manager/commands/uninstall.ts
  • lib/codex-manager/commands/verify.ts
  • lib/codex-manager/commands/why-selected.ts
  • lib/codex-manager/dashboard-display-panel.ts
  • lib/codex-manager/experimental-settings-prompt.ts
  • lib/codex-manager/help.ts
  • lib/codex-manager/repair-commands.ts
  • lib/codex-manager/statusline-settings-panel.ts
  • lib/codex-manager/theme-settings-panel.ts
  • lib/dashboard-settings.ts
  • lib/errors.ts
  • lib/forecast.ts
  • lib/oc-chatgpt-import-adapter.ts
  • lib/oc-chatgpt-target-detection.ts
  • lib/recovery.ts
  • lib/recovery/types.ts
  • lib/request/response-compaction.ts
  • lib/rotation.ts
  • lib/runtime/first-run.ts
  • lib/runtime/quota-headers.ts
  • lib/runtime/runtime-current-account.ts
  • lib/runtime/runtime-observability.ts
  • lib/schemas.ts
  • lib/storage/migrations.ts
  • lib/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.

❤️ Share

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

ndycode added a commit that referenced this pull request Jun 11, 2026
refactor: prune the unused exported types knip recorded
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.

2 participants