Skip to content

Clean up the codebase: remove dead code and duplication - #2

Merged
pch merged 2 commits into
mainfrom
t3/5bd0c99d
Oct 22, 2026
Merged

pch merged 2 commits into
mainfrom
t3/5bd0c99d

Conversation

@pch

@pch pch commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Code review cleanup ahead of the repository going public. Intended to be behavior-preserving apart from the bug fixes listed below.

Changes

Dead code removed

  • Empty ReposResponse, a leftover _ = status in completion detection, a fetchRepos() wrapper that only called fetchAllRepos()
  • Decoded-but-unused fields (Repository.htmlUrl, expiresIn, tokenType, scope, GitHubUser.id, AppInstallation.account, WorkflowRunsResponse.totalCount)
  • Hand-written memberwise initializers and CodingKeys lists (the decoders now use .convertFromSnakeCase)
  • A redundant stopPolling(), an unnecessary panel-tracking set in AppDelegate, and a duplicate .environmentObject

Duplication removed

  • The "check installation → poll or wait" startup was pasted in start() and loginWithGitHub(); now startMonitoring(token:)
  • GitHubAPIClient: one get helper for status checks and decoding, one generic paginator, one task-group body
  • OAuthService: one post helper
  • The GitHub App client ID and installation URL now live in GitHubApp; the 200-repo cap and default settings are named constants
  • Shared .textButtonStyle() (about 15 copies) and QuitButton (4 copies); a single source for status colors and the run title; saveSettings() replaces 4 separate save calls

Organization

  • API response types moved to Models/GitHubModels.swift
  • Workflow filtering, the per-repo run limit and overall status are now pure functions on [WorkflowRun]
  • OAuthService is a struct (it was a stateless actor)
  • SettingsView split into named sections

SwiftUI

  • @Environment(\.openURL) and Link instead of NSWorkspace in views
  • A .task loop instead of a Timer.publish that was recreated on every render
  • Rows are Buttons instead of onTapGesture
  • Accessibility labels on icon-only buttons; real picker labels with .labelsHidden()
  • foregroundStyle, .onChange(initial:), @ViewBuilder instead of Group, private environment objects

Behavior changes (bug fixes)

  1. fetchAllRepos compared the running total across all installations with a single installation's total_count, so it could skip repos from a second installation.
  2. A failed Keychain save showed as "Network error: …"; it now has its own KeychainError.
  3. isLoading could stay true after an invalid token forced a sign-out.
  4. Workflow rows now dim slightly while pressed, since they're buttons.

Testing

  • Debug and Release builds succeed with no warnings.
  • A scratch script checked decoding of realistic GitHub payloads and the filter, run-limit, overall-status and relative-time logic.
  • The app was not launched. An unsigned build can delete the Keychain token when it reads it, so the UI still needs a manual check.

🤖 Generated with Claude Code

pch and others added 2 commits October 21, 2026 22:09
- Remove unused types, decoded-but-unused fields, redundant initializers
  and CodingKeys (decode with convertFromSnakeCase instead)
- Share request, status-check and pagination code in GitHubAPIClient
- Deduplicate the install-check/polling startup in AppState
- Move API response types to GitHubModels.swift and run filtering into
  pure functions on the model
- Centralize the GitHub App client ID and installation URL
- Extract shared button styling and QuitButton; split SettingsView into
  sections
- Adopt current SwiftUI idioms: openURL/Link, foregroundStyle, .task
  instead of a per-render Timer.publish, buttons for clickable rows,
  accessibility labels for icon-only buttons and pickers

Also fixes repos from a second installation being skipped, a misleading
"Network error" for Keychain failures, and a spinner that could stay on
after an invalid token signed the user out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restores main's apply-once behavior without the NSHashTable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pch
pch merged commit b89e842 into main Oct 22, 2026
1 check 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