Skip to content

Remove dead code and stale diagnostics#801

Merged
FuJacob merged 1 commit into
mainfrom
agent/remove-dead-code
Jul 18, 2026
Merged

Remove dead code and stale diagnostics#801
FuJacob merged 1 commit into
mainfrom
agent/remove-dead-code

Conversation

@FuJacob

@FuJacob FuJacob commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Remove verified dead code, stale diagnostics, and obsolete tracked artifacts so the shipped app exposes only behavior that has an active caller.

  • remove unused suggestion/focus diagnostic mirrors while preserving structured logs and active state-machine behavior
  • narrow stale emoji, runtime, settings, permission, onboarding, and API model surfaces; keep assertion-only conveniences in the test target
  • delete the obsolete test-target migration script, an unreferenced README image, and a committed Claude lock file; ignore future lock files

Validation

xcodegen generate
# project regenerated with no tracked project-file diff

xcodebuild -project Cotabby.xcodeproj -scheme Cotabby \
  -destination 'platform=macOS' build-for-testing \
  -derivedDataPath build/DerivedData
# ** TEST BUILD SUCCEEDED **

xcodebuild -project Cotabby.xcodeproj -scheme Cotabby \
  -destination 'platform=macOS' test \
  -derivedDataPath build/DerivedData \
  CODE_SIGN_IDENTITY='Apple Development'
# ** TEST SUCCEEDED ** — 1,668 tests, 7 skipped, 0 failures

swiftformat --lint --rules unusedPrivateDeclarations Cotabby CotabbyTests
# 0/404 files require formatting

git diff --check
# clean

Linked issues

None.

Risk / rollout notes

No user-facing feature behavior is intentionally changed. The two broadest removals are the unused FocusInspectionSnapshot construction path and unused @Published suggestion-debug mirrors; focus capability selection, overlay state, correlation IDs, and structured logging remain active and are covered by the full test suite.

Greptile Summary

This PR removes verified dead code across 83 files: diagnostic @Published mirrors from SuggestionCoordinator, the unused FocusInspectionSnapshot construction path, convenience wrappers that had no runtime callers, and narrowed model surfaces (emoji, runtime, settings, permissions). Test helpers previously duplicated in production are moved to the test target; structured logs and active state-machine behavior are fully preserved.

  • SuggestionCoordinator: 12 @Published debug properties (latestSuggestionPreview, latestStageMessage, latestAcceptanceAction, etc.) removed; state and overlayState downgraded from @Published to plain var since no SwiftUI view subscribes to them. hasSuggestionArtifactsToClear now checks the real session object instead of the removed diagnostic mirrors.
  • Focus system: FocusInspectionSnapshot, FocusCapabilityResolution.resolvedCandidate/bestDiagnosticCandidate/inspectedCandidateCount, and the top-level FocusCapabilityResolver.resolve() entry point are removed; FocusSnapshotResolver now tracks only the winning evaluation score for tie-breaking, not the full candidate tuple.
  • Test target consolidation: LlamaGenerationOutput.text(), ActiveSuggestionSession.acceptedText, SuggestionTextNormalizer.normalize(), and other assertion-only conveniences are moved to the test module, keeping the production API surface minimal.

Confidence Score: 5/5

Safe to merge. All removed code was diagnostic-only with no active runtime callers, verified by 1,668 passing tests.

Every removal is a diagnostic mirror, dead wrapper, or unused model field. The active state-machine paths (overlay visibility, session tracking, focus capability selection, structured logging) are all preserved and covered by the test suite. The one flagged item is a doc-comment fragment left by a partial line removal — no logic is affected.

SettingsAttentionEvaluator.swift has a minor broken doc-comment sentence that should be cleaned up before merge.

Important Files Changed

