Skip to content

Remove dead code surfaced by a whole-app audit#511

Merged
FuJacob merged 1 commit into
mainfrom
chore/dead-code-audit
Jun 1, 2026
Merged

Remove dead code surfaced by a whole-app audit#511
FuJacob merged 1 commit into
mainfrom
chore/dead-code-audit

Conversation

@FuJacob

@FuJacob FuJacob commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

A whole-app audit (single module, so any unreferenced internal symbol is dead) for declared-but-unreferenced code. The recent base-model engine migration left no dead code in the engine/prompt/OCR paths — those were already cleaned. What remained was incidental, unrelated cruft. This removes everything with zero references across the app and tests:

  • Views: StatusPill (in MenuBarSections) and the entire TagsInputView.swift (and its private TagBubble/FlowLayout).
  • Methods: SuggestionInteractionState.clearContext (resetAll already clears), ModelDownloadManager.cancelAllDownloads, SuggestionSettingsModel.setDebounceMilliseconds / setFocusPollIntervalMilliseconds (no caller; the published values are still read and persisted elsewhere), FileLogWriter.wipeForTesting (a test hook no test calls), ExtendedContextPlaygroundModel.cancelGeneration.
  • Getters: MirrorPreference.helpDescription, FocusTrackingModel.menuBarStatusText / .menuBarSymbolName, FocusInspectionSnapshot's three role/capability summaries, FocusedInputSnapshot.textPreview, GeneralPaneView.emojiSkinToneBinding.
  • A dead Phase-2 hook: OverlayController.setCurrentBundleIdentifier was never called, so the currentBundleIdentifier it fed was always nil; the render policy now receives nil directly (behavior unchanged) until per-app overrides ship.

Validation

rm -rf build/DerivedData
xcodebuild -project Cotabby.xcodeproj -scheme Cotabby -destination 'platform=macOS' \
  build-for-testing -derivedDataPath build/DerivedData
# ** TEST BUILD SUCCEEDED **  (clean build — proves nothing still referenced the removed symbols)

swiftlint lint --quiet
# 0 violations

Each symbol was verified with rg -w '<name>' -t swift Cotabby CotabbyTests to have only its own declaration before removal. Cascade checks confirmed no helper was orphaned (e.g. setPreferredEmojiSkinTone keeps a live caller, the debounce/poll DefaultsKeys are still used by load/persist).

Linked issues

None.

Risk / rollout notes

  • Pure dead-code removal; no behavior change. The only live-code touch is OverlayController passing nil where it already passed an always-nil value.
  • Deliberately NOT removed (separate judgment call): five symbols are production-unused but still referenced by their unit tests — SettingsAttentionEvaluator.calloutMessage, FocusCapabilityResolution.bestDiagnosticCandidate, and CotabbyPermissionKind.guidanceHint (each superseded by a live path), plus SuggestionTextColorCodec.hexString(from:) and ActiveSuggestionSession.acceptedText (cohesive value-type API kept for symmetry/completeness). Removing them means deleting test coverage too, so I left them; happy to remove in a follow-up if you'd prefer.

Greptile Summary

This PR removes dead code surfaced by a whole-app audit, deleting unreferenced symbols across views, models, services, and support files. The only live-code behavioural touch is in OverlayController, where an always-nil currentBundleIdentifier (because its setter was never called) is replaced with a literal nil.

  • Deleted: TagsInputView.swift in full, StatusPill in MenuBarSections, ExtendedContextPlaygroundModel.cancelGeneration(), ModelDownloadManager.cancelAllDownloads(), SuggestionInteractionState.clearContext(), several computed properties in FocusModels, FocusTrackingModel, and CompletionRenderModePolicy, and the emojiSkinToneBinding/wipeForTesting helpers.
  • Simplified: OverlayController.showSuggestion now passes bundleIdentifier: nil directly (identical runtime result) with a code comment pointing future per-app override authors to the right thread point.

Confidence Score: 5/5

Pure dead-code removal with one cosmetic live-code simplification in OverlayController that does not change observable behavior; safe to merge.

Every removed symbol was confirmed to have zero call sites across the app and tests. The only live-code change — passing nil directly where a field that was always nil was previously read — is a no-op refactor backed by a clean full build and SwiftLint run. No logic paths are modified, no data flows are altered, and no tests are deleted.

No files require special attention. The Xcode project file changes are bookkeeping-only and match the Swift file deletions precisely.

