Skip to content

Commit 482ad5c

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-9jsz55
2 parents f4cc54a + f6caa12 commit 482ad5c

7 files changed

Lines changed: 142 additions & 32 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
fix(app-shell): Studio's rails mark a customized row with the word 定制 / Custom and an added row with 新增 / Added, no fill, instead of a filled square with a glyph that read as an add button (#30070)
7+
8+
Clause-②: yes (widening) — new studio i18n key `engine.customizationMark.customizedShort` (en, zh)
9+
Metadata-protocol: none
10+
11+
The compact customization mark the pillar rails draw (and the Interfaces rail's navigation-override mark, which wraps it) now prints one short coloured word with no background. Its tooltip and accessible name are unchanged: the full text ("已定制(HotCRM)") followed by the sentence naming the customization package. It is not a control: a click on it is a click on its row.

‎scripts/check-where-matcher-conformance.mjs‎

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@
216216
// is transpiled with the same-file declarations it references (resolved from
217217
// its enclosing scopes, transitively) and evaluated. Only the matcher and the
218218
// declarations it names are executed -- never the test file, never a suite.
219+
// "Names" means its CODE names them: identifiers are read off the parsed tree,
220+
// so the words of a string, a template literal's text or a comment never pull
221+
// a sibling binding into the lift (#29860).
219222
// Anything that cannot be lifted this way is UNJUDGED and must be declared;
220223
// it is never treated as passing.
221224

@@ -316,7 +319,11 @@ function declaredName(node) {
316319
return null;
317320
}
318321

319-
/** Same-file declarations visible from `node`, innermost scope first. */
322+
/**
323+
* Same-file declarations visible from `node`, innermost scope first. Each entry
324+
* carries the declaration's TEXT (what the lift executes) and the identifiers
325+
* its CODE names (what the lift follows), read off the tree rather than the text.
326+
*/
320327
function visibleDeclarations(node, sf) {
321328
const decls = new Map();
322329
for (let cur = node.parent; cur; cur = cur.parent) {
@@ -328,22 +335,44 @@ function visibleDeclarations(node, sf) {
328335
if (ts.isVariableStatement(s)) {
329336
for (const d of s.declarationList.declarations) {
330337
if (ts.isIdentifier(d.name) && d.initializer && !decls.has(d.name.text)) {
331-
decls.set(d.name.text, `const ${d.name.text} = ${d.initializer.getText(sf)};`);
338+
decls.set(d.name.text, {
339+
text: `const ${d.name.text} = ${d.initializer.getText(sf)};`,
340+
identifiers: identifiersIn(d.initializer),
341+
});
332342
}
333343
}
334344
} else if (ts.isFunctionDeclaration(s) && s.name && !decls.has(s.name.text)) {
335-
decls.set(s.name.text, s.getText(sf));
345+
decls.set(s.name.text, { text: s.getText(sf), identifiers: identifiersIn(s) });
336346
}
337347
}
338348
}
339349
return decls;
340350
}
341351

342-
const identifiersIn = (src) => {
352+
/**
353+
* Every identifier the CODE under `node` names — and nothing its TEXT says
354+
* (#29860). Walked off the parsed tree, so a string literal, a template
355+
* literal's text between its `${…}` holes, a regular expression and a comment
356+
* contribute nothing, while an identifier inside a `${…}` hole is code and is
357+
* collected. Over-inclusive on purpose in one direction only: a property name
358+
* (`row.name`) is still an identifier node, and a name that resolves to no
359+
* declaration is skipped by the lift anyway.
360+
*
361+
* It used to be a word regex over the source text. A refusal message reading
362+
* `sparse driver: …` then pulled the sibling `const driver = { name, … }` into
363+
* the lift, `name` was a factory parameter the lift cannot supply, and a
364+
* CONFORMING matcher read UNJUDGED (`ReferenceError: name is not defined`) —
365+
* the gate's verdict hung on which English words a string contained.
366+
*/
367+
function identifiersIn(node) {
343368
const out = new Set();
344-
for (const m of src.matchAll(/\b([A-Za-z_$][A-Za-z0-9_$]*)\b/g)) out.add(m[1]);
369+
const visit = (n) => {
370+
if (ts.isIdentifier(n)) out.add(n.text);
371+
ts.forEachChild(n, visit);
372+
};
373+
visit(node);
345374
return out;
346-
};
375+
}
347376

348377
/**
349378
* Does `body` read `id` as a filter object? The two spellings are exactly the
@@ -474,6 +503,7 @@ export function discoverInSource(text, label) {
474503
line: line + 1,
475504
name: declaredName(node) ?? '(anonymous)',
476505
source: node.getText(sf),
506+
sourceIdentifiers: identifiersIn(node),
477507
declarations: declarations ?? visibleDeclarations(node, sf),
478508
capturedPath: captured ? w : null,
479509
});
@@ -498,15 +528,15 @@ function buildCallable(candidate, dropped = new Set()) {
498528
// cannot supply anyway (`query?.where ?? {}`).
499529
const skip = captured ? new Set([...dropped, captured[0]]) : dropped;
500530
const included = new Map();
501-
let frontier = identifiersIn(candidate.source);
531+
let frontier = candidate.sourceIdentifiers;
502532
for (let depth = 0; depth < 6; depth++) {
503533
const next = new Set();
504534
for (const id of frontier) {
505535
if (included.has(id) || id === self || skip.has(id)) continue;
506536
const decl = candidate.declarations.get(id);
507537
if (!decl) continue;
508-
included.set(id, decl);
509-
for (const x of identifiersIn(decl)) next.add(x);
538+
included.set(id, decl.text);
539+
for (const x of decl.identifiers) next.add(x);
510540
}
511541
if (next.size === 0) break;
512542
frontier = next;
@@ -649,7 +679,7 @@ export function measure() {
649679
const bucket = measured.get(rel);
650680
if (result.verdict === 'SILENT') bucket.silent++;
651681
else bucket.unjudged++;
652-
bucket.details.push({ ...candidate, declarations: undefined, result });
682+
bucket.details.push({ ...candidate, declarations: undefined, sourceIdentifiers: undefined, result });
653683
}
654684
}
655685
return { measured, discovered, conforming, refusing };
@@ -844,6 +874,39 @@ const FIXTURE_CAPTURED_NEGATED = `
844874
const run = (rows: any[], opts: any) =>
845875
rows.filter((r) => !Object.entries(opts.where).every(([k, v]) => r[k] === v));`;
846876

877+
// --- #29860: the lift reads identifiers from code, never from text ---------
878+
// A conforming, refusing matcher inside a factory, beside a sibling binding the
879+
// lift cannot run (`driver` closes over the factory's `name` parameter). The
880+
// matcher's refusal MESSAGE says "sparse driver", so a lift that reads words
881+
// out of template-literal text pulls `driver` in and throws `name is not
882+
// defined`. The control word is in a plain string literal too, so neither
883+
// spelling of a string may name a binding into the lift.
884+
const FIXTURE_TEXT_NAMES_SIBLING = `
885+
function makeSparseDriver(name: string) {
886+
const matches = (row: any, where: any): boolean => {
887+
for (const [k, v] of Object.entries(where ?? {})) {
888+
if (k.startsWith('$')) throw new Error(\`sparse driver: filter operator \${k} is not implemented\`);
889+
if (v !== null && typeof v === 'object') throw new Error('sparse driver: operator is not implemented');
890+
if (row[k] !== v) return false;
891+
}
892+
return true;
893+
};
894+
const driver = { name, version: '0.0.0' };
895+
return { driver, matches };
896+
}`;
897+
898+
// The other direction: an identifier inside a `\${…}` hole IS code. Here the
899+
// hole calls a same-file helper on the matcher's answering path, so a lift that
900+
// stopped reading holes would leave `label` undefined and the control probe
901+
// would throw — UNJUDGED, not CONFORMING.
902+
const FIXTURE_HOLE_NAMES_HELPER = `
903+
const label = (k: string) => k.toUpperCase();
904+
const matches = (row: any, where: any): boolean => {
905+
if (Array.isArray(where.$or) && !where.$or.some((w: any) => matches(row, w))) return false;
906+
if (Array.isArray(where.$and) && !where.$and.every((w: any) => matches(row, w))) return false;
907+
return Object.entries(where).every(([k, v]) => k.startsWith('$') || \`\${label(k)}\` === k.toUpperCase() && row[k] === v);
908+
};`;
909+
847910
function judgeFixture(src) {
848911
const found = discoverInSource(src, 'fixture.test.ts');
849912
return { found, results: found.map(judge) };
@@ -876,11 +939,12 @@ const SELF_TEST_BATTERIES = Object.freeze({
876939
'#8615: the captured-filter arm': 17,
877940
'the dispatch-gates declaration (#13163\'s landing obligation)': 6,
878941
'the ratchet is ONE-SIDED: a decrease passes and is reported (#26444)': 5,
942+
'#29860: the lift reads identifiers from code, never from text': 7,
879943
});
880944

881945
// DELETING an entry silences that battery's floor exactly as effectively as
882946
// zeroing it, so the roster's own size is pinned too.
883-
const SELF_TEST_BATTERY_FLOOR = 4;
947+
const SELF_TEST_BATTERY_FLOOR = 5;
884948

885949
// The key an assertion is filed under when no battery is open. It is not a
886950
// declared battery, so it reds by the same set difference rather than silently
@@ -991,6 +1055,33 @@ function selfTest() {
9911055
expect('a fallen count PASSES (one-sided, #26444)', reconcile(fakeMeasured, { 'a.test.ts': { silent: 2 } }).length === 0);
9921056
expect('a clean/gone entry PASSES (one-sided, #26444)', reconcile(new Map(), { 'gone.test.ts': { silent: 1 } }).length === 0);
9931057

1058+
// --- #29860: the lift reads identifiers from code, never from text -------
1059+
battery('#29860: the lift reads identifiers from code, never from text');
1060+
const textNames = judgeFixture(FIXTURE_TEXT_NAMES_SIBLING);
1061+
expect('a matcher beside text naming a sibling binding is discovered', textNames.found.length === 1);
1062+
expect(
1063+
'template-literal TEXT names no identifier: "driver" in the message is not collected',
1064+
textNames.found[0]?.sourceIdentifiers?.has('driver') === false,
1065+
);
1066+
expect(
1067+
'nor does a plain string literal: its "implemented" is not collected either',
1068+
textNames.found[0]?.sourceIdentifiers?.has('implemented') === false,
1069+
);
1070+
expect(
1071+
'a matcher beside text naming a sibling binding lifts and is CONFORMING, not UNJUDGED',
1072+
textNames.results[0]?.verdict === 'CONFORMING' && textNames.results[0]?.refused === true,
1073+
);
1074+
const holeNames = judgeFixture(FIXTURE_HOLE_NAMES_HELPER);
1075+
expect('a matcher calling a helper inside a `${…}` hole is discovered', holeNames.found.length === 1);
1076+
expect(
1077+
'the helper named only inside the hole is collected',
1078+
holeNames.found[0]?.sourceIdentifiers?.has('label') === true,
1079+
);
1080+
expect(
1081+
'so the hole-reading matcher lifts with its helper and is CONFORMING',
1082+
holeNames.results[0]?.verdict === 'CONFORMING',
1083+
);
1084+
9941085
// ── The ratchet is ONE-SIDED: a decrease passes and is reported (#26444) ──
9951086
battery('the ratchet is ONE-SIDED: a decrease passes and is reported (#26444)');
9961087
expect('a fallen count is reported once', reconcileDown(fakeMeasured, { 'a.test.ts': { silent: 2 } }).length === 1);
@@ -1110,6 +1201,7 @@ function selfTest() {
11101201
' parameter callbacks capturing their filter — by name and by access path — are\n' +
11111202
' discovered and judged, while an unresolvable root, a computed filter and an\n' +
11121203
' inverted survivor filter are each declined for their own recorded reason; the\n' +
1204+
' lift follows identifiers its code names, never the words of its text; the\n' +
11131205
' ledger reconciles one-sided (a decrease passes and is reported).',
11141206
);
11151207

‎ui/packages/app-shell/src/views/studio-design/CustomizationMark.tsx‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import * as React from 'react';
18-
import { Layers3, PencilRuler, Plus } from 'lucide-react';
1918
import { cn } from '@object-ui/components';
2019
import { customizationPackageId } from '@objectstack/spec/kernel';
2120
import { t, tFormat } from '../metadata-admin/i18n.js';
@@ -36,18 +35,20 @@ const KIND_CLASS: Record<CustomizationMarkChipKind, string> = {
3635
customizationOf: 'bg-muted text-muted-foreground',
3736
};
3837

39-
/** objectstack#29693 — the glyph the compact mark draws in place of its text. */
40-
const KIND_ICON: Record<CustomizationMarkChipKind, React.ElementType> = {
41-
customized: PencilRuler,
42-
added: Plus,
43-
customizationOf: Layers3,
38+
/** The compact mark's colour: its word alone, no fill, so it never reads as a button. */
39+
const KIND_TEXT_CLASS: Record<CustomizationMarkChipKind, string> = {
40+
customized: 'text-violet-700 dark:text-violet-300',
41+
added: 'text-emerald-700 dark:text-emerald-300',
42+
customizationOf: 'text-muted-foreground',
4443
};
4544

4645
/**
47-
* objectstack#29693 — `compact` (the pillar rails): the mark is its glyph
48-
* alone, so it never takes a row's name ("已定制(ObjectStack Showcase)" left a
49-
* selected flow row no room for its label). Its text is its accessible name
50-
* and leads its tooltip, before the sentence naming the pair.
46+
* `compact` (the pillar rails): the mark prints one short word with no
47+
* background (objectstack#30070: 定制 for customized, 新增 for added), so it
48+
* reads as a status, never as a button, and never takes a row's name
49+
* (objectstack#29693). Its full text is its accessible name and leads its
50+
* tooltip, before the sentence naming the pair. It is not a control: a click
51+
* on it is a click on its row.
5152
*/
5253
export function CustomizationMark({
5354
kind,
@@ -64,7 +65,7 @@ export function CustomizationMark({
6465
pairId?: string;
6566
locale: string;
6667
className?: string;
67-
/** Draw the glyph alone, the text in its accessible name and tooltip. */
68+
/** Print one short word, no fill; the full text is its accessible name and leads its tooltip. */
6869
compact?: boolean;
6970
}): React.ReactElement {
7071
const base = baseName ?? '';
@@ -76,7 +77,6 @@ export function CustomizationMark({
7677
? tFormat(`engine.customizationMark.${kind}Title`, locale, { baseName: base, pair: pairId })
7778
: undefined;
7879
if (compact) {
79-
const Icon = KIND_ICON[kind];
8080
return (
8181
<span
8282
data-testid="customization-mark"
@@ -85,9 +85,9 @@ export function CustomizationMark({
8585
role="img"
8686
aria-label={label}
8787
title={title ? `${label}\n${title}` : label}
88-
className={cn('inline-flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-[5px]', KIND_CLASS[kind], className)}
88+
className={cn('inline-flex shrink-0 items-center whitespace-nowrap text-[11px] font-medium leading-none', KIND_TEXT_CLASS[kind], className)}
8989
>
90-
<Icon className="h-3 w-3" aria-hidden="true" />
90+
{kind === 'customized' ? t('engine.customizationMark.customizedShort', locale) : label}
9191
</span>
9292
);
9393
}

‎ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.oneSurface-28572.test.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ describe('the Interfaces rail lists a base and its pair as one list (objectstack
464464
});
465465
});
466466

467-
describe('the rail mark never takes the row’s name (objectstack#29693)', () => {
468-
it('is its glyph alone: the row prints only its label, and the mark’s text is its name and leads its tooltip', async () => {
467+
describe('the rail mark never takes the row’s name (objectstack#29693, objectstack#30070)', () => {
468+
it('prints one short word with no fill and no glyph: its full text is its name and leads its tooltip', async () => {
469469
renderAt(`/studio/${BASE}/interfaces`);
470470
await interfacesReady();
471471
const row = rowOf(ifRail(), 'dashboard', 'pipeline')!;
@@ -475,11 +475,16 @@ describe('the rail mark never takes the row’s name (objectstack#29693)', () =>
475475
expect(mark).toHaveAttribute('data-compact');
476476
expect(mark).toHaveAccessibleName(label);
477477
expect(mark.getAttribute('title')?.split('\n')[0]).toBe(label);
478-
expect(mark.textContent).toBe('');
478+
expect(mark.textContent).toBe(t('engine.customizationMark.customizedShort', 'en'));
479479
expect(within(row).queryByText(label)).toBeNull();
480480
const added = within(rowOf(ifRail(), 'dashboard', 'wins')!).getByTestId('customization-mark');
481481
expect(added).toHaveAccessibleName(t('engine.customizationMark.added', 'en'));
482-
expect(added.textContent).toBe('');
482+
expect(added.textContent).toBe(t('engine.customizationMark.added', 'en'));
483+
// A status, not a control: no filled block, no glyph that reads as an add button.
484+
for (const m of [mark, added]) {
485+
expect(m.querySelector('svg')).toBeNull();
486+
expect(m.className).not.toMatch(/(^|\s)bg-/);
487+
}
483488
});
484489
});
485490

‎ui/packages/app-shell/src/views/studio-design/StudioRailCustomizations.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ export function railCustomizationsOf(
115115
}
116116

117117
/**
118-
* A row's mark in the rail's trailing slot, or nothing. objectstack#29693 —
119-
* compact (its glyph, the text in its name and tooltip), so it never takes the
120-
* row's label.
118+
* A row's mark in the rail's trailing slot, or nothing. Compact (one short
119+
* word, no fill; the full text in its name and tooltip), so it never takes the
120+
* row's label and never reads as a button.
121121
*/
122122
export function RailCustomizationMark({
123123
row,

‎ui/packages/i18n/src/namespaces/studio/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,6 +3682,7 @@ const STUDIO_EN: Record<string, string> = {
36823682
// objectstack ADR-0146 D3 (#28568) — the customization marks, counts and
36833683
// filter of the All metadata area, from a base's customization read.
36843684
'engine.customizationMark.customized': 'Customized ({baseName})',
3685+
'engine.customizationMark.customizedShort': 'Custom',
36853686
'engine.customizationMark.customizedTitle': 'The customization package {pair} overrides this item of {baseName}',
36863687
'engine.customizationMark.added': 'Added',
36873688
'engine.customizationMark.addedTitle': 'Added to {baseName} by its customization package {pair}',

‎ui/packages/i18n/src/namespaces/studio/zh.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,6 +3257,7 @@ const STUDIO_ZH: Record<string, string> = {
32573257
// objectstack ADR-0146 D3 (#28568) — the customization marks, counts and
32583258
// filter of the All metadata area, from a base's customization read.
32593259
'engine.customizationMark.customized': '已定制({baseName})',
3260+
'engine.customizationMark.customizedShort': '定制',
32603261
'engine.customizationMark.customizedTitle': '定制包 {pair} 覆盖了 {baseName} 的此项',
32613262
'engine.customizationMark.added': '新增',
32623263
'engine.customizationMark.addedTitle': '由 {baseName} 的定制包 {pair} 新增',

0 commit comments

Comments
 (0)