Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

src/ui/mod-menu.js builds the moderator menu for one chat line - Remove, Mute 10m/1h/24h/forever, Ban - and the exact /live frame each sends - module and test only #409

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

I added src/ui/mod-menu.js and src/ui/mod-menu.test.ts and pushed the branch. The 5 new tests pass. I didn't run the full bun test for so101.

Notes

shipped merged

opened this

I added src/ui/mod-menu.js and src/ui/mod-menu.test.ts and pushed the branch. The 5 new tests pass. I didn't run the full bun test for so101. tsc --noEmit failed with "bun is unable to write files to tempdir: ReadOnlyFileSystem", so I have no type-check result.

  • menuItems(line, me) returns Remove, Mute 10m / 1h / 24h / forever, and Ban. It returns nothing for your own line, nothing for anyone who is neither owner nor moderator, and nothing for a moderator looking at the owner's or another moderator's line. The owner still gets the full menu on a moderator's line.
  • frameFor(item, line) returns exactly {type:'delete',id}, {type:'mute',id,on:true,for} or {type:'ban',id,on:true}. For mute and ban, id is the line author's user id.
  • renderMenu(doc, items, onPick) builds buttons with min-width and min-height of 44px, text set through textContent.
  • Line and me shape: I assumed a line looks like {id, from:{id, name, owner?, moderator?}} and me looks like {id, owner?, moderator?}. The server's chat from carries no owner or moderator flags today, so whoever wires this up must supply them. viewer.html and lobby-panel.js are unchanged and nothing loads the module yet.

The button-size test uses a small fake document rather than a real DOM, so it checks the style properties set, not rendered size.

🤖 Generated with Claude Code

Closes #384

commented

I added src/ui/mod-menu.js and src/ui/mod-menu.test.ts and pushed the branch. The 5 new tests pass. I didn't run the full bun test for so101. tsc --noEmit failed with "bun is unable to write files to tempdir: ReadOnlyFileSystem", so I have no type-check result.

  • menuItems(line, me) returns Remove, Mute 10m / 1h / 24h / forever, and Ban. It returns nothing for your own line, nothing for anyone who is neither owner nor moderator, and nothing for a moderator looking at the owner's or another moderator's line. The owner still gets the full menu on a moderator's line.
  • frameFor(item, line) returns exactly {type:'delete',id}, {type:'mute',id,on:true,for} or {type:'ban',id,on:true}. For mute and ban, id is the line author's user id.
  • renderMenu(doc, items, onPick) builds buttons with min-width and min-height of 44px, text set through textContent.
  • Line and me shape: I assumed a line looks like {id, from:{id, name, owner?, moderator?}} and me looks like {id, owner?, moderator?}. The server's chat from carries no owner or moderator flags today, so whoever wires this up must supply them. viewer.html and lobby-panel.js are unchanged and nothing loads the module yet.

The button-size test uses a small fake document rather than a real DOM, so it checks the style properties set, not rendered size.

🤖 Generated with Claude Code

Approved

Module and test only, as the issue asked. The frames match what lobby-panel.js and terminal.ts already send ({type:delete,id}, {type:mute,id,on,for}, {type:ban,id,on}). Nothing loads the module yet, so the preview is unchanged. Text goes through textContent and buttons are 44px. Next: (1) role=menu/menuitem promises arrow-key navigation and roving tabindex that renderMenu does not provide. Either add them or drop the roles and use a plain group of buttons. (2) Wiring needs owner/moderator flags on chat from, which the server does not send today. Keep that wiring in its own pull, and keep the terminal door in step.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs