polish(v0.5.4): invocation-name audit + targeted regression tests

Audit walked every cmd/ and internal/ file that produces user-facing
output. All command-form hints (text the user is meant to type back)
were already routed through invocationName() in v0.5.3 — the audit is
a verification pass, not a code rewrite.

Additions:

- Extract formatResumeRestoreHint and formatDirectModeTmuxHint as
  testable string-only helpers. Production paths are unchanged
  behaviorally; the helpers exist purely so the audit can pin down
  the format strings without simulating tmux or stderr capture.

- Two new tests pinning the invocation name to a non-canonical value
  ("my-bin"). The pre-existing tests already protect these surfaces
  but pin the name to "ctask", so they cannot detect a regression
  that hard-codes "ctask" inside the format string. The new tests
  flush that out for the resume restore hint and the Layer-1
  active-session attach hint.

- Drop the duplicated withInvocationName helper accidentally added in
  the info-session tests; reuse the canonical helper from
  persistent_test.go.

Product-identity references ("ctask persistent mode requires tmux",
the SSH-remote `ssh -t <host> ctask <subcmd>` hint, doctor's "[ctask]"
diagnostic prefix, root-command Use:/Long:) deliberately remain
literal per spec §2.
This commit is contained in:
2026-05-14 19:56:05 -04:00
parent 0c8076aba9
commit 0fb8de697b
4 changed files with 81 additions and 17 deletions
+9 -1
View File
@@ -153,9 +153,17 @@ func directModeTmuxHint(opts WorkspaceEntryOptions) string {
if !shell.HasSession(tmuxPath, sessionName) {
return ""
}
return formatDirectModeTmuxHint(opts.WsMeta.Slug)
}
// formatDirectModeTmuxHint builds the hint string itself, with no tmux
// or filesystem checks. Split out so unit tests can verify that the
// command-form line uses invocationName() without needing a live tmux
// session set up against a real workspace.
func formatDirectModeTmuxHint(slug string) string {
return fmt.Sprintf(
"Tip: a tmux session exists for this workspace.\nTo reattach instead of starting a second direct-mode session, run:\n %s attach %s",
invocationName(), opts.WsMeta.Slug)
invocationName(), slug)
}
func invokePersistentRun(opts WorkspaceEntryOptions, tmuxPath, sessionName string) error {