Skip to content

fix(companies): a person without a name is named by their email - #687

Merged
allisonmahmood merged 2 commits into
mainfrom
fix/583-blank-user-name
Oct 15, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
fix/583-blank-user-name

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Clerk's name claim is null for email-only accounts. Company creation, invitation acceptance and the per-request claim refresh stored that as a blank users.name, so every surface that names a person showed nothing: patchy look printed Only an admin changes it: ., whoami printed User: (email), the app header read · Acme Co, and Join suggested 's company.

The fix

One rule, Users.displayName({ name, email }): a name blank after trim() is stored as the lowercased email's local part (up to the last @), or the whole email when that part is empty. A non-blank name is stored exactly as given.

  • Company creation and invitation acceptance share one user insert in Companies; the rule applies there.
  • Users.refreshClaims applies it before its change check, so a nameless person's repeat requests (any whitespace, any email case) write nothing and wake no directory subscriptions. A real name later replaces the fallback, clearing it brings the fallback back, and an email change while nameless moves it.
  • Join suggests <local part>'s company.
  • Migration 0015_user_name_never_blank rewrites existing blank names for active and deactivated users with the same rule in SQL. Its notion of blank is trim()'s whitespace, spelled out, since Postgres's \s varies with the locale and misses some of it (U+FEFF, for one). The directory trigger records each rename as usual.
  • The dev sign-in path needed no change of its own: its claims for a new email carry an empty name, like a nameless Clerk account, and land in the writes above.

No read-time fallbacks, no constraint, no change to claim decoding or any wire shape.

Migration id: this takes 15. #587 is adding a Companies migration at the same time; whichever lands second renumbers (the record's test fails on a duplicate or skipped id).

Rolling deploy: an old host can re-blank a name during the rollout; it heals on that person's next browser request (checked by hand below).

Tested by hand

In pnpm dev up team:

  • Ada invited [email protected] as an admin from /company (303). The address signed in through /dev/sign-in, saw Acme Co · admin on /join and joined (303 to /company).
  • The environment CLI as Ada: patchy look printed Only an admin changes it: Ada Park, nova.quinn.
  • pnpm dev shot [email protected] /company: the header reads nova.quinn · Acme Co, and the user list shows nova.quinn (You), [email protected], Admin.
  • Set Nova's name back to '' in the database, as an old host would: the next /company request restored nova.quinn and advanced the directory revision 5 → 6, and a repeat request left it at 6.

Tests: creation and acceptance with empty and whitespace-only names (separately), the rule's empty-local-part fallback, the refreshClaims sequence with an update audit, the migration on a pre-15 database (including a name of only non-ASCII whitespace, which fails against a \s clause), and Join's suggestion from a name: null session.

Surfaces

  • Migrations: the step lives in packages/companies/src/migrations.ts, composed by apps/server/src/migrations.ts as before.
  • Vocabulary: the Companies glossary's User entry says a name is never blank and falls back to the email's local part.
  • Project skills: patchy-members says name is never blank.
  • Not applicable: wire contract and CLI (no shape changes), the dev loop's runner and seed (scenario people are named), served-page fixtures, reverse states, repo layout.

Closes #583

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review by GPT 6.1 Sol (xhigh, read-only, against git diff origin/main...HEAD): one finding, no others.

  • Medium, packages/companies/src/migrations.ts: the backfill's name ~ '^\s*$' doesn't match all of JavaScript trim()'s whitespace (U+FEFF, for one), so a deactivated user who never signs in again could keep a blank name. Fixed in e403b04: the clause spells out trim()'s whitespace, and the migration test's non-ASCII whitespace row fails against the old \s clause and passes against the new one.

@github-actions github-actions Bot added area:server Touches the server area area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:m 100-500 changed lines labels Oct 15, 2026
Clerk's name claim is null for email-only accounts, and company creation,
invitation acceptance and the per-request claim refresh stored it as a blank
users.name, so every surface that names a person showed nothing.

