Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
collab v2: People panel — key-bound roster, roles, owner Remove (revocation)
nyblnet7d19cb11784b
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.tsindex 0ab2228c..3ac31228 100644--- a/slides/src/editor/editor.ts+++ b/slides/src/editor/editor.ts@@ -694,10 +694,16 @@ export class Editor {nameRow.append(nameLabel, nameInput)panel.appendChild(nameRow)- // who's here, live — colored dot, name, slide; click follows+ // People: colored dot, key-bound name, role, slide; click follows. The+ // OWNER (v2) also gets a Remove button per member — a signed revocation of+ // that device's key: the relay drops its writes and refuses its reconnects,+ // nobody else is disturbed (see docs/collab-design.md roadmap).const peers = this.session?.peers() ?? []+ const cme = this.store.doc.collab+ const iAmOwner = !!(cme?.v === 2 && cme.ownerPriv && cme.owner)if (peers.length) {const list = div('ed-share-peers')+ const roleLabel = (r?: string) => r === 'owner' ? t('Owner') : r === 'viewer' ? t('Viewer') : r === 'editor' ? t('Editor') : ''for (const peer of peers) {const row = document.createElement('button')row.className = 'ed-share-peer'@@ -707,15 +713,32 @@ export class Editor {const who = document.createElement('span')who.className = 'who'who.textContent = peer.editing ? `${peer.name} ✏️` : peer.name+ // a pub-carrying peer's name is bound to its signing key, not just typed+ if (peer.pub) who.title = t('Key-verified identity') + ` · ${peer.pub.slice(0, 12)}…`const where = document.createElement('span')where.className = 'where'const idx = this.store.doc.slides.findIndex((s) => s.id === peer.slide)- where.textContent = idx >= 0 ? t('slide {n}', { n: idx + 1 }) : ''+ const rl = roleLabel(peer.role)+ where.textContent = [rl, idx >= 0 ? t('slide {n}', { n: idx + 1 }) : ''].filter(Boolean).join(' · ')row.append(dot, who, where)row.title = t('{name} — on slide {n} (click to follow)', { name: peer.name, n: idx + 1 })row.addEventListener('click', () => {if (idx >= 0) this.store.goTo(idx)})+ if (iAmOwner && peer.pub && peer.pub !== cme!.owner) {+ const kick = document.createElement('span')+ kick.className = 'kick'+ kick.textContent = '✕'+ kick.title = t('Remove {name} — revokes this device’s access; everyone else is unaffected', { name: peer.name })+ kick.addEventListener('click', async (ev) => {+ ev.stopPropagation()+ if (!confirm(t('Remove {name} from this deck? Their copy drops to read-only.', { name: peer.name }))) return+ const tr = onlineTransport()+ const ok = tr && (await tr.revokeKey(peer.pub!, cme!.owner!, cme!.ownerPriv!))+ this.toast(ok ? t('{name} was removed', { name: peer.name }) : t('Couldn’t reach the live session'))+ })+ row.appendChild(kick)+ }list.appendChild(row)}panel.appendChild(list)diff --git a/slides/src/styles.css b/slides/src/styles.cssindex 2487b91c..79b42e7e 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -1435,6 +1435,17 @@ body.ed-col-resizing { cursor: col-resize; user-select: none; }}.ed-share-peer .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.ed-share-peer .where { color: var(--muted, #5d6b80); font-size: 11.5px; flex: none; }+.ed-share-peer .kick {+ flex: none;+ width: 18px;+ height: 18px;+ line-height: 18px;+ text-align: center;+ border-radius: 5px;+ color: #a0323c;+ font-size: 12px;+}+.ed-share-peer .kick:hover { background: rgba(160, 50, 60, 0.12); }/* Live button status dot: always present — grey when dormant (not sharing),amber+pulsing while connecting, green when live. The dot makes the on/offstate legible at a glance instead of the button looking inert. */diff --git a/slides/src/sync/session.ts b/slides/src/sync/session.tsindex cd307c7e..9e5308c1 100644--- a/slides/src/sync/session.ts+++ b/slides/src/sync/session.ts@@ -32,6 +32,10 @@ export interface PresenceInfo {sel: string[]/** element id currently being text-edited (in-text presence) */editing?: string+ /** v2 fine-grained: the key this copy signs with — key-bound identity */+ pub?: string+ /** capability of this copy, derived locally from its collab material */+ role?: 'owner' | 'editor' | 'viewer'}export interface Peer extends PresenceInfo {@@ -345,12 +349,28 @@ export class SyncSession {} catch {/* storage unavailable */}+ // key-bound identity (v2): which key this copy signs with + its capability.+ // The device key is minted by the transport on first connect; until then a+ // member's pub is simply absent from presence (it fills in on reconnect).+ const c = this.store.doc.collab+ let pub: string | undefined+ let role: 'owner' | 'editor' | 'viewer' | undefined+ if (c) {+ if (c.role === 'reader') role = 'viewer'+ else if (c.v === 2 && c.ownerPriv) { role = 'owner'; pub = c.owner }+ else if (c.v === 2 && c.invite) {+ role = 'editor'+ try { pub = JSON.parse(localStorage.getItem(`bento-member-${this.store.doc.docId}`) ?? 'null')?.pub } catch { /* absent */ }+ } else if (c.writerPriv) { role = 'editor'; pub = c.writerPub }+ }return {name,color: actorColor(this.actor),slide: this.store.slide?.id ?? '',sel: this.store.selection.slice(),...(this.editingEl ? { editing: this.editingEl } : {}),+ ...(pub ? { pub } : {}),+ ...(role ? { role } : {}),}}