From 50030eca7d03c7d194b55c3deea806612e01d9b9 Mon Sep 17 00:00:00 2001 From: pstayet Date: Tue, 22 Sep 2026 13:41:07 -0700 Subject: [PATCH] Make first-run linking one line and fix three places new users got stuck A first-run test from a phone sign-up to Claude Code started from the phone hit each of these: - The installer can now run a shell command after installing, by the new executable's full path: `curl ... | sh -s -- auth`. On a stock Mac the install directory is not on PATH, so the separate `shell auth` step failed with command not found. Piped into sh, the command gets /dev/tty for its prompts, or no input at all when there is no terminal, never the rest of the script. exec replaces the installer's shell, so it removes its temporary directory before, not on an EXIT trap that would never fire. - The empty Machines page and the app guide's "1. Link your computer" card show that one line. Remote start is left out of it on purpose: it grants remote execution authority, so it stays a choice made at the prompt. - The sign-up page's header "Sign in" link now carries router state, as the foot link already did, so signing in returns to the CLI's link request instead of the sessions list. - `shell auth` waits 15 minutes instead of 5 (sign-in, vault creation and recovery-key confirmation ran past 5) and says to run it again on timeout. - The empty-list command wraps instead of running off the edge of a phone. Rebased onto main: the Sessions empty state is main's SessionStartGuide, the top bar is main's (#242), and README and docs keep main's structure. Tests: installer scenarios for the post-install command, its stdin without a terminal and its temporary directory; AuthShell header link state; setup command, remote start excluded; login timeout and message. Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 41 +++++++++++++++++-------- app/src/components/AuthShell.test.ts | 46 ++++++++++++++++++++++++++++ app/src/components/AuthShell.tsx | 11 +++++-- app/src/lib/setup-command.test.ts | 21 +++++++++++++ app/src/lib/setup-command.ts | 10 ++++++ app/src/routes/Machines.tsx | 10 +++--- app/src/styles/terminal.css | 9 ++++-- docs/content.json | 4 +++ internal/account/login.go | 9 ++++-- internal/account/login_test.go | 11 +++++++ public/install | 21 +++++++++++++ scripts/test-install.sh | 46 +++++++++++++++++++++++++++- 12 files changed, 213 insertions(+), 26 deletions(-) create mode 100644 app/src/components/AuthShell.test.ts create mode 100644 app/src/lib/setup-command.test.ts create mode 100644 app/src/lib/setup-command.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a646ff7..a7ebf890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,18 +4,6 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve ## Unreleased -### Fixed - -- Build with Go 1.26.9, which fixes two `net/http` vulnerabilities - (GO-2026-6613, GO-2026-6617) reported by govulncheck. -- Existing terminal sessions now automatically run “Fit to my screen” once - when their owner opens them, restoring the grid density on laptops and - desktops. Sizing overlaps password lookup and unlock, reusing the connection - for a fresh encrypted screen once the key is ready. Manual fitting stays available. Hidden panes, read-only viewers, - reconnects and renderer changes do not cause repeated resize requests. - `?terminalAutoFit=0` opts out for one page; `VITE_TERMINAL_AUTO_FIT=0` - disables automatic fitting for an app build. - ### Added - A blog at shell.online/blog/, listing every shell.online post published so @@ -24,9 +12,34 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve `blog/posts/`, and the build renders the index, each post, an RSS feed and a sitemap as static pages. See blog/README.md. - `/blogs` and `/blogs//` redirect to the same page under `/blog/`. +- The installer runs a `shell` command once it has installed, by the new + executable's full path, so one pasted line can install and link a machine + before its install directory is on PATH: + `curl -fsSL https://shell.online/install | sh -s -- auth`. Piped into `sh`, + the command gets the terminal for its prompts; with no terminal it gets no + input rather than the rest of the script. + +### Changed + +- The empty Machines page and the app guide's "Link your computer" card give + that one line instead of two separate steps. Remote start stays a separate + choice at the prompt. +- `shell auth` waits 15 minutes for the browser instead of 5. A first link can + mean signing in, creating a vault and confirming its recovery key, and five + minutes ran out partway through. When it does run out it now says to run + `shell auth` again. ### Fixed +- Build with Go 1.26.9, which fixes two `net/http` vulnerabilities + (GO-2026-6613, GO-2026-6617) reported by govulncheck. +- Existing terminal sessions now automatically run “Fit to my screen” once + when their owner opens them, restoring the grid density on laptops and + desktops. Sizing overlaps password lookup and unlock, reusing the connection + for a fresh encrypted screen once the key is ready. Manual fitting stays available. Hidden panes, read-only viewers, + reconnects and renderer changes do not cause repeated resize requests. + `?terminalAutoFit=0` opts out for one page; `VITE_TERMINAL_AUTO_FIT=0` + disables automatic fitting for an app build. - Mobile bottom navigation stays at the visible bottom after the browser scrolls the document to a focused field, instead of leaving an empty strip below it. - Chat preserves code indentation, literal identifiers and fenced blank lines, @@ -38,6 +51,9 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve - Answers that resume after an idle pause continue in the same chat message. - Blue “Reading … as messages” notices are restored. Summary permission switches reflect a successful save immediately instead of waiting for the next poll. +- Signing in from the header link of the sign-up page returns to the terminal + link request that sent you there. It used to land on the sessions list, with + the terminal still waiting for a callback that was never coming. ## [0.25.0] — 2026-10-02 @@ -189,7 +205,6 @@ All notable user-visible changes are recorded here. Versions follow [Semantic Ve so on a machine short of memory an idle session could take 5-30 seconds to echo a keystroke. Existing installs keep the old agent until you run `shell service install`; `shell service status` says when that is needed. - ## [0.23.2] — 2026-09-25 ### Changed diff --git a/app/src/components/AuthShell.test.ts b/app/src/components/AuthShell.test.ts new file mode 100644 index 00000000..1de41910 --- /dev/null +++ b/app/src/components/AuthShell.test.ts @@ -0,0 +1,46 @@ +import { createElement } from "react"; +import { renderToStaticMarkup } from "react-dom/server"; +import { MemoryRouter } from "react-router-dom"; +import { describe, expect, it, vi } from "vitest"; + +/* The link's props are the subject: which page it goes to, and what it carries. */ +const links: { to: unknown; state: unknown }[] = []; +vi.mock("react-router-dom", async (original) => { + const actual = await original(); + return { + ...actual, + Link: (props: { to: unknown; state?: unknown; children?: unknown }) => { + links.push({ to: props.to, state: props.state }); + return null; + }, + }; +}); + +const { AuthShell } = await import("./AuthShell"); + +describe("the header link", () => { + /* + * `shell auth` sends a signed-out browser to /signup with the CLI's request + * in router state. The header's "Sign in" used to drop it, so signing in + * from there landed on the sessions list and the terminal waited for a + * callback that was never coming. + */ + it("carries the page's router state to the other auth page", () => { + links.length = 0; + const from = "/cli/authorize?code_challenge=abc&state=xyz"; + renderToStaticMarkup( + createElement( + MemoryRouter, + { initialEntries: [{ pathname: "/signup", state: { from } }] }, + createElement(AuthShell, { + title: "Create your account.", + dek: "", + headLink: { to: "/login", label: "Sign in" }, + children: null, + }), + ), + ); + /* The wordmark links home too; the header link is the one to /login. */ + expect(links.filter((link) => link.to === "/login")).toEqual([{ to: "/login", state: { from } }]); + }); +}); diff --git a/app/src/components/AuthShell.tsx b/app/src/components/AuthShell.tsx index 96e9378b..f6ba4877 100644 --- a/app/src/components/AuthShell.tsx +++ b/app/src/components/AuthShell.tsx @@ -1,5 +1,5 @@ import { lazy, Suspense, type ReactNode } from "react"; -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; import { Wordmark } from "./Wordmark"; /* @@ -32,13 +32,20 @@ export function AuthShell({ foot, legal, }: AuthShellProps) { + /* + * The header link carries the page's router state across, as the link in + * the foot does. Someone sent here by `shell auth` has the CLI's request in + * that state; dropping it on the way to sign-in landed them on their + * sessions instead, with the terminal still waiting. + */ + const location = useLocation(); return (
{headLink && ( - + {headLink.label} )} diff --git a/app/src/lib/setup-command.test.ts b/app/src/lib/setup-command.test.ts new file mode 100644 index 00000000..8fc3365a --- /dev/null +++ b/app/src/lib/setup-command.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it } from "vitest"; +import { SETUP_COMMAND } from "./setup-command"; + +describe("the setup command", () => { + it("is a single line someone can paste", () => { + expect(SETUP_COMMAND).not.toMatch(/\n/); + }); + + /* + * First-run test: after the bare installer, `shell` was not on PATH on a + * stock Mac, so the installer runs `shell auth` itself. + */ + it("links the machine through the installer", () => { + expect(SETUP_COMMAND).toBe("curl -fsSL https://shell.online/install | sh -s -- auth"); + }); + + /* Remote start grants remote execution authority: a choice made at the prompt, never pasted in. */ + it("leaves remote start to the prompt", () => { + expect(SETUP_COMMAND).not.toContain("--allow-remote-start"); + }); +}); diff --git a/app/src/lib/setup-command.ts b/app/src/lib/setup-command.ts new file mode 100644 index 00000000..d7ff17dd --- /dev/null +++ b/app/src/lib/setup-command.ts @@ -0,0 +1,10 @@ +/** + * The one line that takes a computer from nothing to linked. + * + * The installer runs whatever follows `sh -s --` with the executable it just + * wrote, by full path, so a fresh machine whose install directory is not on + * PATH yet still gets to `shell auth`. Remote start is deliberately not in + * it: it grants remote execution authority, so it stays a choice made at the + * prompt, not one that arrives with a pasted line. + */ +export const SETUP_COMMAND = "curl -fsSL https://shell.online/install | sh -s -- auth"; diff --git a/app/src/routes/Machines.tsx b/app/src/routes/Machines.tsx index 4413e0ef..0510a1ad 100644 --- a/app/src/routes/Machines.tsx +++ b/app/src/routes/Machines.tsx @@ -9,6 +9,7 @@ import { machineOnline } from "../lib/agent"; import { usePageTitle } from "../lib/page-title"; import { ago } from "../lib/time"; import { SearchSelect } from "../components/SearchSelect"; +import { SETUP_COMMAND } from "../lib/setup-command"; const MACHINE_STATUS = [ { value: "all", label: "All machines", detail: "Online and offline machines" }, @@ -171,14 +172,11 @@ export function Machines() {

No machines linked yet.

  1. - Install shell on the machine you want to share from. - - curl -fsSL https://shell.online/install | sh - + On the computer you want to link, paste this into a terminal. + {SETUP_COMMAND}
  2. - Sign that machine in, then approve the request in this browser. - shell auth + Sign in in the browser tab it opens and press Link terminal.
  3. The machine appears in this list.
diff --git a/app/src/styles/terminal.css b/app/src/styles/terminal.css index c2ed9d50..e11496df 100644 --- a/app/src/styles/terminal.css +++ b/app/src/styles/terminal.css @@ -1407,8 +1407,13 @@ button.tab { font-family: var(--mono); font-size: 13.5px; line-height: 1.5; - white-space: pre; - overflow-x: auto; + /* + * Wrapped, not scrolled: on a phone the one-line setup command ran off the + * edge, and a command someone is meant to read and send on has to be seen + * whole. Soft wraps add no newline to what gets copied. + */ + white-space: pre-wrap; + overflow-wrap: anywhere; /* One click takes the whole command, and there is no prompt glyph to strip. */ user-select: all; } diff --git a/docs/content.json b/docs/content.json index f04d83a2..f39727da 100644 --- a/docs/content.json +++ b/docs/content.json @@ -293,6 +293,10 @@ "1. Link your computer", "Create or sign into your account at [app.shell.online](https://app.shell.online/), then run this on the host computer. Complete the approval in your browser.", [ + [ + "curl -fsSL https://shell.online/install | sh -s -- auth", + "Install shell and link this machine in one line, before its install directory is on PATH." + ], [ "shell auth", "Link this machine. Remote start is a separate choice during setup." diff --git a/internal/account/login.go b/internal/account/login.go index 128cc672..577fb7e4 100644 --- a/internal/account/login.go +++ b/internal/account/login.go @@ -15,7 +15,12 @@ import ( ) // LoginTimeout bounds how long the CLI waits for the browser to come back. -const LoginTimeout = 5 * time.Minute +// +// A first link is not only a click: the browser may still have to sign in, +// create a vault, save its recovery key and confirm it. Five minutes ran out +// on people partway through that, and the tab they finished it in then +// landed on a loopback address nothing was listening on any more. +const LoginTimeout = 15 * time.Minute // callbackResult carries what the browser handed back on the loopback listener. type callbackResult struct { @@ -299,7 +304,7 @@ func Login(ctx context.Context, client *Client, options Options) (Credentials, e result = candidate case <-waitContext.Done(): if errors.Is(waitContext.Err(), context.DeadlineExceeded) { - return Credentials{}, fmt.Errorf("timed out after %s waiting for the browser", timeout) + return Credentials{}, fmt.Errorf("timed out after %s waiting for the browser; run 'shell auth' again for a fresh link", timeout) } return Credentials{}, waitContext.Err() } diff --git a/internal/account/login_test.go b/internal/account/login_test.go index 3ec160d3..31094de1 100644 --- a/internal/account/login_test.go +++ b/internal/account/login_test.go @@ -211,6 +211,17 @@ func TestLoginTimesOutWhenTheBrowserNeverReturns(t *testing.T) { if !strings.Contains(err.Error(), "timed out") { t.Fatalf("error = %v, want a timeout", err) } + if !strings.Contains(err.Error(), "run 'shell auth' again") { + t.Fatalf("error = %v, want it to say how to get a fresh link", err) + } +} + +func TestLoginWaitsLongEnoughToSetUpAVault(t *testing.T) { + // Signing in, creating a vault and confirming its recovery key in the + // browser took longer than five minutes in a first-run test. + if LoginTimeout < 15*time.Minute { + t.Fatalf("LoginTimeout = %s, want at least 15m for a first link", LoginTimeout) + } } func TestLoginStopsWhenTheContextIsCancelled(t *testing.T) { diff --git a/public/install b/public/install index 6ff83782..85ca2b52 100755 --- a/public/install +++ b/public/install @@ -11,6 +11,12 @@ set -eu # SHELL_ONLINE_INSTALL_CHECK=1: every request then carries the user agent # shell.online-install-check, which the site counts as a monitor and not as # a person, and nothing is reported. +# +# Anything after the script's own name is a shell command to run once the +# install is done, by the new executable's full path, so it works before the +# install directory is on PATH: +# +# curl -fsSL https://shell.online/install | sh -s -- auth --allow-remote-start curl_agent= wget_agent= if [ "${SHELL_ONLINE_INSTALL_CHECK:-0}" = 1 ]; then @@ -244,6 +250,21 @@ fi "$target" --version report ok + +if [ "$#" -gt 0 ]; then + printf '\nRunning: shell %s\n' "$*" + # exec replaces this shell, so the EXIT trap would never run: clean up first. + rm -rf "$temporary_dir" + trap - EXIT HUP INT TERM + # Piped into sh, this script's stdin is the script itself. Give the command + # the terminal when there is one, so it can prompt, and otherwise nothing: + # never the rest of this script. + if (: /dev/null; then + exec "$target" "$@" Run it in the background and print its browser link\n' printf ' shell help See the guided start, share, and stop flow\n' diff --git a/scripts/test-install.sh b/scripts/test-install.sh index 84696fa8..bccd8680 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -32,7 +32,9 @@ case "$(uname -m)" in esac binary_name=shell-$platform-$architecture -printf '%s\n' '#!/bin/sh' 'printf "shell 9.9.9\\n"' > "$downloads/$binary_name" +# Run with arguments, the mock says what it ran and what its stdin held: a +# terminal, or a byte count, which must be 0 and never the installer's text. +printf '%s\n' '#!/bin/sh' 'if [ "$#" -gt 0 ] && [ "$1" != --version ]; then if [ -t 0 ]; then input=tty; else input=$(wc -c | tr -d " "); fi; printf "ran:%s stdin:%s\\n" "$*" "$input"; exit 0; fi' 'printf "shell 9.9.9\\n"' > "$downloads/$binary_name" chmod 0755 "$downloads/$binary_name" if command -v sha256sum >/dev/null 2>&1; then @@ -178,4 +180,46 @@ if grep -q "install/report" "$report_log"; then exit 1 fi +# Arguments after the script name are a command for the new executable, run +# by its full path so it works before the install directory is on PATH, and +# fed from the pipe the script itself did not come down. +args_install=$test_root/args-install/bin +args_tmp=$test_root/args-tmp +mkdir -p "$args_tmp" +output=$(TMPDIR=$args_tmp SHELL_ONLINE_BASE_URL=$base_url SHELL_ONLINE_INSTALL_DIR=$args_install SHELL=/bin/zsh \ + PATH=/usr/bin:/bin sh -s -- auth --allow-remote-start < "$installer" 2>&1) +assert_contains "$output" "Installed shell to $args_install/shell" +assert_contains "$output" "Running: shell auth --allow-remote-start" +assert_contains "$output" "ran:auth --allow-remote-start stdin:" +case "$output" in + *"Next:"*) + printf 'Installer printed next steps after running a command.\n%s\n' "$output" >&2 + exit 1 + ;; +esac +# With no terminal the command gets no input, never the rest of the script. +case "$output" in + *"stdin:tty"*|*"stdin:0"*) ;; + *) + printf 'The command after install was fed the installer script.\n%s\n' "$output" >&2 + exit 1 + ;; +esac +# exec replaces the installer's shell, so it cleans up before, not on exit. +if [ -n "$(find "$args_tmp" -mindepth 1 -maxdepth 1 -name 'shell-online.*' -print -quit)" ]; then + printf 'Installer left its temporary directory behind after running a command.\n' >&2 + ls -la "$args_tmp" >&2 + exit 1 +fi + +# Without arguments it only installs and says what to do next. +output=$(run_installer "$test_root/no-args/bin" env) +assert_contains "$output" "Next:" +case "$output" in + *"Running:"*) + printf 'Installer ran a command it was not given.\n%s\n' "$output" >&2 + exit 1 + ;; +esac + printf 'Installer integration scenarios passed.\n'