refactor: extract magic strings, decompose long functions, standardize error display#628
Merged
Conversation
…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()
Owner
Author
PR Review SummaryReviewed by: code-reviewer, docs-impact-agent, comment-analyzer, code-simplifier Critical Issues (0 found)None. Code review confirms the refactoring is behavior-preserving across all 18 changed files. Important Issues (3 found)
Suggestions (5 found)
Strengths
Documentation Issues
VerdictREADY TO MERGE — no behavioral issues. The important issues are docstring accuracy improvements and a CLAUDE.md gap that should be addressed (in this PR or a follow-up). |
- Fix kill_tracked_agents docstring: clarify daemon errors are always non-fatal, not gated on force flag - Fix resolve_resume_args docstring: document is_bare_shell parameter and error return paths - Remove .unwrap() in kill_tracked_agents, use indexing instead - Change display_operation_error to use impl Display over &dyn Display - Inline WORKTREE_ADMIN_PREFIX constant (single use site) - Reuse kild_branch variable in pr.rs no_pr_found path - Use imported color module instead of crate::color in teammates.rs - Add kild-git crate to CLAUDE.md workspace structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WORKTREE_ADMIN_PREFIX,SHIM_VERSION, and usekild_branch_name()/KILD_BRANCH_PREFIXconsistently instead of rawformat!("kild/...")literalskill_tracked_agents()andsweep_ui_daemon_sessions()fromdestroy_session(),resolve_resume_args()fromopen_session()display_operation_error()helper and consistentcolor::error()usage across 9 command handlersTest plan
cargo fmt --checkpassescargo clippy --all -- -D warningspassescargo test --allpasses (3 pre-existing env-dependent test failures unrelated to this change)Closes #438