Skip to content

Commit 98d05a3

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-4h9cyt
2 parents 2ff9fc8 + 5cba8fc commit 98d05a3

20 files changed

Lines changed: 1648 additions & 1357 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/i18n': patch
3+
---
4+
5+
feat(i18n): the flow designer and the rest of the Studio chrome move into the `studio` namespace
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **Sixth slice of the move ruled on objectstack#25922** (6431032267, Q2 = A; kept by 6431234244). Every row still left in `@object-ui/app-shell`'s private designer table, except `engine.translationPreview.*`, now lives in `@object-ui/i18n/namespaces/studio`, text unchanged: the flow designer (`engine.flowSim.*`, `engine.flowCanvas.*`, `engine.flowRuns.*` and the other `engine.flow*` families), the page-block canvas, the doc and book previews, `engine.studio.inspector.*` and the remaining Studio chrome (538 keys in `en`, 583 in `zh`). The `engine.flowNode.*` and `engine.enum.*` rows stay zh-only, as before: their English is the flow node descriptor or the enum value itself. Studio reads the same strings; a Chinese viewer sees these labels in English for the moment the `zh` catalogue takes to load, as with the earlier slices. No export changes.

‎packages/qa/dogfood/test/packaged-action-disabled-dispatch-live.dogfood.test.ts‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
//
3737
// The file owns its boot (and its database file): it writes ledger rows, so it
3838
// may not share a showcase with any other file.
39+
//
40+
// The task the Mark Done cases act on is picked as a not-done one in a stable
41+
// order, and its `done === false` is asserted in `beforeAll`: the seed carries
42+
// done tasks too, and an unordered first row could be one of them, which
43+
// acceptance[0]'s "nothing written" check cannot tell from a refusal.
3944

4045
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
4146
import { mkdtempSync, rmSync } from 'node:fs';
@@ -65,7 +70,6 @@ describe('[#26572] a disabled packaged action is refused at both doors, over HTT
6570
let dir: string;
6671
let dbFile: string;
6772
let taskId: string;
68-
let markDoneRowId: unknown;
6973

7074
const boot = (file: string) => bootShowcase({ databaseFile: file, extraPlugins: [new MCPServerPlugin()] });
7175

@@ -115,9 +119,13 @@ describe('[#26572] a disabled packaged action is refused at both doors, over HTT
115119
dbFile = join(dir, 'showcase.db');
116120
stack = await boot(dbFile);
117121
admin = await stack.signIn();
118-
const list = await call(admin, 'GET', '/data/showcase_task?$top=1');
119-
taskId = list.json.records[0].id;
120-
expect(taskId).toBeTruthy();
122+
const notDone = encodeURIComponent(JSON.stringify({ done: false }));
123+
const list = await call(admin, 'GET', `/data/showcase_task?$filter=${notDone}&$orderby=id&$top=1`);
124+
expect(list.status, list.text).toBe(200);
125+
taskId = list.json.records[0]?.id;
126+
expect(taskId, 'setup: the showcase seed has no task with done = false').toBeTruthy();
127+
// The precondition acceptance[0] rests on, asserted before any switch flips.
128+
expect((await readTask(taskId)).done, `setup: task ${taskId} was picked as not done`).toBe(false);
121129
}, 240_000);
122130