Users.displayName is the one rule: a name blank after trim() is stored as the
lowercased email's local part, or the whole email when that part is empty.
The shared user insert and refreshClaims (before its change check) apply it,
Join's suggested company name uses it, and migration 15 backfills existing
blank names with the same rule.

Closes #583

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Postgres's \s depends on the locale and misses whitespace JavaScript's trim()
strips, such as U+FEFF, so a deactivated user with such a name would have kept
it blank. The migration now spells out trim()'s whitespace.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the fix/583-blank-user-name branch from e403b04 to cbe128c Compare October 15, 2026 19:26
@allisonmahmood
allisonmahmood merged commit 6d6936e into main Oct 15, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the fix/583-blank-user-name branch October 15, 2026 19:35
allisonmahmood added a commit that referenced this pull request Oct 15, 2026
Restoring a look moved the company's pointer but recorded nobody. A repo
at revision 8 that refreshed after Ada restored 7 heard "rev 8 → 7 by
Sam: first green", crediting Sam with Ada's decision, and `patchy look`
showed nothing about the restore.

## What changed

A company now keeps one record of its **latest look restore**: who moved
the pointer, when, and an optional note. It is a single record, not a
history. A later restore replaces it and a publish clears it.

- **Record.** Three nullable columns on `companies`, added by migration
**`0016_look_restore`**. `Looks.restore` sets them in the same
transaction that moves the pointer. Restoring the revision that is
already current changes nothing, the record included. `Looks.publish`
clears them. `Looks.read` returns the record from the same statement as
the revisions.
- **Wire.** `LookRestoreRequest.note` is optional and validated as a
`LookNote`. `CompanyLook.restored` and `LookRestored.restored` are `{
by: { id, name }, at, note } | null`. The decoders also accept the key
being absent, so a new CLI still works against an older server.
- **Generation.** `index.json` gets `lookRestore` beside `look`, from
the same read. The `patchy-look` skill's state line names the restorer.
Notices still compare looks by revision and creation time, so a restore
that leaves a repo on the revision it already has stays silent.
- **CLI.** The notice names the restorer when a restore brought the look
in: `Acme's look changed, rev 8 → 7, restored by Ada: rev 8 failed dark
mode.` Without a note it reads `…, restored by Ada.` For `none`, the
notice names the restorer, then says the Patchy look stands in. `patchy
look restore` takes `--note`. `patchy look` and `look restore` print
`Restored by Ada on 2026-10-07: …` under the byline, and `--json`
carries `restored`. Notices for publishes are unchanged.

**Migration id:** **0016**. #583's fix (#687) also adds a Companies
migration and took 0015, so this one was renumbered when the two were
merged together.

## Surfaces

- Wire contract: `packages/api` schemas and endpoint descriptions, the
`look` handler, `look` / `look restore` and their `--json` shapes, and
`docs/API.md` (regenerated).
- CLI: `packages/patchy/README.md`, ADR-0004, the global `patchy` skill
(`--note`) with its `skills-lock.json` hash, and the `patchy-loop`
project skill's notice example. The `patchy-look` state line comes from
generation.
- Vocabulary and product: the Companies glossary (the "Look revision"
entry, plus a new **Look restore** term) and `docs/product.md`.
- Migrations: `0016_look_restore` in
`packages/companies/src/migrations.ts`.
- Reverse states: a publish clears the record and a later restore
replaces it.
- Not touched: the dev loop, company resources, served pages and the
repo layout. `look.restored` analytics are unchanged.

## Tested by hand

`pnpm dev up team` (Acme Co). Ada (admin) published two revisions with
the environment's CLI and created a patch repo at revision 2. Ada
promoted Cleo to admin on `/company`. Cleo's and Ben's own CLIs then
logged in through the device flow, each approved with that person's own
cookie jar.