Filename Overview
Cotabby/App/Coordinators/SuggestionCoordinator.swift Removes 12 diagnostic @published properties and downgrades state/overlayState to plain var; no UI view was subscribing to these fields, so the change correctly eliminates redundant objectWillChange fires.
Cotabby/App/Coordinators/SuggestionCoordinator+Prediction.swift Removes applySessionDiagnostics calls and latestLatencyMilliseconds/latestPromptPreview/latestRawModelOutput assignments; updates hasSuggestionArtifactsToClear to use interactionState.activeSession instead of removed mirrors.
Cotabby/Support/Focus/FocusCapabilityResolver.swift Removes the FocusCapabilityResolver.resolve() entry point and the bestDiagnosticCandidate/resolvedCandidate/inspectedCandidateCount properties from FocusCapabilityResolution; only the evaluate() primitive and unsupportedReason are kept.
Cotabby/Services/Focus/FocusSnapshotResolver.swift Drops the FocusInspectionSnapshot construction path and the diagnosticCandidate tracking; bestPartial is now just FocusCapabilityCandidateEvaluation? since the candidate identity was only needed for diagnostics.
Cotabby/Support/Settings/SettingsAttentionEvaluator.swift Removes calloutMessage() and the foundationModelMessage input; a doc-comment fragment is left dangling after partial line removal.
Cotabby/Models/Suggestion/SuggestionPresentationModels.swift Removes shortLabel/detail/visibleText from OverlayState and SuggestionDebugState; isVisible and visibleMode are kept for active logic paths.
Cotabby/Models/Focus/FocusModels.swift Removes FocusInspectionSnapshot struct, FocusSnapshot.inspection field, and the capabilitySummary convenience property; FocusSnapshot.inactive updated accordingly.
CotabbyTests/TestSupport/CotabbyTestFixtures.swift Gains two test-target-only extensions: ActiveSuggestionSession.acceptedText and LlamaGenerationOutput.text(), both moved from production types where they had no runtime callers.
Cotabby/Models/Runtime/OpenAICompatibleEndpointModels.swift Removes OpenAICompatibleAPIMode.displayLabel and OpenAICompatibleModelOption.ownedBy (plus its CodingKeys); JSON decoder silently ignores the extra owned_by key on decode.
Cotabby/Models/Emoji/EmojiPickerModels.swift Removes EmojiEntry.group/unicodeVersion (extra JSON keys are silently dropped by Decodable), EmojiMatch.primaryAlias, and EmojiVariantPreferences.default static property.
Cotabby/Support/Suggestion/SuggestionTextNormalizer.swift Removes the normalize() convenience wrapper from production; re-declared as a private extension in SuggestionTextNormalizerTests.swift for tests that only need the output string.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Before["Before: SuggestionCoordinator (12 @Published debug mirrors)"]
        B1["@Published state\n@Published overlayState\n@Published latestSuggestionPreview\n@Published latestAcceptanceAction\n@Published latestStageMessage\n@Published latestOverlayMessage\n@Published latestPromptPreview\n@Published latestRawModelOutput\n@Published latestLatencyMilliseconds\n... (+ 3 more)"]
    end
    subgraph After["After: SuggestionCoordinator (lean state)"]
        A1["var state  ← plain var, no re-render\nvar overlayState  ← plain var, no re-render\nvar latestGenerationNumber  ← kept (active logic)\n@Published visualContextStatus  ← kept (UI)\n@Published totalTabAcceptedWordCount  ← kept (UI)"]
    end
    subgraph FocusBefore["Before: Focus resolution pipeline"]
        FB1["FocusCapabilityResolver.resolve()\n→ FocusCapabilityResolution\n   .resolvedCandidate\n   .bestDiagnosticCandidate\n   .missingCapabilities\n   .inspectedCandidateCount"]
        FB2["FocusSnapshotResolver\n→ FocusCandidateResolution\n   .resolvedCandidate (AXFocusCandidate)\n   .diagnosticCandidate (AXFocusCandidate)\n   .resolution"]
        FB3["FocusSnapshot\n   .inspection (FocusInspectionSnapshot)\n   .capabilitySummary"]
    end
    subgraph FocusAfter["After: Focus resolution pipeline"]
        FA1["FocusCapabilityResolver.evaluate()\n→ FocusCapabilityResolution\n   .unsupportedReason"]
        FA2["FocusSnapshotResolver\n→ FocusCandidateResolution\n   .resolvedCandidate (AXFocusCandidate)\n   .resolution"]
        FA3["FocusSnapshot\n   (no inspection field)"]
    end
    Before --> After
    FocusBefore --> FocusAfter
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    subgraph Before["Before: SuggestionCoordinator (12 @Published debug mirrors)"]
        B1["@Published state\n@Published overlayState\n@Published latestSuggestionPreview\n@Published latestAcceptanceAction\n@Published latestStageMessage\n@Published latestOverlayMessage\n@Published latestPromptPreview\n@Published latestRawModelOutput\n@Published latestLatencyMilliseconds\n... (+ 3 more)"]
    end
    subgraph After["After: SuggestionCoordinator (lean state)"]
        A1["var state  ← plain var, no re-render\nvar overlayState  ← plain var, no re-render\nvar latestGenerationNumber  ← kept (active logic)\n@Published visualContextStatus  ← kept (UI)\n@Published totalTabAcceptedWordCount  ← kept (UI)"]
    end
    subgraph FocusBefore["Before: Focus resolution pipeline"]
        FB1["FocusCapabilityResolver.resolve()\n→ FocusCapabilityResolution\n   .resolvedCandidate\n   .bestDiagnosticCandidate\n   .missingCapabilities\n   .inspectedCandidateCount"]
        FB2["FocusSnapshotResolver\n→ FocusCandidateResolution\n   .resolvedCandidate (AXFocusCandidate)\n   .diagnosticCandidate (AXFocusCandidate)\n   .resolution"]
        FB3["FocusSnapshot\n   .inspection (FocusInspectionSnapshot)\n   .capabilitySummary"]
    end
    subgraph FocusAfter["After: Focus resolution pipeline"]
        FA1["FocusCapabilityResolver.evaluate()\n→ FocusCapabilityResolution\n   .unsupportedReason"]
        FA2["FocusSnapshotResolver\n→ FocusCandidateResolution\n   .resolvedCandidate (AXFocusCandidate)\n   .resolution"]
        FA3["FocusSnapshot\n   (no inspection field)"]
    end
    Before --> After
    FocusBefore --> FocusAfter