123131
afterAll(async () => {
@@ -152,9 +160,7 @@ describe('[#26572] a disabled packaged action is refused at both doors, over HTT
152160
.toEqual({ done: before.done, progress: before.progress, updated_at: before.updated_at });
153161
expect(after.done).toBe(false);
154162

155-
const rows = await actionRows('showcase_mark_done');
156-
expect(rows).toHaveLength(1);
157-
markDoneRowId = rows[0].id;
163+
expect(await actionRows('showcase_mark_done')).toHaveLength(1);
158164
});
159165

160166
it('acceptance[1]: the consult precedes the param contract — 409 disabled, 400 enabled, for the identical request', async () => {
@@ -233,6 +239,12 @@ describe('[#26572] a disabled packaged action is refused at both doors, over HTT
233239
});
234240

235241
it('acceptance[5] / [2]: after a cold boot the switch holds; re-enabling updates the same row and re-arms dispatch', async () => {
242+
// The row acceptance[0]'s switch wrote, read here before the reboot.
243+
const rowsBeforeBoot = await actionRows('showcase_mark_done');
244+
expect(rowsBeforeBoot, 'acceptance[0] disables showcase_mark_done; this clause re-reads the ledger row it wrote')
245+
.toHaveLength(1);
246+
const markDoneRowId = rowsBeforeBoot[0].id;
247+
236248
await stack.stop();
237249
stack = await boot(dbFile);
238250
admin = await stack.signIn();

‎ui/packages/app-shell/src/views/metadata-admin/CelPredicateField.i18n-10862-s2.test.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ import { fieldRuleRootIssue, validateRlsPredicateEnforceability } from '@objects
3636
import { t, tFormat } from './i18n';
3737
import { CelPredicateField } from './CelPredicateField';
3838
import { lintCelPredicate, type CelSchemaHint } from './celAuthoring';
39+
// The designer rows this suite reads in zh live in `@object-ui/i18n`'s `studio`
40+
// namespace, whose `zh` catalogue is fetched on demand (objectstack#25922).
41+
// Resident before any case, so the zh rows below read synchronously.
42+
import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio';
43+
await loadStudioCatalogue('zh');
3944

4045
afterEach(cleanup);
4146

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* A Tab visibility row keeps its name input across keystrokes (objectui#26748).
5+
*
6+
* Each row was keyed by the tab name its input edits, so every keystroke
7+
* renamed the key, remounted the row, and the input lost focus after the first
8+
* character: typing `showcase_app` stored `{"s":"hidden"}`.
9+
*
10+
* What is pinned:
11+
* - a name typed one key at a time (not pasted) into a new row keeps focus
12+
* and lands whole in `tabPermissions`, with the row's visibility;
13+
* - renaming an existing row keeps the other rows and their order;
14+
* - a name that passes through another row's name merges nothing, and the
15+
* row writes again once the name is free;
16+
* - the remove button drops only its own row.
17+
*
18+
* DIRECTION: with `key={tab}` restored the typed-name pin is red (focus leaves
19+
* after the first key).
20+
*/
21+
22+
import "@testing-library/jest-dom/vitest";
23+
import * as React from "react";
24+
import { afterEach, describe, expect, it } from "vitest";
25+
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
26+
import userEvent from "@testing-library/user-event";
27+
import { PermissionAdvancedFacets } from "./PermissionAdvancedFacets";
28+
29+
afterEach(cleanup);
30+
31+
const t = (k: string) => k;
32+
33+
type Draft = Record<string, unknown>;
34+
35+
/** A stateful host, so each write re-renders the facets like the editor does. */
36+
function Host({
37+
initial,
38+
onDraft,
39+
}: {
40+
initial: Draft;
41+
onDraft: (d: Draft) => void;
42+
}) {
43+
const [draft, setDraft] = React.useState<Draft>(initial);
44+
React.useEffect(() => {
45+
onDraft(draft);
46+
}, [draft, onDraft]);
47+
return (
48+
<PermissionAdvancedFacets
49+
draft={draft}
50+
setDraft={setDraft}
51+
writable
52+
allSetNames={[]}
53+
t={t}
54+
/>
55+
);
56+
}
57+
58+
function mount(tabPermissions: Record<string, string>) {
59+
let latest: Draft = {};
60+
render(
61+
<Host
62+
initial={{ tabPermissions }}
63+
onDraft={(d) => {
64+
latest = d;
65+
}}
66+
/>,
67+
);
68+
fireEvent.click(screen.getByText("perm.tabs.title"));
69+
return { tabs: () => latest.tabPermissions };
70+
}
71+
72+
describe("a Tab visibility row keeps its name input across keystrokes (objectui#26748)", () => {
73+
it("stores a name typed key by key into a new row, focus kept", async () => {
74+
const user = userEvent.setup();
75+
const { tabs } = mount({ "": "hidden" });
76+
const input = screen.getByDisplayValue("");
77+
await user.click(input);
78+
await user.type(input, "showcase_app");
79+
expect(document.activeElement).toBe(input);
80+
expect(input).toHaveValue("showcase_app");
81+
expect(tabs()).toEqual({ showcase_app: "hidden" });
82+
});
83+
84+
it("renames an existing row, keeping the others in order", async () => {
85+
const user = userEvent.setup();
86+
const { tabs } = mount({ a_tab: "hidden", b_tab: "visible" });
87+
const input = screen.getByDisplayValue("a_tab");
88+
await user.type(input, "_x");
89+
expect(document.activeElement).toBe(input);
90+
expect(JSON.stringify(tabs())).toBe(
91+
'{"a_tab_x":"hidden","b_tab":"visible"}',
92+
);
93+
});
94+
95+
it("merges nothing while the typed name is another row’s", async () => {
96+
const user = userEvent.setup();
97+
const { tabs } = mount({ app: "visible", "": "hidden" });
98+
const input = screen.getByDisplayValue("");
99+
await user.type(input, "app");
100+
expect(input).toHaveValue("app");
101+
expect(JSON.stringify(tabs())).toBe('{"app":"visible","ap":"hidden"}');
102+
await user.type(input, "_x");
103+
expect(JSON.stringify(tabs())).toBe('{"app":"visible","app_x":"hidden"}');
104+
expect(screen.getByDisplayValue("app")).not.toBe(input);
105+
});
106+
107+
it("removes only its own row", () => {
108+
const { tabs } = mount({ a_tab: "hidden", b_tab: "visible" });
109+
fireEvent.click(screen.getAllByLabelText("perm.tabs.remove")[0]!);
110+
expect(tabs()).toEqual({ b_tab: "visible" });
111+
expect(screen.getByDisplayValue("b_tab")).toBeInTheDocument();
112+
});
113+
});

‎ui/packages/app-shell/src/views/metadata-admin/PermissionAdvancedFacets.tsx‎

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -777,18 +777,20 @@ export function PermissionAdvancedFacets({
777777
>
778778
<p className="text-xs text-muted-foreground mb-3">{t('perm.tabs.help')}</p>
779779
<div className="space-y-2">
780-
{tabEntries.map(([tab, vis]) => (
781-
<div key={tab} className="flex items-center gap-2">
782-
<Input
783-
value={tab}
780+
{tabEntries.map(([tab, vis], row) => (
781+
// objectui#26748 — keyed by position, not by the name the input
782+
// edits: a rename keeps insertion order, so the row (and the
783+
// input's focus) survives each keystroke.
784+
<div key={row} className="flex items-center gap-2">
785+
<TabNameInput
786+
name={tab}
784787
disabled={!writable}
785-
onChange={(e) => {
786-
const nextKey = e.target.value;
788+
taken={(name) => tabEntries.some(([k], j) => j !== row && k === name)}
789+
onRename={(nextKey) => {
787790
const next: TabPerms = {};
788791
for (const [k, v] of tabEntries) next[k === tab ? nextKey : k] = v;
789792
setTabs(next);
790793
}}
791-
className="h-8 w-64"
792794
/>
793795
<FacetPicker
794796
testId={`tab-visibility-${tab}`}
@@ -967,3 +969,37 @@ export function PermissionAdvancedFacets({
967969
}
968970

969971
export default PermissionAdvancedFacets;
972+
973+
/**
974+
* objectui#26748 — a Tab visibility row's name input. It holds what is typed
975+
* and writes the rename only while the name is no other row's: a name that
976+
* passes through (or ends at) another row's would otherwise merge the two
977+
* rows in `tabPermissions` and drop one.
978+
*/
979+
function TabNameInput({
980+
name,
981+
disabled,
982+
taken,
983+
onRename,
984+
}: {
985+
name: string;
986+
disabled: boolean;
987+
taken: (name: string) => boolean;
988+
onRename: (name: string) => void;
989+
}) {
990+
const [text, setText] = React.useState(name);
991+
React.useEffect(() => setText(name), [name]);
992+
return (
993+
<Input
994+
value={text}
995+
disabled={disabled}
996+
aria-invalid={text !== name || undefined}
997+
onChange={(e) => {
998+
const next = e.target.value;
999+
setText(next);
1000+
if (next !== name && !taken(next)) onRename(next);
1001+
}}
1002+
className="h-8 w-64"
1003+
/>
1004+
);
1005+
}

‎ui/packages/app-shell/src/views/metadata-admin/flowNodePaletteI18n.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
import { describe, it, expect } from 'vitest';
2121
import { translateNodeLabel, translateNodeHint } from './i18n';
22+
// The designer rows this suite reads in zh live in `@object-ui/i18n`'s `studio`
23+
// namespace, whose `zh` catalogue is fetched on demand (objectstack#25922).
24+
// Resident before any case: this file runs in the `unit` project, whose shared
25+
// module graph would otherwise let it pass only when another file had loaded
26+
// `zh` first.
27+
import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio';
28+
await loadStudioCatalogue('zh');
2229

2330
/**
2431
* The framework's own strings for this node type, copied here ONLY as the

0 commit comments

Comments
 (0)