Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

docs: the landed-URL promise holds for three commands, not four (PIN-075)

Luigi Agosti95ad7a1a1aa6
diff --git a/docs/commands.md b/docs/commands.md
index d599d265..2831e4c5 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -34,11 +34,14 @@ pinchtab forward # Go forward in the active tab
pinchtab reload # Reload the active tab
```
-`nav`, `back`, `forward` and `reload` report the URL the page actually landed on,
-so a redirect, a login wall or an error page is visible without `--snap`. `nav`
-prints the tab ID first and the landed URL after it, and prints the tab ID alone
-when stdout is not a terminal or when `--print-tab-id` is passed — so
-`TAB=$(pinchtab nav <url>)` still captures a usable tab ID.
+`back`, `forward` and `reload` always report the URL the page actually landed on,
+so a redirect, a login wall or an error page is visible without `--snap`.
+
+`nav` is different, because its stdout is a value other commands consume: it
+prints the tab ID first, and adds the landed URL only when stdout is a terminal.
+Under `--print-tab-id`, a pipe or a redirect, stdout carries the tab ID alone, so
+`TAB=$(pinchtab nav <url>)` captures a usable tab ID. A scripted navigation that
+needs to know where it landed should ask for `--snap`, `--text` or `--json`.
## Tabs
diff --git a/internal/cli/actions/actions_navigate_test.go b/internal/cli/actions/actions_navigate_test.go
index df60dd95..1d6365bb 100644
--- a/internal/cli/actions/actions_navigate_test.go
+++ b/internal/cli/actions/actions_navigate_test.go
@@ -378,6 +378,14 @@ func TestHistoryNavigationPrintsTheLandedURL(t *testing.T) {
m.response = `{"tabId":"ABC123","url":"https://example.com/landed"}`
defer m.close()
+ // Not a terminal, stated rather than inherited. These three have no
+ // tab ID on stdout to protect, so unlike nav they report the landed
+ // URL through a pipe too. Asserting it here is what stops that
+ // difference from being "fixed" in either direction by accident.
+ old := stdoutIsTerminal
+ stdoutIsTerminal = func() bool { return false }
+ t.Cleanup(func() { stdoutIsTerminal = old })
+
out := captureStdout(t, func() {
tc.run(m.server.Client(), m.base(), "", newHistoryCmd())
})
@@ -386,7 +394,7 @@ func TestHistoryNavigationPrintsTheLandedURL(t *testing.T) {
t.Fatalf("path = %q, want %q", m.lastPath, tc.path)
}
if got := strings.TrimSpace(out); got != "https://example.com/landed" {
- t.Errorf("stdout = %q, want the landed URL", got)
+ t.Errorf("stdout = %q, want the landed URL even when stdout is not a terminal", got)
}
})
}