```
$ patchy look restore 1 --note "rev 2 failed dark mode"        # Cleo
Revision 1 is the company's look again.
By Ada Park on 2026-10-14: first green
Restored by Cleo Shah on 2026-10-14: rev 2 failed dark mode.

$ patchy look                                                    # Ada
Revision 1 is the company's look.
By Ada Park on 2026-10-14: first green
Restored by Cleo Shah on 2026-10-14: rev 2 failed dark mode.
…
History:
  2  2026-10-14  Ada Park  darker green
  1  2026-10-14  Ada Park  first green  (current)

$ curl -H "Authorization: Bearer <ben>" $URL/api/look | jq '{current: .current.revision, restored}'   # Ben, a member
HTTP/1.1 200 OK  ·  cache-control: private, no-store
{ "current": 1, "restored": { "by": { "id": "usr_env_acme_cleo", "name": "Cleo Shah" }, "at": "2026-10-14T18:42:20.159Z", "note": "rev 2 failed dark mode" } }

$ pnpm patchy refresh                                            # the repo at rev 2
Acme Co's look changed, rev 2 → 1, restored by Cleo Shah: rev 2 failed dark mode. Colours and fonts follow; …
$ pnpm patchy refresh --json | jq .warnings                      # a copy of the repo at rev 2
[ "Acme Co's look changed, rev 2 → 1, restored by Cleo Shah: rev 2 failed dark mode. Colours and fonts follow; …" ]
```

The repo's `patchy-look` skill then read: "This is the company's look,
revision 1, published by Ada Park: first green. Cleo Shah restored it on
2026-10-14: rev 2 failed dark mode."

The remaining acceptance cases, in the same instance:

- Ben's `look restore none --note mine` was refused (`Only an admin can
change Acme Co's look. Ask Ada Park or Cleo Shah.`, exit 2), and the
record stayed Cleo's.
- Ada's `look restore 1` while 1 was already current left Cleo's record
untouched.
- Cleo's `look restore none` without a note printed `Restored by Cleo
Shah on 2026-10-14.` The repo's next refresh read `rev 1 → none,
restored by Cleo Shah. The Patchy look stands in.`
- Ada then published revision 3. `patchy look` showed no restore line
and `restored: null`. The repo at revision 1 heard `rev 1 → 3 by Ada
Park: third green.` with `lookRestore: null`.
- Old CLIs keep working: `main`'s `LookRestored` and `index.json`
schemas decode bodies carrying `restored` / `lookRestore`, and ignore
the new keys.

The look, migration and generation suites pass locally. A full `pnpm
verify` is still queued behind the shared machine's lock, so CI is the
gate here.

Closes #587

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.
allisonmahmood added a commit that referenced this pull request Oct 16, 2026
…u when they fail (#720)

Release 13's What's new entry, written from `c9b8fc4`, ahead of
deploying it. `patchy` and `CURRENT_RELEASE` move to `0.13.0`, so CLIs
and patch repos installed before this deploy are told to upgrade.

| Change | PRs |
| --- | --- |
| New: Home puts the patches you use first | #713, #716, #719 |
| New: Every patch in one list | #715 |
| Improved: Each patch's page leads with Open | #717 |
| New: See when your tools are failing | #718 |
| Fixed: Everyone has a name | #687 |
| Improved: Your company's look is easier to get right | #697, #696,
#703, #688 |
| Improved: Forms follow your look's error states | #691, #692 |
| Improved: Clearer answers when a publish goes wrong | #686, #685, #689
|
| Fixed: Your agent's Patchy commands are steadier | #695, #704, #680,
#681 |
| Behind the scenes: stricter checks on static pages and tools' database
requests; malformed requests are logged | #682, #693, #683 |
| Behind the scenes: usage numbers count every publish, sharing change
and restore | #698, #699, #700, #690 |
| Test and tooling only, no line | #705, #702, #701, #694, #684, #607 |

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

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

Labels

area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(companies): a person with no name shows as blank in look text

1 participant