Lower provider-owned structured lists

This commit is contained in:
Meta Vens 2026-07-15 02:37:18 +01:00
commit 00141b6473
4 changed files with 54 additions and 3 deletions

View file

@ -173,4 +173,5 @@ export declare function createWorldActionIntent(command: string, action: Record<
export declare function applyEveSurfaceStyles(styles: EveSurfaceStyles | undefined, body?: HTMLElement): void;
export declare function createEveCommandIntent(commandId: string, props?: Record<string, unknown>, options?: EveBrowserLoweringOptions): EveCommandIntent;
export declare function emptyState(message: string): HTMLElement;
export declare function projectSemanticListItems(value: unknown): EveSemanticListItem[];
export * from "./input-gestures.js";

View file

@ -374,6 +374,13 @@ export function renderEveComponent(node, options = currentOptions) {
const title = stringProp(props.title, "");
if (title)
list.append(el("h3", "cultui-list-title", title));
for (const [index, item] of projectSemanticListItems(props.items).entries()) {
list.append(renderEveComponent({
id: `${node.id || "list"}-item-${index}`,
kind: "list.item",
props: { ...item },
}, options));
}
for (const child of children)
list.append(renderEveComponent(child, options));
return list;
@ -623,7 +630,9 @@ export function projectSemanticListItem(node) {
label: firstString(props.label, props.title, node.text, node.kind, "item"),
status: firstString(props.status, ""),
detail: firstString(props.detail, props.phase, ""),
badges: firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean),
badges: Array.isArray(props.badges)
? props.badges.map(value => String(value).trim()).filter(Boolean)
: firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean),
};
}
function applyGeneratedLayout(element, layout, style = {}) {
@ -1592,6 +1601,16 @@ function assignId(element, node) {
function objectProps(value) {
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
}
function arrayProp(value) {
return Array.isArray(value) ? value : [];
}
export function projectSemanticListItems(value) {
return arrayProp(value).map((item, index) => projectSemanticListItem({
id: `list-item-${index}`,
kind: "list.item",
props: objectProps(item),
}));
}
function stringProp(value, fallback) {
return value === null || value === undefined ? fallback : String(value);
}

View file

@ -555,6 +555,13 @@ export function renderEveComponent(
list.dataset.componentKind = kind;
const title = stringProp(props.title, "");
if (title) list.append(el("h3", "cultui-list-title", title));
for (const [index, item] of projectSemanticListItems(props.items).entries()) {
list.append(renderEveComponent({
id: `${node.id || "list"}-item-${index}`,
kind: "list.item",
props: { ...item },
}, options));
}
for (const child of children) list.append(renderEveComponent(child, options));
return list;
}
@ -804,7 +811,9 @@ export function projectSemanticListItem(node: EveSurfaceComponent): EveSemanticL
label: firstString(props.label, props.title, node.text, node.kind, "item"),
status: firstString(props.status, ""),
detail: firstString(props.detail, props.phase, ""),
badges: firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean),
badges: Array.isArray(props.badges)
? props.badges.map(value => String(value).trim()).filter(Boolean)
: firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean),
};
}
@ -1813,6 +1822,18 @@ function objectProps(value: unknown): Record<string, unknown> {
return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : {};
}
function arrayProp(value: unknown): unknown[] {
return Array.isArray(value) ? value : [];
}
export function projectSemanticListItems(value: unknown): EveSemanticListItem[] {
return arrayProp(value).map((item, index) => projectSemanticListItem({
id: `list-item-${index}`,
kind: "list.item",
props: objectProps(item),
}));
}
function stringProp(value: unknown, fallback: string): string {
return value === null || value === undefined ? fallback : String(value);
}

View file

@ -1,7 +1,7 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
import { applyEveStateBindingValue, createEveCommandIntent, createWorldActionIntent, normalizeFieldsDocument, projectSemanticListItem, projectWorldScene, resolveRequiredPluginAdapters, selectAdvertisedSurface } from "../dist/index.js";
import { applyEveStateBindingValue, createEveCommandIntent, createWorldActionIntent, normalizeFieldsDocument, projectSemanticListItem, projectSemanticListItems, projectWorldScene, resolveRequiredPluginAdapters, selectAdvertisedSurface } from "../dist/index.js";
test("applies provider state bindings to component props instead of receipt diagnostics", () => {
const component = { props: { value: 1.2 } };
@ -93,6 +93,16 @@ test("projects unknown semantic items through the generic list contract", () =>
});
});
test("projects provider-owned list data through the same semantic item contract", () => {
assert.deepEqual(projectSemanticListItems([
{ label: "Face One", status: "working", detail: "Current turn", badges: ["repo", "live"] },
{ label: "Face Two", status: "ready" },
]), [
{ label: "Face One", status: "working", detail: "Current turn", badges: ["repo", "live"] },
{ label: "Face Two", status: "ready", detail: "", badges: [] },
]);
});
test("command intents use the active surface advertisement boundary", () => {
const intent = createEveCommandIntent("aetheria.daemon.editor.inspect", {
action: {