High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: the no-session hint tells users with sessions already enabled to enable them and restart, because one static string serves both states (PIN-112)
Luigi Agosti10caab1d148e
diff --git a/internal/cli/hints.go b/internal/cli/hints.goindex cad7d668..7d91632c 100644--- a/internal/cli/hints.go+++ b/internal/cli/hints.go@@ -37,11 +37,23 @@ func WriteCommandHints(out io.Writer, heading string, hints []CommandHint, widthconst SessionCreateCommand = "export PINCHTAB_SESSION=$(pinchtab session create --agent-id <id>)"// NoSessionHint is the single wording for "this caller has no agent session".-// It names the server-side prerequisite before the command, because the command-// exits 1 with "agent sessions are not enabled on this server" on default-// config — so a user following the hint top to bottom cannot dead-end.-const NoSessionHint = "this tab is shared — no agent session is set. Agent sessions must be enabled on the server " +- "(sessions.agent.enabled = true in config.json, then restart); once they are, create one with: " + SessionCreateCommand+//+// It must hold in BOTH server states, which is why the enable-and-restart clause is+// conditional and comes last. It used to lead with "agent sessions must be enabled",+// which kept a reader on default config from dead-ending in the command's own+// "agent sessions are not enabled on this server" — but told every correctly+// configured user to change config that was already right and restart a server that+// needed no restart. This is the most-printed string in the product, so it says the+// applicable half first and keeps the prerequisite as the fallback: a reader on+// either server still reaches a working outcome by following it top to bottom.+//+// A THIRD state is still wrong here and this wording does not fix it: on a bridge+// there are no agent sessions at all, so the otherwise-clause cannot help. Fixing+// that needs the capability in the health payload (nothing there reports whether+// agent sessions are enabled today) so the caller can pick a branch; do not read+// this constant as true on a bridge.+const NoSessionHint = "this tab is shared — no agent session is set. If agent sessions are enabled on this server, create one with: " ++ SessionCreateCommand + "; otherwise set sessions.agent.enabled = true in config.json and restart first."// NextStepsRunningHints is the "Next steps" group shown when the server is up;// shared by the root banner and `pinchtab health` so the two stay in lockstep.diff --git a/internal/cli/hints_test.go b/internal/cli/hints_test.gonew file mode 100644index 00000000..d6ad20e6--- /dev/null+++ b/internal/cli/hints_test.go@@ -0,0 +1,63 @@+package cli++import (+ "strings"+ "testing"+)++// The hint is state-blind by design — the CLI cannot know whether the server has agent+// sessions enabled without a new health field or a round trip per nav — so the wording+// has to be TRUE in both states rather than correct in one. These assertions are on the+// properties that make that so, not on the sentence, because the sentence will be+// reworded again and a full-string compare would only pin today's phrasing.+func TestNoSessionHintHoldsWhetherOrNotSessionsAreEnabled(t *testing.T) {+ hint := NoSessionHint++ // The enabled server is the state the previous wording got wrong: it asserted the+ // prerequisite as an unmet requirement, so a correctly configured user was told to+ // change config that was already right and restart a server that needed no restart.+ for _, imperative := range []string{+ "must be enabled",+ "Agent sessions must be",+ "then restart)",+ } {+ if strings.Contains(hint, imperative) {+ t.Errorf("hint asserts %q as an unmet requirement, which is false on a server that already has sessions enabled: %q", imperative, hint)+ }+ }++ // The disabled server keeps the no-dead-end property: the prerequisite is still+ // named, so a reader following the hint top to bottom does not land in the command's+ // own "agent sessions are not enabled on this server" with nowhere to go.+ for _, needed := range []string{"sessions.agent.enabled = true", "restart", SessionCreateCommand} {+ if !strings.Contains(hint, needed) {+ t.Errorf("hint no longer carries %q; a reader on default config dead-ends without it: %q", needed, hint)+ }+ }++ // Order carries the meaning. The clause that applies to a working server comes+ // first, and the config change is reachable only through a conditional — that is+ // what stops it reading as an instruction to everyone.+ command := strings.Index(hint, SessionCreateCommand)+ fallback := strings.Index(hint, "sessions.agent.enabled = true")+ if command < 0 || fallback < 0 || command > fallback {+ t.Errorf("the create command must come before the enable-and-restart clause, so the applicable half is read first: %q", hint)+ }+ if !strings.Contains(hint, "If agent sessions are enabled") {+ t.Errorf("the create command is not conditional, so it reads as available on every server: %q", hint)+ }+ if !strings.Contains(hint, "otherwise") {+ t.Errorf("the enable-and-restart clause is not conditional, so it reads as an instruction to users who need nothing: %q", hint)+ }+}++// One constant, rendered by both call sites. The temptation once a hint has two halves is+// to specialise it per caller, which is how the two states drift apart again.+func TestNoSessionHintIsOneLineSoBothCallSitesRenderItWhole(t *testing.T) {+ if strings.Contains(NoSessionHint, "\n") {+ t.Errorf("hint spans lines; output.Hint prefixes a single HINT: line, so a newline breaks both call sites' formatting: %q", NoSessionHint)+ }+ if strings.TrimSpace(NoSessionHint) != NoSessionHint {+ t.Errorf("hint has surrounding whitespace, which shows up after HINT:: %q", NoSessionHint)+ }+}