A buttons widget: a grid of presses on one message
Docs / docs (push) Successful in 21s
Playwright Tests / test-playwright (1, 2) (push) Failing after 1m9s
Playwright Tests / test-playwright (2, 2) (push) Failing after 11s
pre-commit / pre-commit (push) Failing after 2m6s
Test Backend / test-backend (push) Failing after 2m27s
Compose Smoke Test / test-compose (push) Failing after 1m54s
Playwright Tests / merge-reports (push) Failing after 2m16s
Docs / docs (push) Successful in 21s
Playwright Tests / test-playwright (1, 2) (push) Failing after 1m9s
Playwright Tests / test-playwright (2, 2) (push) Failing after 11s
pre-commit / pre-commit (push) Failing after 2m6s
Test Backend / test-backend (push) Failing after 2m27s
Compose Smoke Test / test-compose (push) Failing after 1m54s
Playwright Tests / merge-reports (push) Failing after 2m16s
Several stateless instructions where a single button is one — six presets are otherwise six tiles to place, six titles to read, and the message they share repeated six times. Nothing is read back, as for a single button: what these send is an instruction, and the last one sent is not a state to draw. Auto-fit columns rather than a configured count: a tile is resized in the editor and scaled again to whatever panel it hangs on, so how many fit is not something the document can know. The editor reads `cfg.buttons` raw rather than through `buttonsOf`, which drops the blanks — a row being typed into is blank until the first keystroke. Also carried along by the hooks: the generated SDK was stale (it had no `RunsReadMetricNames`) and one pre-existing block in `test_panels.py` was unformatted. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016bm2HwnRsTDpeWjSPNJxQd
This commit is contained in:
@@ -19,11 +19,12 @@ import { PlayerWidget } from "./PlayerWidget"
|
||||
import { usePublish } from "./publish"
|
||||
import { useUi } from "./ui"
|
||||
import { COLOR_DTYPES, colorFormatOf } from "./ui/core/color"
|
||||
import { config, num, rowsOf, text } from "./ui/core/config"
|
||||
import { buttonsOf, config, num, rowsOf, text } from "./ui/core/config"
|
||||
|
||||
/** Widget types that put a value into the graph rather than read one. */
|
||||
export const INPUT_WIDGETS = new Set([
|
||||
"button",
|
||||
"buttons",
|
||||
"switch",
|
||||
"slider",
|
||||
"input",
|
||||
@@ -88,6 +89,7 @@ export const WIDGET_LABELS: Record<WidgetKind, string> = {
|
||||
player: "Player",
|
||||
embed: "Website",
|
||||
button: "Button",
|
||||
buttons: "Buttons",
|
||||
switch: "Switch",
|
||||
slider: "Slider",
|
||||
input: "Input",
|
||||
@@ -111,6 +113,7 @@ export const WIDGET_SIZES: Record<WidgetKind, { w: number; h: number }> = {
|
||||
player: { w: 4, h: 3 },
|
||||
embed: { w: 6, h: 4 },
|
||||
button: { w: 3, h: 2 },
|
||||
buttons: { w: 4, h: 3 },
|
||||
switch: { w: 3, h: 2 },
|
||||
slider: { w: 4, h: 2 },
|
||||
input: { w: 4, h: 2 },
|
||||
@@ -210,6 +213,11 @@ export function widgetIssue(widget: WidgetDef): string | null {
|
||||
return "This player does not publish to a message yet."
|
||||
}
|
||||
|
||||
// A grid with nothing in it publishes nothing, however well it is bound.
|
||||
if (widget.type === "buttons" && !buttonsOf(widget).length) {
|
||||
return "This grid has no buttons yet."
|
||||
}
|
||||
|
||||
const input = INPUT_WIDGETS.has(widget.type)
|
||||
const bound = text(cfg[input ? "target" : "message"])
|
||||
if (!bound) {
|
||||
@@ -501,6 +509,42 @@ function ButtonWidget({ widget, dashboard }: WidgetProps) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Several stateless presses, one message.
|
||||
*
|
||||
* A grid rather than one tile per press: six presets are six tiles to place
|
||||
* and six titles to read, and what they have in common — where they publish —
|
||||
* is then repeated six times. Nothing is read back, exactly as for a single
|
||||
* button: what these send is an instruction, and the last one sent is not a
|
||||
* state anything can be drawn as.
|
||||
*/
|
||||
function ButtonsWidget({ widget, dashboard }: WidgetProps) {
|
||||
const { Button } = useUi()
|
||||
const { target, send, pending, locked, pulse } = usePublish(widget, dashboard)
|
||||
const buttons = buttonsOf(widget)
|
||||
if (!target) return <Unbound />
|
||||
|
||||
return (
|
||||
<>
|
||||
{pulse}
|
||||
<div className="widget-buttons">
|
||||
{buttons.map((button, index) => (
|
||||
<Button
|
||||
// Two presses may share a label and a value; position is the
|
||||
// identity, as it is for a chart's series and a bar's rows.
|
||||
key={`button-${index}`}
|
||||
variant="tonal"
|
||||
disabled={pending || locked}
|
||||
onClick={() => send(button.value ?? button.label ?? true)}
|
||||
>
|
||||
{text(button.label, text(button.value, "Send"))}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A bool, published and read back — a latch either way it is drawn.
|
||||
*
|
||||
@@ -697,6 +741,7 @@ const RENDERERS: Partial<
|
||||
player: PlayerWidget,
|
||||
embed: EmbedWidget,
|
||||
button: ButtonWidget,
|
||||
buttons: ButtonsWidget,
|
||||
switch: SwitchWidget,
|
||||
slider: SliderWidget,
|
||||
input: InputWidget,
|
||||
|
||||
Reference in New Issue
Block a user