Skip to content

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

feat: add pinchtab config token subcommand and dashboard hints

Boschf4ea2983a9ff
diff --git a/cmd/pinchtab/cmd_config.go b/cmd/pinchtab/cmd_config.go
index 8064b30f..1482695d 100644
--- a/cmd/pinchtab/cmd_config.go
+++ b/cmd/pinchtab/cmd_config.go
@@ -55,6 +55,14 @@ func init() {
handleConfigValidate()
},
})
+ configCmd.AddCommand(&cobra.Command{
+ Use: "token",
+ Short: "Copy the API token to clipboard",
+ Long: "Copies the configured server.token to the system clipboard. The token is never printed to stdout.",
+ Run: func(cmd *cobra.Command, args []string) {
+ handleConfigTokenCopy()
+ },
+ })
configCmd.AddCommand(&cobra.Command{
Use: "get <path>",
Short: "Get a config value (e.g., server.port)",
@@ -282,6 +290,14 @@ func clipboardCommands() []clipboardCommand {
}
}
+func handleConfigTokenCopy() {
+ cfg := loadLocalConfig()
+ if err := copyConfigToken(cfg.Token); err != nil {
+ fmt.Fprintln(os.Stderr, cli.StyleStderr(cli.ErrorStyle, err.Error()))
+ os.Exit(1)
+ }
+}
+
func handleConfigInit() {
configPath := workflow.CurrentConfigPath()
diff --git a/cmd/pinchtab/cmd_config_test.go b/cmd/pinchtab/cmd_config_test.go
index 2a1022c7..d8c1eb78 100644
--- a/cmd/pinchtab/cmd_config_test.go
+++ b/cmd/pinchtab/cmd_config_test.go
@@ -196,6 +196,43 @@ func TestConfigGetMasksServerToken(t *testing.T) {
}
}
+func TestConfigTokenSubcommandCopiesToClipboard(t *testing.T) {
+ configPath := filepath.Join(t.TempDir(), "config.json")
+ t.Setenv("PINCHTAB_CONFIG", configPath)
+ t.Setenv("PINCHTAB_TOKEN", "")
+
+ fc := config.DefaultFileConfig()
+ fc.Server.Token = "test-token-for-clipboard"
+ if err := config.SaveFileConfig(&fc, configPath); err != nil {
+ t.Fatalf("SaveFileConfig() error = %v", err)
+ }
+
+ t.Cleanup(func() {
+ rootCmd.SetArgs(nil)
+ })
+
+ output := captureStdout(t, func() {
+ rootCmd.SetArgs([]string{"config", "token"})
+ if err := rootCmd.Execute(); err != nil {
+ t.Fatalf("Execute() error = %v", err)
+ }
+ })
+
+ if strings.Contains(output, "test-token-for-clipboard") {
+ t.Fatalf("expected token to stay hidden, got %q", output)
+ }
+}
+
+func TestCopyConfigTokenReturnsErrorWhenEmpty(t *testing.T) {
+ err := copyConfigToken("")
+ if err == nil {
+ t.Fatal("expected error for empty token")
+ }
+ if !strings.Contains(err.Error(), "empty") {
+ t.Fatalf("expected empty token error, got %q", err.Error())
+ }
+}
+
func TestConfigSetMasksServerTokenInOutput(t *testing.T) {
configPath := filepath.Join(t.TempDir(), "config.json")
t.Setenv("PINCHTAB_CONFIG", configPath)
diff --git a/dashboard/src/pages/LoginPage.tsx b/dashboard/src/pages/LoginPage.tsx
index 5c7f68ad..2fcb472c 100644
--- a/dashboard/src/pages/LoginPage.tsx
+++ b/dashboard/src/pages/LoginPage.tsx
@@ -45,6 +45,13 @@ export default function LoginPage() {
This PinchTab server requires a bearer token before the dashboard
can load protected routes and APIs.
</p>
+ <p className="mt-1 text-xs leading-5 text-text-muted">
+ Run{" "}
+ <code className="rounded bg-[rgb(var(--brand-surface-code-rgb)/0.72)] px-1.5 py-0.5 text-text-secondary">
+ pinchtab config token
+ </code>{" "}
+ to copy the token to your clipboard.
+ </p>
</div>
<form
diff --git a/dashboard/src/pages/settings/NetworkSettingsSection.tsx b/dashboard/src/pages/settings/NetworkSettingsSection.tsx
index 76eea6fe..244d05c8 100644
--- a/dashboard/src/pages/settings/NetworkSettingsSection.tsx
+++ b/dashboard/src/pages/settings/NetworkSettingsSection.tsx
@@ -74,9 +74,18 @@ export function NetworkSettingsSection({
>
<div className="space-y-2">
<div className="text-xs leading-5 text-text-muted">
- {backendState?.tokenConfigured
- ? "Token configured. Manage rotation through the CLI or config file; the current value is never returned by the server."
- : "No token configured. Set one through the CLI or config file."}
+ {backendState?.tokenConfigured ? (
+ <>
+ Token configured. Manage rotation through the CLI or config
+ file; the current value is never returned by the server. Run{" "}
+ <code className="rounded bg-[rgb(var(--brand-surface-code-rgb)/0.72)] px-1 py-0.5 text-text-secondary">
+ pinchtab config token
+ </code>{" "}
+ to copy it to your clipboard.
+ </>
+ ) : (
+ "No token configured. Set one through the CLI or config file."
+ )}
</div>
{apiTokenMissing && (
<div className="rounded-sm border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs leading-5 text-destructive">