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 Agosti51a03868cfda
diff --git a/internal/cli/hints.go b/internal/cli/hints.goindex 7d91632c..c0bb8546 100644--- a/internal/cli/hints.go+++ b/internal/cli/hints.go@@ -37,23 +37,19 @@ 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".+// The CLI cannot tell whether the server has sessions enabled, so this must be+// true in BOTH states: the applicable half leads, the prerequisite survives as a+// conditional fallback, and the command ends the line so lifting it to+// end-of-line yields exactly the command — it is the only place that command is+// published, and its readers are agents.//-// 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."+// A THIRD state stays wrong and this does not fix it: a bridge has no agent+// sessions at all, so the otherwise-clause cannot help there. The honest enabler+// is exposing the capability in the health payload, which reports nothing about+// it today.+const NoSessionHint = "this tab is shared — no agent session is set. If agent sessions are enabled on this server, create one now; " ++ "otherwise set sessions.agent.enabled = true in config.json and restart first. Either way the command is: " ++ SessionCreateCommand// 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.goindex d6ad20e6..ad495fdd 100644--- a/internal/cli/hints_test.go+++ b/internal/cli/hints_test.go@@ -35,20 +35,52 @@ func TestNoSessionHintHoldsWhetherOrNotSessionsAreEnabled(t *testing.T) {}}- // 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") {+ // Order carries the meaning, and it is the CONDITION clauses that carry it: the+ // half that applies to a working server is read first, and the config change is+ // reachable only through the fallback. This used to measure the position of the+ // command literal instead, which said "clause order" but forbade any layout that+ // moved the command elsewhere — including the copy-safe one below.+ applicable := strings.Index(hint, "If agent sessions are enabled")+ fallback := strings.Index(hint, "otherwise")+ if applicable < 0 {+ t.Errorf("the create half is not conditional, so it reads as available on every server: %q", hint)+ }+ if fallback < 0 {t.Errorf("the enable-and-restart clause is not conditional, so it reads as an instruction to users who need nothing: %q", hint)}+ if applicable >= 0 && fallback >= 0 && applicable > fallback {+ t.Errorf("the enable-and-restart fallback is read before the half that applies to a working server: %q", hint)+ }+}++// The hint is the ONLY place the create command is published — it appears in no+// doc and no skill — so its readers lift it from this line, and an agent lifts it+// to end of line. Anything after it is therefore appended to what gets run.+//+// Ending the hint with the command is the form that holds, not merely "no shell+// separator after it": this command carries a $(...) substitution and an+// assignment, so a trailing clause corrupts it however it is punctuated. A ";"+// runs the prose as a command ("otherwise: command not found"); a space makes the+// following words extra export operands; even a full stop is absorbed into the+// assigned value silently. The separator check is kept as its own assertion+// because it names the sharpest failure.+func TestNoSessionHintEndsWithTheCommandSoItCanBeLifted(t *testing.T) {+ command := strings.Index(NoSessionHint, SessionCreateCommand)+ if command < 0 {+ t.Fatalf("hint no longer carries the create command: %q", NoSessionHint)+ }+ trailing := NoSessionHint[command+len(SessionCreateCommand):]++ for _, separator := range []string{";", "&&", "||", "|", "&"} {+ if strings.HasPrefix(trailing, separator) {+ t.Errorf("the create command is followed by %q, so lifting the line to end-of-line runs the prose after it as a command: %q",+ separator, NoSessionHint)+ }+ }+ if trailing != "" {+ t.Errorf("the create command is not last (followed by %q); it carries $(...) and an assignment, so anything after it lands inside what gets run: %q",+ trailing, NoSessionHint)+ }}// One constant, rendered by both call sites. The temptation once a hint has two halves is