Skip to content

dedupe shared helpers into internal/util#5

Merged
rjayasin merged 4 commits into
mainfrom
claude/shared-helpers
Jun 23, 2026
Merged

dedupe shared helpers into internal/util#5
rjayasin merged 4 commits into
mainfrom
claude/shared-helpers

Conversation

@rjayasin

@rjayasin rjayasin commented Jun 23, 2026

Copy link
Copy Markdown
Owner

PR 2 of 4 from the review stack. Base: claude/sshx-fixes (PR #4) — the diff shown here is only this PR's changes; merge #4 first.

Two helpers were copy-pasted across packages; both now live in a single internal/util package:

  • Byte formatter existed as ui.humanSize (int64, e.g. 4.2M) and update.humanBytes (int, e.g. 4.2 MB). Both are replaced by util.HumanBytes, giving one consistent style app-wide. The only user-visible change is the rtr update download message, which now reads 4.2M to match the listing style.
  • ~ home-expansion existed three times: sshx.expandHome, transfer.expandHome, ui.expandHomeUI. All three are replaced by util.ExpandHome, using the safe variant that returns the path unchanged when $HOME can't be resolved.

No behavior change beyond the update-message format. go build, go vet, staticcheck -checks=all, and go test -race ./... all pass.

🤖 Generated with Claude Code

claude added 3 commits June 23, 2026 00:39
authMethods dialed the SSH_AUTH_SOCK unix socket but never closed it, so a
long-running session leaked one descriptor per Dial (plus one more per jump
host). The agent is only consulted during authentication, which ssh.Dial /
NewClientConn complete synchronously before Dial returns, so thread a cleanup
func out through clientConfig and defer it once the handshake is done.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvNkzcutbfXNKAKCSy38H1
Every caller (connectCmd, listCmd) immediately re-sorts the result with
ui.sortEntries by the user's chosen mode, so the dirs-first sort in List was
never observed. Removing it also deletes the ASCII-only lessFold/toLower
helpers, which disagreed with the Unicode-aware strings.ToLower used by the
UI sort — a latent inconsistency that can no longer surface.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvNkzcutbfXNKAKCSy38H1
PathSize swallowed every walk error and unconditionally returned nil, so the
error return advertised a failure mode that could not happen and forced a dead
err check at the call site. Return just int64, matching its local-filesystem
twin localPathSize.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvNkzcutbfXNKAKCSy38H1
Two helpers were copy-pasted across packages; both now live in a single
internal/util package:

- A byte-count formatter existed as ui.humanSize (int64, "4.2M") and
  update.humanBytes (int, "4.2 MB"). Both are replaced by util.HumanBytes,
  giving one consistent style app-wide. The only visible change is the
  `rtr update` download message, now "4.2M" to match the listing style.
- A "~" home-expansion helper existed three times: sshx.expandHome,
  transfer.expandHome, and ui.expandHomeUI. All three are replaced by
  util.ExpandHome, using the safe variant that returns the path unchanged
  when $HOME is unresolved.

No behavior change beyond the update-message format.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvNkzcutbfXNKAKCSy38H1
@rjayasin
rjayasin force-pushed the claude/shared-helpers branch from 6d101a3 to f1308ec Compare June 23, 2026 04:16
@rjayasin rjayasin changed the title dedupe shared helpers: human-readable bytes and ~ expansion dedupe shared helpers into internal/util Jun 23, 2026
@rjayasin
rjayasin merged commit e63c313 into main Jun 23, 2026
1 check passed
@rjayasin
rjayasin deleted the claude/shared-helpers branch June 23, 2026 06:33
rjayasin added a commit that referenced this pull request Jul 14, 2026
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.

2 participants