Suggest a token label only when the hostname names a machine #27

Merged
geusebio merged 1 commit from feature/token-label-suggestion into main 2026-08-16 17:00:30 +00:00
Owner

sc login prints and opens a link to the platform's token page carrying
?label=<short hostname> (sc), so the form arrives named — the label answers
"which box is this?" when someone later comes to revoke a token, and this side
is the only one that knows the answer.

Three cases where the name it proposed was worse than no name:

Hostname Was Now
Matts MacBook Pro passed through with the double space, collapsed server-side Matts MacBook Pro (sc)
200 characters truncated by the server mid-word at 120 cut here, with room kept for the (sc) marker
3f2a1b4c5d6e (a container with no --hostname) 3f2a1b4c5d6e (sc) no suggestion

The container id is declined for the reason localhost already is: it is
regenerated every boot, so it names a container that is gone by the time anyone
reads the token list. Both Docker forms (12 and 64 hex) are covered. A
Kubernetes pod name keeps its human half in front, so it still passes, as do
the near misses a real machine might legitimately be called — wrong length, a
non-hex digit, and the uppercase form Docker never generates.

The platform side of this — numbering a suggestion the user already holds,
bramble (sc)bramble (sc) 2, which only that side can see — is a separate
PR: someones.computer#773.

Verified

go vet, gofmt, and go test ./... green; labelForHost gains cases for
whitespace, the length cut, both container-id forms, and three near misses.

`sc login` prints and opens a link to the platform's token page carrying `?label=<short hostname> (sc)`, so the form arrives named — the label answers "which box is this?" when someone later comes to revoke a token, and this side is the only one that knows the answer. Three cases where the name it proposed was worse than no name: | Hostname | Was | Now | |---|---|---| | `Matts MacBook Pro` | passed through with the double space, collapsed server-side | `Matts MacBook Pro (sc)` | | 200 characters | truncated by the server mid-word at 120 | cut here, with room kept for the ` (sc)` marker | | `3f2a1b4c5d6e` (a container with no `--hostname`) | `3f2a1b4c5d6e (sc)` | no suggestion | The container id is declined for the reason `localhost` already is: it is regenerated every boot, so it names a container that is gone by the time anyone reads the token list. Both Docker forms (12 and 64 hex) are covered. A Kubernetes pod name keeps its human half in front, so it still passes, as do the near misses a real machine might legitimately be called — wrong length, a non-hex digit, and the uppercase form Docker never generates. The platform side of this — numbering a suggestion the user already holds, `bramble (sc)` → `bramble (sc) 2`, which only that side can see — is a separate PR: [someones.computer#773](https://git.grey.ooo/Grey.ooo/Someones.Computer/pulls/773). ## Verified `go vet`, `gofmt`, and `go test ./...` green; `labelForHost` gains cases for whitespace, the length cut, both container-id forms, and three near misses.
Suggest a token label only when the hostname names a machine
All checks were successful
CI / build (pull_request) Successful in 6m34s
ea3fcdc334
`sc login` links to the token page carrying `?label=<short hostname> (sc)`, so
the form arrives named rather than blank. Three cases where that name was worse
than no name at all:

- A hostname with whitespace in it went through as-is, so the suggestion
  arrived with a tab or a double space the server then collapsed. Fields it now.
- A hostname longer than the platform's 120-character label field was truncated
  server-side, mid-word. The cut happens here instead, with room kept for the
  ` (sc)` marker.
- A container with no --hostname reports the short container id — twelve hex
  digits, regenerated every boot. It identifies a container that no longer
  exists by the time anyone reads the token list, which is the same reason
  `localhost` is already declined. Declined too, along with the 64-character
  form. A Kubernetes pod name keeps its human half in front, so it still
  passes; so do the near misses (wrong length, a non-hex digit, and the
  uppercase form Docker never generates).
geusebio changed title from WIP: Suggest a token label only when the hostname names a machine to Suggest a token label only when the hostname names a machine 2026-08-16 16:48:51 +00:00
geusebio scheduled this pull request to auto merge when all checks succeed 2026-08-16 16:53:34 +00:00
Sign in to join this conversation.
No reviewers
No labels
in-progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grey.ooo/someones.computer_agent!27
No description provided.