Skip to content

docs(guide): a public HTTPS address with Portal - #229

Merged
devswha merged 2 commits into
devswha:mainfrom
rabbitson87:docs/portal-public-address
Oct 8, 2026
Merged

devswha merged 2 commits into
devswha:mainfrom
rabbitson87:docs/portal-public-address

Conversation

@rabbitson87

@rabbitson87 rabbitson87 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Change

Step 1 of #202. Adds Portal to Behind a reverse proxy in docs/guide.md, right after the 401 check. It also mentions Portal in the access table's "A public domain, reverse proxy or Portal" row, adds a bullet to the FAQ "Do I need Tailscale?", and adds a CHANGELOG line.

  • Version: Portal v2.6.1 (released 2026-10-05). From that release --http-route keeps the browser's Host, sends X-Forwarded-For and X-Forwarded-Proto: https, and passes the WebSocket upgrade (fix(sdk): keep the browser Host and https scheme in routed HTTP gosuda/portal-tunnel#545). It can also drop a request header with --strip-request-header (feat: harden public HTTP exposure with --strip-request-header (fixes #556) gosuda/portal-tunnel#564). The plain portal expose 7317 sends no X-Forwarded-Proto, so a browser gets invalid_origin.
  • Tailscale, first and in bold: the command drops a visitor's Tailscale-User-Login with --strip-request-header, and the warning says to keep that on a PC that runs Tailscale and not to combine Portal with HERDR_WEB_TAILSCALE_SERVE_ONLY=1. Since fix(access): ask for the token before trusting a Tailscale login header #309 a token also stops a forged header; without one, the header would get a visitor in.
  • Command: split over five lines with \, so it reads on a phone.
  • Relay: a relay running Portal's code passes the encrypted bytes on and sees only connection metadata, but it holds its domain's certificate, so the section says to use one you trust.
  • Token: a long random HERDR_WEB_TOKEN (openssl rand -hex 32), with a pointer to where settings go.
  • Address: v2.6.1 prints an identity-bound address, https://<name>-<address>.<relay> (feat: define address-bound service identities and canonical hostnames gosuda/portal-tunnel#567). No other identity can take it, even while Portal is stopped, so the section says to use that address and not the short <name>.<relay> alias, which can be reused. A v2.6.1 client needs a relay on v2.6.1 or later, which portal list shows.
  • Check: the same 401 check as the other proxies, against that address.
  • The section is a block of paragraphs inside Behind a reverse proxy, like the Caddy and nginx examples. A heading after the 401 line would have pulled "Sign out" and the paragraphs after it under Portal.

Docs only; no code changes.

Validation

  • Checked against decideAccess and cameThroughProxy in server/access.ts, sameOrigin in server/machine-security.ts, and the current "Behind a reverse proxy" text, at main 8a5ac49 (after v0.4.0).
  • Portal v2.6.1:
    • every flag in the command exists, and --strip-request-header requires --http-route, which the command has;
    • the printed URL is the relay's canonical_hostname, <name>-<40 hex>, and names are limited to 22 characters (the command's name is 22);
    • the client refuses a relay that returns no canonical hostname;
    • portal list shows gosunuts.xyz, portal.dawnfullstack.com and kakashit.org on v2.6.1;
    • the relay reads only the ClientHello for routing (portal/server.go:808) and copies bytes (portal/proxy.go:26); the tunnel ends TLS (sdk/listener.go:649); the relay holds the wildcard certificate (portal/acme/certificate.go:42).
  • Anchors #behind-a-reverse-proxy and #in-a-terminal render, and the Portal links return 200.
  • End-to-end run: done through gosunuts.xyz (v2.6.1): token sign-in in a real browser, the terminal over /ws, pairing a device, the 401 and refusal checks, and the header strip. Push alerts were not tested (the automation browser has no PushManager); details in the comment below.

Prepared with Claude Code; the claims above are checked against the code they cite.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2312d06b-1f29-4ef9-a659-c0630eb66abe
📥 Commits

Reviewing files that changed from the base of the PR and between 8a5ac49 and df5a98e.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • docs/guide.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Documentation
    • Updated the access guide and FAQ with instructions for making the app available at a public HTTPS address through Portal v2.6.1 or later.
    • Clarified that public access requires a long random token and reverse-proxy configuration, including handling of identity headers.
    • Added a check to confirm unauthenticated session requests are rejected.

Walkthrough

The guide and changelog add Portal instructions for public HTTPS access. The guide covers proxy behavior, token and relay settings, identity handling, and an unauthenticated /api/session check.

Changes

Portal public access

Layer / File(s) Summary
Document Portal public access setup
docs/guide.md, CHANGELOG.md
The access table and FAQ list Portal as a public-address option requiring a token, HTTPS, and the reverse-proxy instructions. The guide documents Portal v2.6.1+ setup, proxy headers, relay and identity settings, and a check that an unauthenticated /api/session request returns 401. The changelog records the guide update.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Other

Suggested reviewers: devswha

Merge Risk: ⚪ Minimal · up to df5a9

The Portal guide’s setup instructions match the documented Portal behavior and the app’s authentication contract. No material merge risk remains.

Security Architecture Review

Security architecture risk: 🔵 Low · up to df5a9

The documented setup preserves token authentication and warns against trusting visitor-supplied identity headers. No introduced authorization bypass was established. Risk remains low because the public tunnel depends on trusted external infrastructure whose complete behavior and restart handling were not verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant exposure is the adopting installation's session and terminal service. Successful shared-token authentication grants drive authority, not a restricted Portal-only capability. The documented token requirement contains anonymous public access but does not reduce the authority of a stolen valid credential.

