Skip to content

feat(app): join a hub, leave it and pair again from the app (G1) - #111

Merged
bketelsen merged 6 commits into
mainfrom
irulan/g1-join-hub-in-app
Oct 28, 2026
Merged

bketelsen merged 6 commits into
mainfrom
irulan/g1-join-hub-in-app

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Plan 0008, gap G1 (Brian's day line 7, T377a): sync with a hub with no terminal. Today a Flatpak user must type flatpak run --command=notesctl org.frostyard.Frostnotes hub join ….

What.

  • Vault manager, "Join a vault on a hub": a Join button opens a panel in the actions' place: hub URL, hub vault name (checked with vaultNameError, so it cannot leave the location), this device's name (optional), and a location (Browse, or a typed path where there is no picker). It pairs where needed, shows the code and notesctl hub approve CODE for the hub's machine, and waits; then it makes <location>/<hub vault> (vault.add with create) and joins. Join shows only where sync.hubs answers (unknown, yes, no per client), and never inside lodge.
  • Settings, Sync (window's vault, local callers only): Join… when the vault does not sync; Leave (danger, asks first) when it does; Pair again… when the state is revoked.
  • The flow (app/src/data/sync.ts) is notesctl hub join's (cmd/notesctl/hub.go): pair only with a hub not paired before; on revoked from sync.join for a paired hub, pair again once and join again (fix(sync): hub join pairs again when the hub revoked the device's token #101). Pair again alone replaces the token and wakes every vault on that hub.
  • Stops and cleanup (app/src/app/JoinHub.tsx): the panel stays while its flow runs. A counted hold (holdVaultOpen, one release per flow) keeps the session from opening a first vault on vault.added, so a revoked retry's new code stays on screen. Back, Cancel and closing the panel take one stop path: a vault the flow made and did not join is removed (a removal failure is shown); a joined vault stays. Back and Cancel show only in the form and approve phases, never while a call runs.
  • Mock notesd pairs, joins and leaves, and can refuse a join with revoked, expire or hold a pairing, and hold a join, for the tests.

No API change: sync.hubs, sync.pair, sync.paired, sync.join, sync.leave exist.

Tests (Vitest). data/sync.test.ts (new hub; paired hub; revoked → 1 re-pair; revoked twice; expired; cancel; pair again); features/sync/JoinHubForm.test.tsx; Settings' Sync rows; the vault manager's Join, availability states, the first-vault revoked retry, Back, Cancel and close with cleanup, the late-cancel hold race; the session hold.

Docs. docs/specs/ui.md (Vault manager, Settings), docs/design/sync.md (Pairing and sessions), plan 0008 (G1 built; Phase 3 item 6 in the app is still to run).

Note. #110 (G2) also adds a last argument to settingsSections; whichever merges second needs a small rebase.

Review. Cross-review by openai/gpt-6.1-sol: 1 review, 3 re-reviews and 1 extra re-review authorized by Brian (T394b); Ready at ac77d82, blocking: none.

Coder: deepseek/deepseek-flash (subagent); parent: Irulan.

The vault manager's "Join a vault on a hub" gets a Join panel: the hub's
URL and vault name, this device's name, and a location for the new vault.
It pairs where needed (shows the code to approve on the hub and waits),
makes the vault, and joins; a failed join forgets the new vault. Settings,
Sync, joins the window's vault, leaves (after asking), and pairs again
where the hub refused the token. The flow (data/sync.ts) is notesctl hub
join's, with its single re-pairing on revoked (#101). The mock notesd
pairs, joins and leaves for the tests.

Plan 0008: G1 built; Phase 3's item 6 in the app is still to run.
…es, cleanup and sync (cross-review, CI)

- Cancel and unmount stop only the pairing wait; from vault.add on, the
  flow runs to its end, with errors as notices once the panel is gone (the
  session opens a first vault as notesd adds it).
- A new vault's name follows vaultNameError, so it cannot leave the chosen
  location.
- A failed join's cleanup says when vault.remove fails, and the list drops
  the vault only when notesd removed it.
- The vault manager offers Join only where sync.hubs answers.
- Biome's import order.
…eans up (cross-review)

- A hold (holdVaultOpen) keeps the session from opening a first vault on
  vault.added while a join runs, so the panel, and a revoked retry's new
  code, stay on screen.
- Back, Cancel and an unmount take one stop path: a vault the flow made
  and did not join is removed; a joined vault stays. Back and Cancel show
  only in the form and the approve phases, never while a call runs.
- The vault manager's sync availability is unknown, yes or no, per
  client; Join shows only for yes.
…n (cross-review)

holdVaultOpen returns a one-shot release, and the session opens no first
vault while any hold stands, so a cancelled flow that ends late no longer
clears the hold of the flow that replaced it.
…ates B's join (cross-review)

Flow A's removal keeps its folder, so flow B makes its vault under another
parent. The mock's holdJoins and releaseJoins hold B's sync.join until the
test has checked that B's panel stays.
@frostyard-machines frostyard-machines added ready-for-human Reviewed, CI green: ready for Brian to review and merge and removed ready-for-human Reviewed, CI green: ready for Brian to review and merge labels Oct 28, 2026
…-app

# Conflicts:
#	app/src/app/Settings.tsx
#	docs/specs/ui.md
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Oct 28, 2026
@bketelsen
bketelsen merged commit b7bf450 into main Oct 28, 2026
9 checks passed
@bketelsen
bketelsen deleted the irulan/g1-join-hub-in-app branch October 28, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants