chadtmiller.com/group-host
atmosphere group host
0
0
A dialog's title is its own fixed words, never a name or handle
.claude/skills/ui/SKILL.md+10−1
| @@ -176,10 +176,19 @@ controls. | ||
- *Confirming.* An act that cannot be undone (leaving, removing | ||
someone, deleting a rule or role, removing a key, revoking, | ||
disconnecting) opens a `ConfirmDialog`: its title the question | ||
("Leave Riders?", "Delete this rule?"), what will happen in a | ||
("Leave this group?", "Delete this rule?"), what will happen in a | ||
sentence, a quiet Cancel, and the act in `danger`, its verb alone | ||
("Delete"). What is undone by doing it again (cancelling an invite, | ||
removing a picture, declining an invite) needs no asking. | ||
- *Titles.* A dialog's title is a few fixed words: "Remove this | ||
member?", "Change roles", "Invite someone". Never put a name, handle, | ||
or anything someone typed in it ("bob.test's roles", "Revoke | ||
“Phone”?"). Those are as long as people make them, and the title then | ||
wraps over three lines or runs off the dialog. Say which thing in the | ||
body, where it wraps as text: a person by `Person` ("`@bob.test` loses | ||
access…"), anything else by its name in the sentence ("Apps using | ||
“Phone” are signed out"). `node harness/dialogs.mjs` fails on a title | ||
built around a value. | ||
- *Lists.* `ul` or `ol` with a class, a row per thing, inside the part's | ||
card: its `Avatar`, `ordinal` or picture first; its name, and under it | ||
what is said about it (`.row-main` with `.what`); its acts at the | ||
.knotless/workflows/web.yml+6−3
| @@ -1,16 +1,17 @@ | ||
# The console's checks, as `just lint` runs them: that each component uses | ||
# only its own layer and those below (harness/layers.mjs), and svelte-check, | ||
# only its own layer and those below (harness/layers.mjs), that every | ||
# dialog's title is its own fixed words (harness/dialogs.mjs), and svelte-check, | ||
# which fails on any warning. The packages are kept between runs and | ||
# installed again only when the lockfile changes. | ||
image: node:24.22.1 | ||
# Pushes to main, and pulls that change the pages, the lexicons their types | ||
# are made from, the layers' check or this file. A pull changing none passes | ||
# are made from, the layers' or dialogs' check or this file. A pull changing none passes | ||
# at once, noted as skipped. | ||
on: | ||
push: {refs: [refs/heads/main]} | ||
pull: | ||
base: [refs/heads/main, refs/heads/feature/*] | ||
paths: [web/**, lexicons/**, harness/layers.mjs, .knotless/workflows/web.yml, .knotless/uses.lock] | ||
paths: [web/**, lexicons/**, harness/layers.mjs, harness/dialogs.mjs, .knotless/workflows/web.yml, .knotless/uses.lock] | ||
cache: [web/node_modules] | ||
steps: | ||
- uses: chadtmiller.com/steps/npm-ci@1 | ||
| @@ -18,6 +19,8 @@ steps: | ||
with: {dir: web} | ||
- name: layers | ||
run: node harness/layers.mjs | ||
- name: dialogs | ||
run: node harness/dialogs.mjs | ||
- name: svelte-check | ||
run: cd web && npm run check | ||
- name: build | ||
docs/development.md+2−1
| @@ -116,7 +116,8 @@ docs-deploy` after a change to the docs lands. | ||
| ||
`just lint` runs what `check` and `web` do but the console's build: | ||
`cargo fmt --check`, clippy with warnings denied, the console's | ||
component layers (`harness/layers.mjs`) and svelte-check. `just lex` is | ||
component layers (`harness/layers.mjs`), that no dialog's title holds a | ||
name or anything typed (`harness/dialogs.mjs`), and svelte-check. `just lex` is | ||
the `lexicons` check, with goat 0.2.8 in CI, and `just docs` with the | ||
site's build the `docs` check. `AGENTS.md` says what each workflow runs, | ||
and when. | ||
harness/e2e/flows.spec.mjs+9−8
| @@ -162,7 +162,7 @@ test('asking to join with a note, and being approved', async () => { | ||
| ||
test('leaving a group', async () => { | ||
// Asked to be sure of; cancelled, he is still in. | ||
const sure = bob.getByRole('dialog', { name: 'Leave Hikers?' }) | ||
const sure = bob.getByRole('dialog', { name: 'Leave this group?' }) | ||
await bob.getByRole('button', { name: 'Leave the group' }).click() | ||
await sure.getByRole('button', { name: 'Cancel' }).click() | ||
await expect(sure).toBeHidden() | ||
| @@ -173,7 +173,7 @@ test('leaving a group', async () => { | ||
| ||
/** Alice invites bob to Hikers from its page, picking him as she types, with a note. */ | ||
async function send() { | ||
const dialog = page.getByRole('dialog', { name: 'Invite someone to Hikers' }) | ||
const dialog = page.getByRole('dialog', { name: 'Invite someone' }) | ||
await page.getByRole('button', { name: 'Invite someone' }).click() | ||
const handle = dialog.getByRole('combobox', { name: 'Their handle' }) | ||
await handle.pressSequentially('bo') | ||
| @@ -187,7 +187,7 @@ async function send() { | ||
| ||
test('inviting someone from the dialog', async () => { | ||
await page.goto(url('/g/hikers.groups.test')) | ||
const dialog = page.getByRole('dialog', { name: 'Invite someone to Hikers' }) | ||
const dialog = page.getByRole('dialog', { name: 'Invite someone' }) | ||
const invite = page.getByRole('button', { name: 'Invite someone' }) | ||
await invite.click() | ||
await expect(dialog.getByText("They'll see it the next time they sign in, here or in any app that shows invites.")).toBeVisible() | ||
| @@ -270,13 +270,14 @@ test('giving roles, and putting someone out', async () => { | ||
const row = () => page.locator('.member', { hasText: 'bob.test' }) | ||
// His roles in a dialog, those she may give to tick. | ||
await row().getByRole('button', { name: "Change bob.test's roles" }).click() | ||
const roles = page.getByRole('dialog', { name: "bob.test's roles" }) | ||
const roles = page.getByRole('dialog', { name: 'Change roles' }).filter({ visible: true }) | ||
await expect(roles.getByRole('checkbox', { name: 'member' })).toBeChecked() | ||
await roles.getByRole('button', { name: 'Save' }).click() | ||
await expect(row()).toContainText('member') | ||
// Removed, once she is sure. | ||
await row().getByRole('button', { name: 'Remove bob.test' }).click() | ||
const sure = page.getByRole('dialog', { name: 'Remove @bob.test from Hikers?' }) | ||
const sure = page.getByRole('dialog', { name: 'Remove this member?' }).filter({ visible: true }) | ||
await expect(sure).toContainText('bob.test') | ||
await expect(sure.getByText('They can ask to join again.')).toBeVisible() | ||
await sure.getByRole('button', { name: 'Remove', exact: true }).click() | ||
await expect(page.locator('.members', { hasText: 'bob.test' })).toHaveCount(0) | ||
| @@ -285,7 +286,7 @@ test('giving roles, and putting someone out', async () => { | ||
test('being told why the host refused', async () => { | ||
// The group's only admin may not leave it: the page says so. | ||
await page.getByRole('button', { name: 'Leave the group' }).click() | ||
await page.getByRole('dialog', { name: 'Leave Hikers?' }).getByRole('button', { name: 'Leave the group' }).click() | ||
await page.getByRole('dialog', { name: 'Leave this group?' }).getByRole('button', { name: 'Leave the group' }).click() | ||
await expect(page.locator('p.danger')).toBeVisible() | ||
await expect(page.getByText(/You're a member/)).toBeVisible() | ||
}) | ||
| @@ -508,7 +509,7 @@ test('creating an app password, and revoking what it signed in', async () => { | ||
// The console's own token, from inviting, stays. | ||
await expect(page.locator('.sessions', { hasText: 'With an app password' })).toHaveCount(0) | ||
await page.getByRole('button', { name: 'Revoke “Phone”' }).click() | ||
await page.getByRole('dialog', { name: 'Revoke “Phone”?' }).getByRole('button', { name: 'Revoke', exact: true }).click() | ||
await page.getByRole('dialog', { name: 'Revoke this app password?' }).filter({ visible: true }).getByRole('button', { name: 'Revoke', exact: true }).click() | ||
await expect(page.locator('.passwords')).toHaveCount(0) | ||
expect((await signIn()).status).toBe(401) | ||
}) | ||
| @@ -600,7 +601,7 @@ test('connecting an AI app, and disconnecting it', async () => { | ||
await page.goto(url('/g/riders.groups.test')) | ||
await expect(page.locator('.ai-apps', { hasText: 'Pocket helper' })).toBeVisible() | ||
await page.locator('.ai-apps', { hasText: 'Pocket helper' }).getByRole('button', { name: 'Disconnect' }).click() | ||
await page.getByRole('dialog', { name: 'Disconnect Pocket helper?' }).getByRole('button', { name: 'Disconnect', exact: true }).click() | ||
await page.getByRole('dialog', { name: 'Disconnect this app?' }).filter({ visible: true }).getByRole('button', { name: 'Disconnect', exact: true }).click() | ||
await expect(page.getByText('No AI app connected yet')).toBeVisible() | ||
expect((await client.tool(tokens.access_token, 'group_show', {})).status).toBe(401) | ||
}) | ||
harness/dialogs.mjsnew+70−0
| @@ -0,0 +1,70 @@ | ||
// A dialog's title is a few fixed words ("Remove this member?", "Invite | ||
// someone"), never words built around a name, a handle or anything | ||
// someone typed: those are as long as people make them, and a title | ||
// holding one wraps over lines or runs past the dialog's edge. Which | ||
// thing the dialog is about is said in its body, where it wraps as text. | ||
// | ||
// node harness/dialogs.mjs | ||
// | ||
// Reads every component and page under web/src, and prints each dialog | ||
// (a tag whose name ends in Dialog) whose title is a template literal | ||
// with a `${…}` in it, or strings joined with `+`, as `file:line: title`, | ||
// failing if any. A title passed whole (`title={title}`, as ConfirmDialog | ||
// hands its own to Dialog, or a choice between fixed words) is let be: | ||
// what reaches it is the caller's, and checked where the caller writes it. | ||
| ||
import { readdirSync, readFileSync } from 'node:fs' | ||
import { dirname, join, relative, resolve } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
| ||
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..') | ||
const src = join(root, 'web/src') | ||
| ||
const files = (d) => | ||
readdirSync(d, { withFileTypes: true }).flatMap((e) => | ||
e.isDirectory() ? files(join(d, e.name)) : e.name.endsWith('.svelte') ? [join(d, e.name)] : [] | ||
) | ||
| ||
/** The expression in `text` from `at`, just past its opening `{`, to its matching `}`. */ | ||
function expression(text, at) { | ||
let depth = 1 | ||
let quote = null | ||
for (let i = at; i < text.length; i++) { | ||
const c = text[i] | ||
if (quote) { | ||
if (c === '\\') i++ | ||
else if (c === quote) quote = null | ||
else if (quote === '`' && c === '$' && text[i + 1] === '{') { | ||
// Inside a template's `${`, braces count again until it closes. | ||
const inner = expression(text, i + 2) | ||
i += 2 + inner.length | ||
} | ||
continue | ||
} | ||
if (c === '"' || c === "'" || c === '`') quote = c | ||
else if (c === '{') depth++ | ||
else if (c === '}' && --depth === 0) return text.slice(at, i) | ||
} | ||
return text.slice(at) | ||
} | ||
| ||
const problems = [] | ||
for (const file of files(src)) { | ||
const text = readFileSync(file, 'utf8') | ||
// Each dialog's opening tag, as far as its title. | ||
for (const tag of text.matchAll(/<(\w*Dialog)\b[^<]*?\btitle=\{/g)) { | ||
const at = tag.index + tag[0].length | ||
const title = expression(text, at) | ||
const built = /`[^`]*\$\{/.test(title) || /['"`]\s*\+|\+\s*['"`]/.test(title) | ||
if (!built) continue | ||
const line = text.slice(0, at).split('\n').length | ||
problems.push(`${relative(root, file)}:${line}: <${tag[1]} title={${title}}>`) | ||
} | ||
} | ||
| ||
if (problems.length) { | ||
console.log(problems.join('\n')) | ||
console.log(`dialogs: ${problems.length} titles built around a value; say which thing in the body (harness/dialogs.mjs)`) | ||
process.exit(1) | ||
} | ||
console.log("dialogs: every title is the dialog's own words") | ||
web/src/lib/molecules/Standing.svelte+3−3
| @@ -1,11 +1,11 @@ | ||
<script lang="ts"> | ||
import ConfirmDialog from '#lib/molecules/ConfirmDialog.svelte'; | ||
/** | ||
* A member's standing in the group (`name`): the roles they hold there | ||
* A member's standing in the group: the roles they hold there | ||
* beyond being a member, which everyone is, in a sentence; and the way | ||
* to leave it, asked to be sure of. | ||
*/ | ||
let { name, roles }: { name: string; roles: string[] } = $props(); | ||
let { roles }: { roles: string[] } = $props(); | ||
const held = $derived(roles.filter((r) => r !== 'member')); | ||
const as = $derived(held.length ? ` with the ${held.length > 1 ? `${held.slice(0, -1).join(', ')} and ${held.at(-1)} roles` : `${held[0]} role`}` : ''); | ||
</script> | ||
| @@ -14,6 +14,6 @@ | ||
<span class="mute">You're a member{as}.</span> | ||
<button class="quiet small" type="button" popovertarget="leave">Leave the group</button> | ||
</div> | ||
<ConfirmDialog id="leave" title={`Leave ${name}?`} action="?/leave" confirm="Leave the group"> | ||
<ConfirmDialog id="leave" title="Leave this group?" action="?/leave" confirm="Leave the group"> | ||
You'll lose access to what only members see. You can ask to join again later. | ||
</ConfirmDialog> | ||
web/src/lib/organisms/AppPasswords.svelte+2−2
| @@ -25,8 +25,8 @@ | ||
<span class="what">By <Person actor={p.actor ?? { did: p.member }} />{p.privileged ? ', with chat' : ''}{p.lastUsedAt ? `; last used ${day(p.lastUsedAt)}` : ''}</span> | ||
</span> | ||
<span class="row-actions"><button class="quiet small" type="button" popovertarget={`unpassword-${i}`} aria-label={`Revoke “${p.name}”`}>Revoke</button></span> | ||
<ConfirmDialog id={`unpassword-${i}`} title={`Revoke “${p.name}”?`} action="?/unpassword" confirm="Revoke" fields={{ name: p.name }}> | ||
Apps using it are signed out, and it stops working. | ||
<ConfirmDialog id={`unpassword-${i}`} title="Revoke this app password?" action="?/unpassword" confirm="Revoke" fields={{ name: p.name }}> | ||
Apps using “{p.name}” are signed out, and it stops working. | ||
</ConfirmDialog> | ||
</li> | ||
{/each} | ||
web/src/lib/organisms/ConnectedApps.svelte+2−2
| @@ -13,8 +13,8 @@ | ||
<li> | ||
<span class="row-main"><strong>{a.name}</strong><span class="what">Connected {day(a.connectedAt)}, last used {day(a.usedAt)}</span></span> | ||
<span class="row-actions"><button class="quiet small" type="button" popovertarget={`disconnect-${i}`}>Disconnect</button></span> | ||
<ConfirmDialog id={`disconnect-${i}`} title={`Disconnect ${a.name}?`} action="?/disconnect" confirm="Disconnect" fields={{ clientId: a.clientId }}> | ||
It can no longer act for you here. You can connect it again later. | ||
<ConfirmDialog id={`disconnect-${i}`} title="Disconnect this app?" action="?/disconnect" confirm="Disconnect" fields={{ clientId: a.clientId }}> | ||
{a.name} can no longer act for you here. You can connect it again later. | ||
</ConfirmDialog> | ||
</li> | ||
{/each} | ||
web/src/lib/organisms/InviteDialog.svelte+2−2
| @@ -2,10 +2,10 @@ | ||
import FormDialog from '#lib/molecules/FormDialog.svelte'; | ||
import HandleInput from '#lib/molecules/HandleInput.svelte'; | ||
/** Inviting someone to the group, by their handle, with a note if one likes: opened by a button whose `popovertarget` is `id`. */ | ||
let { id, name }: { id: string; name: string } = $props(); | ||
let { id }: { id: string } = $props(); | ||
</script> | ||
| ||
<FormDialog {id} title={`Invite someone to ${name}`} action="?/invite" submit="Send invite"> | ||
<FormDialog {id} title="Invite someone" action="?/invite" submit="Send invite"> | ||
{#snippet intro()}They'll see it the next time they sign in, here or in any app that shows invites.{/snippet} | ||
<HandleInput id="{id}-handle" label="Their handle" placeholder="someone.bsky.social" /> | ||
<label class="field">A note, if you like <textarea name="message" rows="3" maxlength="2000"></textarea></label> | ||
web/src/lib/organisms/MemberList.svelte+8−8
| @@ -4,13 +4,14 @@ | ||
import Empty from '#lib/molecules/Empty.svelte'; | ||
import FormDialog from '#lib/molecules/FormDialog.svelte'; | ||
import MemberRow from '#lib/molecules/MemberRow.svelte'; | ||
import Person from '#lib/molecules/Person.svelte'; | ||
type Member = { actor: { did: string; handle?: string }; roles: { role: string }[] }; | ||
/** | ||
* Who is in the group, `shown` at a time, found by part of their handle | ||
* (`q`), with more to show while there are (`more`); and their roles: | ||
* for one who may give roles, the ones they may give, to give or take, | ||
* in a dialog; for one who may remove people, the way to, asked to be | ||
* sure of, from the group `name`. Their own row they leave from, not here. | ||
* sure of. Their own row they leave from, not here. | ||
*/ | ||
let { | ||
members, | ||
| @@ -19,9 +20,8 @@ | ||
more = false, | ||
me, | ||
assignable = [], | ||
canEject = false, | ||
name | ||
}: { members: Member[]; q?: string; shown: number; more?: boolean; me?: string; assignable?: string[]; canEject?: boolean; name: string } = $props(); | ||
canEject = false | ||
}: { members: Member[]; q?: string; shown: number; more?: boolean; me?: string; assignable?: string[]; canEject?: boolean } = $props(); | ||
const named = (m: Member) => m.actor.handle ?? m.actor.did; | ||
// Found again as it is typed, the field keeping its place; sent as a form without a script. | ||
function find(e: Event) { | ||
| @@ -46,8 +46,8 @@ | ||
{/if} | ||
</MemberRow> | ||
{#if m.actor.did !== me && assignable.length} | ||
<FormDialog id={`roles-${i}`} title={`${named(m)}'s roles`} action="?/roles" submit="Save"> | ||
{#snippet intro()}Choose the roles you can give. Everyone keeps the member role.{/snippet} | ||
<FormDialog id={`roles-${i}`} title="Change roles" action="?/roles" submit="Save"> | ||
{#snippet intro()}Choose the roles <Person actor={m.actor} /> holds. Everyone keeps the member role.{/snippet} | ||
<input type="hidden" name="did" value={m.actor.did} /> | ||
{#each m.roles.filter((r) => !assignable.includes(r.role)) as kept (kept.role)} | ||
<input type="hidden" name="role" value={kept.role} /> | ||
| @@ -61,8 +61,8 @@ | ||
</FormDialog> | ||
{/if} | ||
{#if m.actor.did !== me && canEject} | ||
<ConfirmDialog id={`eject-${i}`} title={`Remove ${m.actor.handle ? `@${m.actor.handle}` : m.actor.did} from ${name}?`} action="?/eject" confirm="Remove" fields={{ did: m.actor.did }}> | ||
They can ask to join again. | ||
<ConfirmDialog id={`eject-${i}`} title="Remove this member?" action="?/eject" confirm="Remove" fields={{ did: m.actor.did }}> | ||
<Person actor={m.actor} /> loses access to what only members see. They can ask to join again. | ||
</ConfirmDialog> | ||
{/if} | ||
</li> | ||