Security Findings and Attack Paths

  • inferred — The candidate path is a public visitor supplying a forged Tailscale identity through a loopback proxy. Under the documented configured-token setup, that identity does not bypass authentication. The remaining Portal stripping and relay uncertainties are proof gaps, not verified attack paths or introduced findings.

Trust Boundaries and Controls

  • observed — Application authorization remains independent of Portal's forwarded identity when a token is configured: a valid token or paired device grants access; otherwise token_required is returned before identity and local-access exceptions. The guide additionally requires a trusted relay and stripping visitor-supplied Tailscale identity.

Resilience and Maintainability Implications

  • observed — Existing contract tests cover unauthorized pairing initiation, invalid pairing codes, cookie issuance, sign-out, and revocation without reopening proxied access. These support application lifecycle controls but do not establish Portal interruption, concurrent restart, or retained-address behavior.

Hardening Proposals

  • proposed — Validate the documented command end to end against the intended Portal and relay versions, including forged identity headers, unauthenticated HTTP and WebSocket access, and stop/restart with the retained identity. Establish the complete hostname behavior when the name changes rather than assuming identity reuse preserves the browser origin.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the documentation change: adding Portal support for a public HTTPS address in the guide.
Description check ✅ Passed The description includes the required Change and Validation sections. It explains the resulting documentation behavior, implementation details, security considerations, and validation results, includi…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@rabbitson87
rabbitson87 force-pushed the docs/portal-public-address branch from 338667b to 06644ed Compare October 1, 2026 16:02