Important Files Changed

Filename Overview
Cotabby/Services/UI/OverlayController.swift Removes currentBundleIdentifier property and setCurrentBundleIdentifier method; replaces the always-nil field with a literal nil and adds a comment for future wiring. Behaviour is unchanged.
Cotabby/UI/TagsInputView.swift Entire file deleted — TagsInputView, TagBubble, and FlowLayout had zero references; project.pbxproj entries cleaned up simultaneously.
Cotabby/Models/SuggestionSettingsModel.swift Removes setDebounceMilliseconds and setFocusPollIntervalMilliseconds; the published vars and DefaultsKeys remain intact and are still used by the load/persist paths.
Cotabby/Services/Utilities/ModelDownloadManager.swift Removes cancelAllDownloads(); per-task cancelDownload remains intact; no caller for the bulk helper existed.
Cotabby/UI/Settings/Panes/AdvancedPaneView.swift Removes ExtendedContextPlaygroundModel.cancelGeneration(); method was never wired to a UI element or dismiss handler, so in-flight task cleanup was already absent before this PR.
Cotabby/Models/FocusModels.swift Removes three role/capability summary computed properties from FocusInspectionSnapshot and textPreview from FocusedInputSnapshot; all had no callers.
Cotabby/UI/Settings/Panes/GeneralPaneView.swift Removes private emojiSkinToneBinding; no picker or control in the file or its tests referenced it.
Cotabby/Support/CompletionRenderModePolicy.swift Removes MirrorPreference.helpDescription; the tooltip strings were not wired to any .help() modifier.
Cotabby/Support/FileLogHandler.swift Removes wipeForTesting() test hook that no test called; underlying rotateLocked() remains.
Cotabby/UI/MenuBarSections.swift Removes StatusPill view struct; no reference existed in MenuBarView or elsewhere in the app.
Cotabby/Models/FocusTrackingModel.swift Removes menuBarStatusText and menuBarSymbolName getters; both were unreferenced by MenuBarView or any test.
Cotabby/Services/Suggestion/SuggestionInteractionState.swift Removes clearContext(); resetAll already calls the underlying buffer clear so the method was fully redundant.

Sequence Diagram

sequenceDiagram
    participant Coord as SuggestionCoordinator
    participant OC as OverlayController
    participant Policy as CompletionRenderModePolicy
    participant Panel as OverlayPanel

    Note over Coord,Panel: Before PR — setCurrentBundleIdentifier (dead hook, never called)
    Coord--xOC: setCurrentBundleIdentifier(_:) ❌ never called
    Note over OC: currentBundleIdentifier = nil (always)

    Note over Coord,Panel: After PR — nil passed directly
    Coord->>OC: showSuggestion(_:geometry:)
    OC->>Policy: mode(for: geometry, bundleIdentifier: nil)
    Policy-->>OC: .inline / .mirror(reason:)
    OC->>Panel: setFrame + orderFrontRegardless()
Loading

Reviews (1): Last reviewed commit: "Remove dead code: unused views, methods,..." | Re-trigger Greptile

Whole-app audit (single module) for declared-but-unreferenced symbols.
Each was verified to have zero references across the app and tests before
removal; clean build-for-testing and SwiftLint both pass.

- Views: StatusPill (MenuBarSections) and the whole TagsInputView.swift.
- Methods: SuggestionInteractionState.clearContext (resetAll already
  clears the context), ModelDownloadManager.cancelAllDownloads,
  SuggestionSettingsModel.setDebounceMilliseconds /
  setFocusPollIntervalMilliseconds (no caller; the published values are
  still read and persisted elsewhere), FileLogWriter.wipeForTesting (a
  test hook no test calls), ExtendedContextPlaygroundModel.cancelGeneration.
- Getters: MirrorPreference.helpDescription, FocusTrackingModel
  .menuBarStatusText / .menuBarSymbolName, FocusInspectionSnapshot's three
  role/capability summaries, FocusedInputSnapshot.textPreview, and
  GeneralPaneView.emojiSkinToneBinding (the skin-tone UI writes the setting
  directly).
- OverlayController's never-called setCurrentBundleIdentifier and the
  always-nil currentBundleIdentifier it fed; the render policy now receives
  nil directly (behavior unchanged) until per-app overrides ship.
@FuJacob FuJacob merged commit 5ec00e9 into main Jun 1, 2026
4 checks passed
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