Companion Buttons 1.2.0: back to picking any buttons from any pages, without the header row

1.1.0 made each tile one page, so buttons picked on a second page never
showed, choosing ended on every settings change, and a tile could go blank
after a remount. This goes back to 1.0's model and keeps only the changes
asked for:

- Pick buttons from any pages; each gets a ring and its order number.
- No Page / Clear / Done row: Page is in the gear, the grid icon starts and
  ends choosing, a second click on a button takes it out.
- Choosing survives the remount a gear change causes, so switching Page
  carries straight on.
- A tile joining a stream its dashboard already has open (another tile with
  the same buttons, or itself after a settings change) asks GET /state for
  the snapshot instead of waiting blank.
- Gear: Captions and Page. The per-page + entries are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 12:09:31 -04:00
co-authored by Claude Opus 5.5
parent 0a6cec88aa
commit a3097481e7
8 changed files with 772 additions and 605 deletions
+8 -11
View File
@@ -8,9 +8,8 @@
*
* pages.watch → every page, its name, and which control
* sits at each row/column
* preview.graphics.controlId → a button's rendered image, on every redraw
* controls.watchControl → a button's setup, read once for its kind
* (page up/down buttons are left out)
* preview.graphics.controlId → a button's rendered image, following the
* button if it is moved to another page
*
* Nothing here can press, edit or change anything in Companion.
*
@@ -267,16 +266,17 @@ function createPageBook() {
return null;
}
/** One page by Companion's own page id (stable when pages are renumbered), or null. */
function page(id) {
return list().find((p) => p.id === id) || null;
/** The control at a page number, row and column right now, or null. */
function at(number, row, column) {
const page = pages.get(order[number - 1]);
return (page && page.controls[row] && page.controls[row][column]) || null;
}
return {
apply,
list,
locate,
page,
at,
get loaded() {
return order.length > 0;
},
@@ -303,7 +303,4 @@ function pageName(raw, number) {
return `${number} ${name}`;
}
/** Companion's navigation buttons: page up, page down, the page number. Never shown. */
const NAV_TYPES = new Set(['pageup', 'pagedown', 'pagenum']);
module.exports = { createLink, createPageBook, pageName, NAV_TYPES };
module.exports = { createLink, createPageBook, pageName };