Loading

Fix All in Codex Fix All in Claude Code

Reviews (1): Last reviewed commit: "Remove dead code and stale diagnostics" | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@FuJacob
FuJacob force-pushed the agent/remove-dead-code branch from 97f3384 to add17f8 Compare July 18, 2026 03:19
@FuJacob
FuJacob marked this pull request as ready for review July 18, 2026 03:22
@FuJacob
FuJacob merged commit 5c1dcf6 into main Jul 18, 2026
4 checks passed
@FuJacob
FuJacob deleted the agent/remove-dead-code branch July 18, 2026 03:22
Comment on lines 9 to +11
/// redesign surfaces attention per pane: a sidebar dot signals "look in here," and the affected
/// pane carries an inline callout next to the controls that fix the underlying problem. Keeping
/// the rule outside the view layer makes it unit-testable without AppKit and keeps the sidebar
/// view free of state-mapping logic.
/// Keeping the rule outside the view layer makes it unit-testable without AppKit and keeps the
/// sidebar view free of state-mapping logic.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The doc comment has a dangling fragment after the partial removal. The sentence "a sidebar dot signals 'look in here,' and the affected" was left without its continuation ("pane carries an inline callout…"), producing unreadable prose.

Suggested change
/// redesign surfaces attention per pane: a sidebar dot signals "look in here," and the affected
/// pane carries an inline callout next to the controls that fix the underlying problem. Keeping
/// the rule outside the view layer makes it unit-testable without AppKit and keeps the sidebar
/// view free of state-mapping logic.
/// Keeping the rule outside the view layer makes it unit-testable without AppKit and keeps the
/// sidebar view free of state-mapping logic.
/// redesign surfaces attention per pane: a sidebar dot signals "look in here." Keeping the rule
/// outside the view layer makes it unit-testable without AppKit and keeps the sidebar view free
/// of state-mapping logic.

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 in Claude Code

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