@devswha devswha left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rabbitson87, this is careful work, and fixing Portal first (gosuda/portal-tunnel#545) was the right order. I checked the section against decideAccess and the same-origin check: the token-first rule, the Tailscale warning and the invalid_origin explanation are all correct.

Before it leaves draft:

  1. Portal release. v2.5.1 is still the latest, so the command doesn't work yet. Please name the exact version once it ships.
  2. One end-to-end run through a relay: token sign-in, the terminal over /ws, pairing a device, and a push alert if you can.
  3. Rebase. CHANGELOG.md conflicts; add your line to the existing ### Added under [Unreleased], ending with ([#229](https://github.com/devswha/herdr-web-ui/pull/229) by @rabbitson87).
  4. Placement. Put the section right after the "it must answer 401" line, and add the same 401 check for the Portal address.
  5. Tailscale warning first, in bold, before the command: on such a PC a forged Tailscale-User-Login header gets past the token.
  6. Say to use a long random token (e.g. openssl rand -hex 32), and mention Portal in the "A public domain or reverse proxy" row of the access table.

Could you also point to where Portal documents that a name can be claimed while the tunnel is down?

@rabbitson87

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review. Pushed 7e35112, rebased on main:

  1. Version: Portal v2.6.0 shipped on 2026-10-02 with fix(sdk): keep the browser Host and https scheme in routed HTTP gosuda/portal-tunnel#545, so the section names v2.6.0.
  2. End-to-end run: not done yet. I'll run it through a relay (token sign-in, /ws, pairing, a push alert) and post the results here. It stays a draft until then.
  3. Rebase: done; the line is in the existing ### Added, with the link and credit.
  4. Placement: right after the "it must answer 401" line, with the same 401 check for the Portal address. I added it as paragraphs, like the Caddy and nginx examples, without its own heading: a heading there would have pulled "Sign out", the devices.json paragraph and "Nothing is typed without you" under it. Happy to add one if you'd rather move those paragraphs.
  5. Tailscale warning: first and in bold, before the command. I adjusted its wording for fix(access): ask for the token before trusting a Tailscale login header #309, which merged half an hour after your review: with a token set, a forged Tailscale-User-Login no longer gets past it. It now reads "On a PC that runs Tailscale, never run Portal without the token", because Portal v2.6.0 passes a visitor's copy on and cannot drop it. Without a token, a visitor who sends your login gets in. Portal's main now has --strip-request-header (feat: harden public HTTP exposure with --strip-request-header (fixes #556) gosuda/portal-tunnel#564), so after Portal's next release I'll add --strip-request-header Tailscale-User-Login to the command.
  6. Token and table: asks for a long random token (openssl rand -hex 32), and the access table row now reads "A public domain, reverse proxy or Portal".

On names: Portal's docs don't say that a name can be claimed while the tunnel is down. It comes from the relay code: registration only rejects a name held by an active lease, and Ctrl+C unregisters it. gosuda/portal-tunnel#561 states it ("Once the previous lease expires or disappears, the name can be reused by another identity") and was opened from this PR. The fix is gosuda/portal-tunnel#562, still open; it reserves a name for its identity for seven days by default. That is a relay change, so it only helps on relays that upgrade. Until it is widely deployed, the caveat stays.

@rabbitson87
rabbitson87 force-pushed the docs/portal-public-address branch from 7e35112 to 501524a Compare October 5, 2026 14:28
@rabbitson87

Copy link
Copy Markdown
Contributor Author

Portal v2.6.1 is out, so I updated the section (501524a, rebased on main):

The end-to-end run is still to come; I'll post it here before taking this out of draft.

@devswha devswha left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-through on this, including the two fixes on the Portal side. I reviewed 501524a against v0.4.0 (aca94ee) and against the Portal v2.6.1 source.

What I verified

  • --http-route /=7317 does what the section says. In Portal v2.6.1 an upstream without a scheme goes through NormalizeLoopbackTarget (sdk/http.go:249-255), the proxy keeps the browser's Host (sdk/http.go:324), sets the forwarding headers (SetXForwarded, sdk/http.go:325) and always overwrites X-Forwarded-Proto with https (sdk/http.go:49). So "does all four things" matches the list above it in the guide, and sameOrigin in server/machine-security.ts accepts the app's own requests.
  • --strip-request-header exists in v2.6.1 (cmd/portal-tunnel/main.go:117) and is accepted together with --http-route.
  • "With a token set the server asks for the token whatever that header says" still holds in v0.4.0: decideAccess returns token_required before it looks at Tailscale-User-Login (server/access.ts:118-120).
  • The anchors the section links (#in-a-terminal, #behind-a-reverse-proxy) exist in v0.4.0, and the placement after the 401 check is where it was asked for.

Before it leaves draft

  1. It no longer merges. v0.4.0 was released, so CHANGELOG.md conflicts (docs/guide.md still merges on its own). Please rebase and put the entry under the new ## [Unreleased], in ### Added.
  2. The end-to-end run is still open. It is the one item left from the first review: token sign-in, the terminal over /ws, pairing a device, and a push alert if you can, through a v2.6.1 relay. The reading of both codebases agrees with the text, but this section tells people how to put the server on the public internet, so it should be run once before it merges. Please post what you ran and what you saw.

Smaller notes

  • v0.4.0 added HERDR_WEB_TAILSCALE_SERVE_ONLY (#525). With the header stripped, a Portal request has the shape that setting grants on: forwarded, from loopback, no login (isServeOwnerRequest, server/access.ts:113). The token check comes first and the grant also needs a Host that names this PC on the tailnet, so nothing is open today. One sentence would still help, since the guide's own table says that setting is only for a port nothing else forwards to: do not combine it with Portal.
  • The command is about 190 characters on one line. Breaking it with \ would make it readable on a phone, like the nginx block above it.
  • Unverified on my side: the sentence on what a relay can see (addresses, timing and volume, not the traffic). It rests on Portal's security model page, which I did not check against the code.

The technical content is right as far as I could check it, and the wording fits the guide. With the rebase and the run it is ready for a final look.

@rabbitson87
rabbitson87 force-pushed the docs/portal-public-address branch from 501524a to 7deaad1 Compare October 8, 2026 01:01
@rabbitson87

Copy link
Copy Markdown
Contributor Author

Thanks for checking it against both codebases. Pushed 7deaad1, rebased on main (8a5ac49):

  1. Rebase: done. The entry is under the new ## [Unreleased], in ### Added, and CHANGELOG.md no longer conflicts.
  2. End-to-end run: still open. I'll run it through a v2.6.1 relay (token sign-in, /ws, pairing a device, a push alert) and post what I ran and saw before taking this out of draft.

Smaller notes:

  • HERDR_WEB_TAILSCALE_SERVE_ONLY: added to the Tailscale paragraph: "Do not set HERDR_WEB_TAILSCALE_SERVE_ONLY=1 while Portal runs either: it says tailscale serve is the only way into this port, and Portal is another (see Configuration)."
  • Command: split over five lines with \.
  • What a relay can see: checked against Portal v2.6.1's code. Before routing, the relay reads only the ClientHello for the SNI name (portal/server.go:808, l4.InspectClientHello), then copies bytes in both directions (bridge, portal/proxy.go:26). The tunnel on this PC ends tenant TLS (sdk/listener.go:649 → TerminateConn, portal/keyless/client.go:143), and the relay only signs the handshake through /v1/sign. So the sentence holds for a relay running Portal's code. The relay does hold the wildcard certificate for its domain (portal/acme/certificate.go:42), though, so one set up to intercept could end TLS itself; Portal's self-probe only detects that on sampled connections (--ban-mitm to act on it). The sentence now says so: "It does hold the certificate for its domain, so a relay set up to intercept could read the traffic; that is why the relay must be one you trust."

Add Portal to "Behind a reverse proxy", right after the 401 check, and
mention it in the access table row and the "Do I need Tailscale?" FAQ.

From v2.6.1, Portal's --http-route keeps the browser's Host, sends
X-Forwarded-For and X-Forwarded-Proto: https, passes the WebSocket
upgrade, and can drop a request header with --strip-request-header. The
plain `portal expose 7317` sends no X-Forwarded-Proto, so the app's own
requests get invalid_origin.

The command drops a visitor's Tailscale-User-Login, and the section
warns first, in bold, to keep that on a PC that runs Tailscale and not
to combine Portal with HERDR_WEB_TAILSCALE_SERVE_ONLY. It asks for a
long random token, a trusted relay on v2.6.1 or later (one that runs
Portal's code passes the encrypted bytes on, but it holds its domain's
certificate), and the identity-bound address Portal prints, and repeats
the 401 check for that address.

Refs devswha#202.
@rabbitson87
rabbitson87 force-pushed the docs/portal-public-address branch from 7deaad1 to df5a98e Compare October 8, 2026 01:45
@rabbitson87

Copy link
Copy Markdown
Contributor Author

End-to-end run done, through a real v2.6.1 relay. Here is what I ran and what I saw.

Setup (macOS arm64, no Tailscale installed)

  • herdr 0.9.3 as a headless herdr server, with one workspace and a shell pane.
  • This PR's commit (on main 8a5ac49), run with bun run server/index.ts, Bun 1.4.2, and a 64-hex HERDR_WEB_TOKEN.
  • The Portal v2.6.1 release binary (darwin-arm64, checksum verified), using the section's command against https://gosunuts.xyz (v2.6.1). The only change was a temporary identity path.

Results

Check Seen
Address Portal prints service ready at https://herdr-<16 hex>-<address>.gosunuts.xyz:443. The section didn't show the :443, so I updated it (df5a98e).
No credentials /api/session → 401; /api/health?scope=bridge → token_required, not local
Token sign-in, real browser (WebKit, phone-sized window) Sign-in screen → "Have an access token instead?" → Unlock → the app opened the terminal pane. Over the API, POST /api/auth → 204, and the cookie is HttpOnly; SameSite=Strict; Secure
Terminal over /ws In the browser, typed echo BROWSER-E2E-… and pressed the key bar's Enter; the shell's output came back. A scripted client (attach, then input) got its marker echoed too
Pairing Pair a device showed a code and a https://<portal address>/?pair=… link. A fresh client paired with that code (204, a Secure device cookie) and got in as device without the token. The PC's list then showed "Paired: Device"
Settings → Phone The QR code is the Portal address
Refusals through the relay /ws with no credentials → 401; /ws with a device cookie and a foreign Origin → 403; a cross-site POST /api/auth → 403 invalid_origin; a forged Tailscale-User-Login with no credentials → token_required
--strip-request-header The same flags in front of a header-echo upstream. A visitor's Tailscale-User-Login did not arrive. Host was the public host, X-Forwarded-Proto was https (I sent http), X-Forwarded-Host was the public host (I sent evil.example), and X-Forwarded-For was not my forged 100.64.0.1
Plain portal expose 7317 Visitors get token_required, and a browser's sign-in gets 403 invalid_origin, as the section says

Not tested

  • Push alert. The automation browser (a macOS WKWebView) has no PushManager. The page was a secure context and its service worker registered, but no push was sent. That needs a real Safari or Chrome, or a phone.
  • A PC signed in to Tailscale. Tailscale isn't installed here; the strip check above covers the header itself.
  • A physical phone.

One note: the settings menu entry now reads Phone & devices. The section says Settings → Devices → Pair a device, like the rest of the guide and the sign-in screen's own text (AccessGate.tsx). I left it consistent with those; happy to change it if you'd rather name the menu entry.

Marking this ready for review.

@rabbitson87
rabbitson87 marked this pull request as ready for review October 8, 2026 01:45

@devswha devswha left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the run and the write-up. I re-reviewed at df5a98e (the last review was at 501524a), against main at 5979118 and the Portal v2.6.1 source (tag v2.6.1, 80d6e37). On the Portal side I read the code; I did not run a tunnel myself.

The earlier points

Point from the last review Now Checked how
Rebase, CHANGELOG.md under the new ## [Unreleased] Fixed git merge-tree --write-tree origin/main df5a98e merges with no conflict. In the merged file the entry is at lines 10-14: ## [Unreleased] → ### Added, above ### Fixed, with the PR link and credit
End-to-end run through a v2.6.1 relay Done Your comment of 2026-10-08: token sign-in in a browser, the terminal over /ws, pairing, the 401 and the refusals, the header strip. Not covered: a push alert, a PC signed in to Tailscale, a physical phone. The first review asked for push "if you can", so I am not holding the PR for it
HERDR_WEB_TAILSCALE_SERVE_ONLY sentence Fixed The new sentence agrees with the Configuration row ("Enable it only when no public reverse proxy, tunnel or other forwarding server exposes this port") and with isServeOwnerRequest in server/access.ts
Command on one 190-character line Fixed Five lines with \
What a relay can see (I had not verified it) Fixed The lines you cited are there in v2.6.1: l4.InspectClientHello (portal/server.go:808), bridge (portal/proxy.go:26), TerminateConn on the tunnel side (sdk/listener.go:649), and the wildcard certificate (portal/acme/certificate.go:42). The added sentence about a relay that holds its domain's certificate is the right caveat

What I checked in this head

  • Every flag in the command exists in v2.6.1 (cmd/portal-tunnel/main.go:95-117).
  • The name is 22 characters (herdr- plus 16 hex), which is exactly the limit for an identity-bound hostname (CanonicalLeaseNameMaxLength, types/identity.go:11).
  • Pasting the command again does not change the address, although --name is random each time: an existing identity file is parsed as it is and its stored name is used (LoadOrCreate, portal/identity/client_identity.go:38-52). So "keep using it, since a new identity gives a new address" is right.
  • App side, on main: with no credentials the answer is 401 (server/index.ts:1216), a token is checked before Tailscale-User-Login (decideAccess), X-Forwarded-Proto: https is what makes the app's own requests pass (sameOrigin, server/machine-security.ts:24), and the button is called Pair a device (src/components/DevicesPanel.tsx:151).
  • "Does all four things" matches the four-item list above it; #configuration, #in-a-terminal and #behind-a-reverse-proxy exist, and In a terminal does say where settings go. The security-model link answers 200.

I found nothing wrong in the section.

Two small things, neither blocking

  • Settings → Devices → Pair a device. The Settings entry is labelled Phone & devices (src/components/SettingsDialog.tsx:582), and the guide already uses that name in three places (On your phone, twice, and Access and safety). The older "Settings → Devices" is left in the devices.json paragraph and in the sign-in screen's text. Settings → Phone & devices → Pair a device would match what the reader sees; the older ones can be changed separately.
  • A reader may expect $(openssl rand -hex 8) to give a new address on every start. Half a sentence saying the name is saved in the identity file with the first run would settle it.

Status

Ready from the review side: every earlier point is addressed and the claims hold against both codebases.

Two things are left on my side, not yours:

  • CI has not run on this head. The run is waiting for a maintainer's approval, as every fork run does, so only CodeRabbit has reported. main requires Fast checks and Integration and browser.
  • The branch is two commits behind main (#567, #568). Neither touches these files, but main requires an up-to-date branch. If 0.4.1 is cut before this merges, the CHANGELOG entry has to stay under the new ## [Unreleased].

@devswha
devswha merged commit 4117b53 into devswha:main Oct 8, 2026
3 checks passed
aNNdii added a commit to aNNdii/herdr-web-ui that referenced this pull request Oct 8, 2026
Upstream's settings redesign (devswha#562) replaces next's own (one page per
section, with search and a phone list); next's file viewer settings
become a File viewer page in upstream's dialog.
aNNdii added a commit to aNNdii/herdr-web-ui that referenced this pull request Oct 8, 2026
chore(sync): merge upstream main (v0.4.0, devswha#229–devswha#590) into next
devswha added a commit that referenced this pull request Oct 8, 2026
## Change

Prepares v0.4.1 and remote bundle 21.

- `package.json` and `herdr-plugin.toml`: 0.4.0 → 0.4.1. A patch
release: fixes from the audit and the pre-release reviews (#566, #570,
#588, #592), Windows chat discovery (#563, #582), the plugin's port
handling (#577), GJC menus (#593) and more. The new pieces are small and
opt-in or additive: the sidebar's Activity order and Quiet opened
finishes (#529, both off by default), the `/effort` card (#594), the
clipboard-from-a-pane switch (#570) and the Portal guide (#229).
- `shared/machines.ts`: `REMOTE_BUNDLE_VERSION` 20 → 21. `server/` code
that ships in the bundle changed since v0.4.0 (#566, #563, #572, #576,
#582, #583, #588, #519, #570, #592, #593, #594), so remote PCs need a
new bridge.
- `CHANGELOG.md`: the Unreleased notes become `[0.4.1] - 2026-10-08`,
with the compare links. #592 merged without entries; its three
user-visible fixes are added under Fixed (forwarded-address token limit,
https-only web push that never follows a redirect, Tab and Escape in Add
PC over a file preview).
- `release-summaries.json`: 0.4.1 in English, Korean, Japanese and
Chinese: four new, seven improved and eight fixed lines (eight is the
most a list keeps).

## After the merge

1. `git tag remote-v21 <merge commit> && git push origin remote-v21` →
the remote-bundles workflow publishes the five bundles and
`manifest.json` as release `remote-v21`.
2. Only then `gh workflow run release.yml --ref main -f version=0.4.1`:
preflight validates version, notes and summaries, CI runs on the exact
commit, and the tag `v0.4.1` with its GitHub release is created.

## Validation

- `bun run check fast` (workflow syntax, generated types, typecheck,
build, unit tests).
- `bun scripts/release-notes.ts 0.4.1` prints the notes (version sources
agree, one heading, summaries in all four languages).
devswha added a commit that referenced this pull request Oct 8, 2026
…e notes (#598)

Two changes the owner asked for, one commit each.

## 1. Clipboard from a pane (OSC 52) is on by default

#570 turned **Settings → Terminal → Clipboard from a pane** off by
default, so copying from vim, tmux and Claude Code silently did nothing.
It is on again; the switch stays for anyone running output they do not
trust.

**Migration: a new storage key.** Settings are saved as one whole
record, so any 0.4.1 install whose user changed *any* setting has
`terminalOsc52: false` stored without choosing it. The choice now lives
under `paneClipboard` (default `true`) and `terminalOsc52` is ignored
and dropped by `sanitizeSettings`, which already discards unknown keys.
That is the simplest correct option:
- a 0.4.1 record loads as on (its `false` cannot be told apart from a
real choice, so it is not trusted);
- an off chosen from now on is written under `paneClipboard` and stays
off across saves and reloads;
- no version field or one-off migration state is needed. A settings
version would do the same with more code.

Known edge: a tab still running the 0.4.1 bundle that saves settings
writes its own record, which has no `paneClipboard`, so a new "off"
would read as on again until it is re-chosen. Tabs pick up the new
bundle on reload, and settings already have no cross-tab sync (each tab
saves its in-memory record), so this is no worse than any other setting.

Tests (`src/lib/settings.test.ts`, "clipboard from a pane"): fresh
default on; a 0.4.1 record with `terminalOsc52: false` loads as on; an
off chosen after the change survives a save, a reload and an unrelated
change. A mutation that falls back to the old key fails the second case.

Also: the setting's description and code comments say what is true now,
ko/ja/zh entries are updated, and there is a CHANGELOG line under
Unreleased → Changed. No doc in `docs/`, `DESIGN.md`, `INSTALL.md` or
`README.md` mentions the default.

## 2. Patch-note style GitHub release notes

`scripts/release-notes.ts` printed the whole CHANGELOG section (181
lines for v0.4.1). It now prints the English lists from
`release-summaries.json` (`### New features`, `### Improvements`, `###
Bug fixes`, a list with no lines left out), then the full section inside
`<details><summary>Full changelog</summary>` with blank lines around it
so GitHub renders the markdown. Lines come through `readSummary`, so
they are trimmed and capped exactly as an install shows them. Every
validation is unchanged (version format, the three version sources,
exactly one heading, nonempty notes, all four languages).
`scripts/release-notes.test.ts` pins the shape, the order and an empty
list left out. `docs/development.md` → Releasing and `scripts/AGENTS.md`
describe the new body.

The published v0.4.1 release is not touched here; the lead regenerates
it after the merge.

### v0.4.1 rendered with this script (`bun scripts/release-notes.ts
0.4.1`)

### New features

- Typing /effort in a Claude Code chat opens a card to pick the effort
for this session
- Settings → Appearance can keep waiting and the latest agents on top of
the Agents list
- A finished agent you opened in the web UI can lose its dot, as it
would in herdr (opt-in)
- The guide shows how to give the app a public HTTPS address with Portal

### Improvements

- A wrong access token waits longer after five tries, up to a minute
- A program in a pane copies to your clipboard only once you allow it in
Settings → Terminal
- Dialogs keep Tab inside them, and screen readers announce tabs, panes
and status lines
- Add PC, Reconnect PC and Update remote bridge open as a bottom sheet
on a phone
- Updating a remote PC that is already current reuses its bridge without
a new download
- Alerts go only to https push services and never follow a redirect
- Long drafts wrap, and the scrollbar no longer covers text when the
page is zoomed

### Bug fixes

- A long line of unclosed brackets or broken escape codes no longer
freezes the chat
- On Windows, more Claude Code and Codex panes show their chat instead
of an error
- Your own devices are recognised by their Tailscale login again,
without pairing
- A Claude Code chat shows what a slash command answered, and /goal is
suggested
- Settings, the palette, Add PC and file previews stack in order; Escape
closes the top one
- The plugin's start keeps the app on its port while herdr is away
- A secret or typed text no longer reaches a pane you have already left
- Gajae Code's selection and startup menus show their choices, not only
arrow keys

<details><summary>Full changelog</summary>

### Added
- `/effort` sent from a Claude Code chat opens a card with the effort
levels, low to max, so the
level no longer has to be set in the terminal. A pick applies to this
session only, as a pick
from the `/model` card does, and leaves the default for new sessions
alone. `/effort` is also in
  the chat's command list now.
  ([#594](#594),
  [#523](#523) by @suho-han)
- Settings → Terminal has a **Clipboard from a pane** switch, off by
default: a program running in a
pane can no longer put text on your clipboard unless you turn it on.
Programs that copy this way
  (vim, tmux, Claude Code) copy again once it is on.
  ([#570](#570) by @radicor)
- The guide's **Behind a reverse proxy** shows how to give the app a
public HTTPS address with
[Portal](https://github.com/gosuda/portal-tunnel) v2.6.1 or later,
behind a long random token
  and with a visitor's `Tailscale-User-Login` header dropped.
([#229](#229) by
@rabbitson87)
- **Settings → Appearance → Agents order → Activity** keeps a waiting
agent on top of the Agents
list and orders the rest by their latest state change, as herdr's agents
panel keeps the latest
work in view: the agent you just sent a message to stays on top while it
runs and after it
finishes, and a new one starts there. herdr's own order and the
workspace rows are unchanged.
  **Workspaces** (herdr's order) remains the default.
([#529](#529) by
@phirschybar)
- **Settings → Appearance → Quiet opened finishes** (off by default): a
finished agent you have
opened in the web UI loses its dot and reads as ready, as viewing it in
herdr would make it.
herdr's DONE otherwise stands until herdr itself shows the pane. It is
remembered per PC in
this browser. ([#529](#529)
by @phirschybar)

### Changed
- A wrong access token is refused with a growing wait after five tries,
up to a minute, whether it
is typed into the sign-in form or sent with a request. Each visitor
behind `tailscale serve` has
their own count, and a browser holding an old token never stops you
signing in with the new one.
  ([#570](#570) by @radicor)
- The app now sends itself a Content-Security-Policy, so third-party
content rendered in a chat —
  math, agent marks — cannot run script in the app.
  ([#570](#570) by @radicor)
- A web-push subscription must be an https endpoint.
  ([#570](#570) by @radicor)

### Fixed
- Gajae Code's selection menus show their choices instead of only
arrow-key buttons, including
startup selectors shown before the pane reports that it is waiting.
Answers move to the selected
  row and recheck the menu before confirming.
  ([#593](#593))
- Secret input and the Codex follow-up fallback validate the live
screen, so a password
prompt or collapsed question queue in scrollback cannot send input into
the current program.
  ([#566](#566))
- The PC's Tailscale login is read from a real Tailscale user id. These
ids are too large for a
JavaScript number, so the owner was not recognised and the owner's own
devices had to pair. Two
  logins with neighbouring ids are also no longer taken for one.
  ([#572](#572))
- On Windows, a Claude Code pane started with a second account's
`~/.claude-*` directory as its
`CLAUDE_CONFIG_DIR` shows its chat. Before, the pane fell back to
`~/.claude`, so the chat said
**Conversation unavailable** and only the terminal worked. Windows does
not let the server read
another process's environment, so the store is the one among the
server's own
`CLAUDE_CONFIG_DIR`, `~/.claude` and the `~/.claude-*` directories
beside it that holds the
Claude process's own record, checked against the time the process
started. A directory
elsewhere is not looked in. Claude Code processes reported as
`claude.exe` are
  recognized too.
([#563](#563) by
@David-Sousa-Web)
- A long line of brackets, `\(` or underscores that never close, as an
agent prints in a log or a
minified file, no longer freezes the chat: a megabyte of them took a
minute or more to read, and
  now takes milliseconds. What every message shows is unchanged.
  ([#574](#574))
- On a mirrored pane (Windows, where herdr cannot attach a terminal),
text typed while a message
was still being sent no longer reaches the pane once you have left it,
or left it and opened it
  again, before the text's turn came.
  ([#576](#576))
- The plugin's `start` keeps the app on its port when the app's own
server holds it but cannot
reach herdr. It used to move the app to another port beside the running
one and blame another
program; now it says that the app runs there without herdr and exits,
and the app answers
  again on its port once herdr is back.
  ([#577](#577))
- On Windows, a Codex pane shows its chat when Codex stored its paths
with the `\\?\` prefix, as
it does for a canonical Windows path (`\\?\D:\work` for `D:\work`).
Before, the chat said
**Conversation unavailable**: the session's file seemed to lie outside
Codex's store, and none of
  the threads matched the pane's directory as herdr reports it.
([#582](#582) by
@David-Sousa-Web)
- In a Claude Code pane, the chat shows what a slash command answered,
so a `/goal` that Claude
Code refuses says why in the chat instead of only in the terminal.
`/goal` is also among the
  commands the message box suggests.
  ([#583](#583))
- Settings opened over a file preview is visible above it; Escape and
Back close Settings
first, preserving the preview and its history entry until the file
itself is closed.
  ([#568](#568))
- Command palette buttons keep their native Enter action; IME commit and
cancel keys
stay with text input, and arrow navigation keeps the selected result
visible.
  ([#567](#567))
- Long drafts in the message box wrap and keep a narrow scroll cue in
reserved space, so the
  scrollbar no longer covers text at fractional zoom.
([#522](#522) by @suho-han)
- A secret sent from a pane you then left and opened again, while
another browser kept the pane
open, is no longer typed into the pane: you send it again from the pane
you opened.
  ([#588](#588))
- A Claude Code slash command whose answer holds a long run of broken
terminal escape codes no
longer stalls the server while the chat reads it. Its answer also drops
a link cut off before
its end and a stray `B` after a charset switch, and an answer with both
output and errors
  shows both.
  ([#588](#588))
- The command palette opened over Settings and a file preview shows
above both, instead of
  taking the keyboard unseen beneath them.
  ([#588](#588))
- The plugin's `start` no longer takes another program on the app's port
for the app because
its answer says `ok`: it treats it as any other program there, moving
the app to a free port,
  or saying the port is taken when `PORT` is set.
  ([#588](#588))
- A 500 from the server no longer repeats the system's own error text,
which carried absolute paths
and the herdr socket location; it names a short id you can quote in a
bug report instead.
  ([#570](#570) by @radicor)
- Settings, the command palette, the file viewer, the file browser and
the new-workspace dialog keep
  Tab inside them and give the focus back to whatever opened them.
  ([#570](#570) by @radicor)
- The tabs of a workspace name the pane region they govern, so a screen
reader announces the tab and
  the pane together.
  ([#570](#570) by @radicor)
- Agent headings in a chat no longer pose as the app's own page
structure; they sit below the app's
  own headings and look the same as before.
  ([#570](#570) by @radicor)
- The "reconnecting" line and the composer's terminal-only hint are
announced when they appear.
  ([#570](#570) by @radicor)
- A chat locked out by the token gate, the "Last checked" line under
Settings → About (with its
date in your language) and a remote PC's state word in the sidebar are
translated like the rest of
  the UI.
  ([#570](#570) by @radicor)
- The alerts menu item now says the same thing the same way in every
state.
  ([#570](#570) by @radicor)
- Held terminal input typed while disconnected is forgotten after a day.
  ([#570](#570) by @radicor)
- A link printed in the terminal opens only if it is an http(s) address,
on both link paths.
  ([#570](#570) by @radicor)
- A second tab open on one pane no longer sends a message the first tab
is already sending: it
sees that send on its way and holds back. Two tabs that press Send at
nearly the same moment can still
  both send it.
  ([#570](#570) by @radicor)
- A row's ⋯ menu is capped to the room its button leaves and scrolls
instead of being cut off by the
viewport, so the pane picker of a tab with many panes keeps every entry
reachable with the pointer
as well as the keyboard. Before, items below the fold were rendered but
unreachable.
  ([#570](#570) by @radicor)
- A row menu open while the window crosses the 640 px breakpoint now
switches between bottom sheet and
  popover instead of keeping the form it opened with.
  ([#570](#570) by @radicor)
- The workspace drawer a narrow window opened is closed again when the
window is widened past 768 px,
  so narrowing it no longer brings back a drawer and its scrim unasked.
  ([#570](#570) by @radicor)
- **Add PC**, **Reconnect PC** and **Update remote bridge** open as a
bottom sheet on a phone, like
every other dialog, and keep clear of the on-screen keyboard. Before,
the one native dialog stayed
  a centred card on a phone.
  ([#570](#570) by @radicor)
- **Remove PC**'s first click is a quiet ghost button that only arms the
removal; the second is the
  red one, as revoking a device already was.
  ([#570](#570) by @radicor)
- A PC's rename, connect and disconnect buttons disable while their
request is in flight, so a double
  click no longer sends two overlapping requests.
  ([#570](#570) by @radicor)
- A failed pane or workspace rename keeps the field open with what you
typed, so a network blip no
  longer makes you write the name again.
  ([#570](#570) by @radicor)
- A workspace reorder that fails no longer undoes a later, successful
reorder.
  ([#570](#570) by @radicor)
- A tab watching several busy panes gives up its oldest cached
conversation answers when they grow
  past a byte budget, not only past sixteen of them.
  ([#570](#570) by @radicor)
- The usage meters' note is the same size as every other advisory and
empty state.
  ([#570](#570) by @radicor)
- The PDF viewer's page colour, the pill radii, the tab dot and the
pairing-code size come from
design tokens now, and the pairing code follows the compact density
setting.
  ([#570](#570) by @radicor)
- Updating an already current remote bridge verifies and reuses it
without downloading or
restarting it again, while a bridge from a newer app is left running
instead of downgraded.
A PC that waits on such a conflict says so in the sidebar and under the
header, with a
  **Reconnect** button, instead of asking for setup approval.
([#519](#519) by @suho-han)
- A wrong access token sent through a proxy on this PC with a made-up
`X-Forwarded-For` address
that itself says " via " now counts against the limit every visitor
through that proxy shares,
like any other wrong token. Before, each such try started a fresh count.
  ([#592](#592))
- A web-push subscription must be an https address, with no exception
for this PC, and an alert is
never sent on where a push service redirects it, so an alert can never
be posted to a service
running on this PC.
([#592](#592))
- In the **Add PC** dialog opened over a file preview, Tab moves through
the dialog's own controls
and Escape closes the dialog alone, leaving the preview beneath it open.
  ([#592](#592))

</details>


## Checks
- `bun run check fast`: ok (1817 pass, 6 platform skips, 0 fail).
- No browser regression covers OSC 52 (`terminal-copy-regression.ts`
covers drag and Ctrl+C copy), so none was run for it.

## Codex review (gpt-6-astra, read-only)
- **Fixed** (P2): summary text was put into the markdown as-is, so
`"…\n\n<!--"` could hide the whole changelog fold. The gate now refuses
a summary line with a line break in any language, and the English lines
escape `<`. A test covers both and fails without the fix.
- **Declined, documented** (P2): a tab still on the 0.4.1 bundle that
saves settings drops `paneClipboard`, so a new "off" reads as on until
it is chosen again. A versioned storage key would stop that, but then
every setting changed in such a tab would be lost instead. It lasts only
until that tab reloads, and every setting added before this one had the
same gap.
- **Pre-existing, not in this diff** (P2): settings have no cross-tab
sync, so a stale tab's next save writes its own copy of every setting,
this one included. Reported to the lead as a follow-up.
devswha added a commit that referenced this pull request Oct 12, 2026
## Change

This is step 2 of #202, as a draft to discuss. **Settings → Phone &
devices → Portal** gives this PC a public HTTPS address through
[Portal](https://github.com/gosuda/portal-tunnel). It runs the command
the guide already documents, using the `portal` already on the PC. The
app never installs Portal, Tailscale stays the default route, and
`tailscale.ts` stays read-only.

What the group shows:
- **No `portal`, or one older than v2.6.1:** a single line that says so,
with a link to Portal's install.
- **Ready:** a **Relay** field and **Start**.
- Start first asks the relay's `/sdk/domain` whether it runs v2.6.1 or
later.
- It then runs `portal expose --http-route /=<port>
--strip-request-header Tailscale-User-Login --name herdr-<random>
--identity-path <state dir>/portal/identity.json --relays <relay>
--discovery=false --hide`.
- **Running:** the address from Portal's `service ready at` line, with
its QR code (through `PhonePanel`'s `Address`), and a Relay row with
**Stop**.
- **Blocked:** one line that names the setting to change and says to
restart the app.

Rules the server enforces, whatever the request says:
- Start is refused without `HERDR_WEB_TOKEN` (409 `token_required`) and
while `HERDR_WEB_TAILSCALE_SERVE_ONLY=1` (409 `serve_only`). This
follows the guide from #229, which says to set a token before starting
Portal.
- Any device that can type can start and stop it. A watch-only device
gets `read_only`. Both POSTs need same-origin and `x-herdr-update: 1`,
like the update POSTs.
- Only the relay comes from the request, as one https origin. A comma is
refused because `--relays` takes a list.
- Portal's environment is PATH, home, temp and proxy variables only, so
the token never reaches it.

Lifecycle:
- **At start, the server first stops a Portal that an earlier server
left running** (one killed outright, say). It identifies that Portal by
the pid in `state.json` and checks with `ps`, or the Windows process
table, that the process is `portal expose` on this identity. This
happens before the token check, so a server restarted without a token
keeps no public address.
- An address that was on then comes back, since an app update restarts
the server. A server on another port that shares the state directory
leaves the other server's Portal alone.
- On shutdown the entrypoint waits for Portal to exit before it exits
itself. Portal gets SIGTERM so it can unregister, then SIGKILL after 4
s, within the 6 s the supervisor allows.
- Portal retries a relay it cannot use forever, so readiness has a 60 s
deadline of its own. A `relay operation failed permanently` line stops
it too. Errors quote Portal's last warning or error line.

Docs:
- the guide's Portal section;
- the "Do I need Tailscale?" FAQ and the privacy FAQ, since the relay
sees connection metadata and holds the address's certificate;
- the uninstall note and the `HERDR_WEB_STATE_DIR` row;
- DESIGN.md (page list and the group), a `server/AGENTS.md` row,
ko/ja/zh strings, a demo answer (`supported: false`) and a changelog
line.

The README and site still say the app "brings no tunnel". That stays
true, since Portal is installed separately, so I left them alone.

Questions for you:
- Start/Stop, or the read-only copyable command gosunuts asked about on
#202? I can cut this down to the latter.
- Token only, or "paired or token" as in your step-2 description?
- I have not run any of this on Windows.

Refs #202.

## Validation

- `bun run check fast` (macOS arm64, with `TMPDIR`/`CHECK_DIR` under
`/tmp`, because macOS's default temp path makes socket paths longer than
100 bytes): generated types, typecheck, build and `test:unit` all pass
(2386 tests, 0 failures).
- `server/portal.test.ts` (17 tests) uses a stand-in `portal` script and
an injected fetch. It covers:
  - relay and ready-line parsing, including a comma in the relay;
  - no start without a token or under serve-only;
- the exact flags, and that neither `HERDR_WEB_TOKEN` nor Portal's
`IDENTITY_PATH` reaches the child;
  - stop remembered across a restart;
  - shutdown waiting for Portal, then resume;
  - taking over from a Portal left by a killed server;
- **a restart without a token stops that leftover Portal and starts
nothing**;
  - a server on another port leaving it alone;
  - a relay or `portal` older than v2.6.1 refused before anything runs;
- the readiness deadline, the permanent-failure line, a crash reported
with Portal's last error line, and SIGKILL after the grace period;
  - the endpoint's header, origin, relay, token and method checks.
- Contract tests, through `bun run check run … -t "Portal API|watch"`: 2
pass.
- New `Portal API` test in `server/api.contract.test.ts`: 401 without
the token; status; start reaches `running` with the address; stop.
- The watch-device test in `server/device-access.contract.test.ts` now
also expects 403 on `portal/start` and `portal/stop`.
- Live UI on a `herdr-web-ui-test` session (token set), with no relay
contacted:
- with Portal v2.6.1 on PATH, the Relay field and Start, at desktop
width and phone width (the row stacks);
- with v2.5.0 on PATH, "This PC has Portal v2.5.0; the app needs v2.6.1
or later. Get Portal".
- Screenshots are attached below. The running state (address and QR
code) is covered by the tests with a stand-in, not by a live relay.

---------

Co-authored-by: Hako <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants