Skip to content

refactor: extract magic strings, decompose long functions, standardize error display#628

Open
Wirasm wants to merge 2 commits intomainfrom
kild/refactor-cleanup
Open

refactor: extract magic strings, decompose long functions, standardize error display#628
Wirasm wants to merge 2 commits intomainfrom
kild/refactor-cleanup

Conversation

@Wirasm
Copy link
Owner

@Wirasm Wirasm commented Mar 4, 2026

Summary

  • Extract magic strings into constants: WORKTREE_ADMIN_PREFIX, SHIM_VERSION, and use kild_branch_name() / KILD_BRANCH_PREFIX consistently instead of raw format!("kild/...") literals
  • Decompose 3 long functions: kill_tracked_agents() and sweep_ui_daemon_sessions() from destroy_session(), resolve_resume_args() from open_session()
  • Standardize CLI error display with display_operation_error() helper and consistent color::error() usage across 9 command handlers

Test plan

  • cargo fmt --check passes
  • cargo clippy --all -- -D warnings passes
  • cargo test --all passes (3 pre-existing env-dependent test failures unrelated to this change)
  • No behavioral changes — pure refactor

Closes #438

Wirasm added 2 commits March 4, 2026 17:26
…e error display

- Add WORKTREE_ADMIN_PREFIX constant to naming.rs alongside KILD_BRANCH_PREFIX
- Use kild_branch_name() instead of raw format!("kild/{}") in pr.rs, detail_view.rs
- Use KILD_BRANCH_PREFIX in kild_branch_name() function body
- Add SHIM_VERSION constant for tmux version string in shim commands

- Extract kill_tracked_agents() from destroy_session() (127 lines → helper)
- Extract sweep_ui_daemon_sessions() from destroy_session() (55 lines → helper)
- Extract resolve_resume_args() from open_session() (46 lines → helper)

- Add display_operation_error() helper for consistent CLI error formatting
- Standardize error display across open, hide, focus, diff, health, stats,
  sync, commits, and teammates commands to use color::error() consistently

Closes #438
…t helpers

- Restore non-fatal comment on daemon cleanup in kill_tracked_agents()
- Change WORKTREE_ADMIN_PREFIX to pub(crate) — no external callers
- Replace raw format!("kild/...") in cleanup/handler.rs and overlaps.rs
  test helpers with kild_branch_name() / kild_worktree_admin_name()
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.

General refactoring: magic strings, long functions, inconsistent error display

1 participant