Repository navigation
feat(studio): the formula editor inserts a field by label and reads a CEL syntax fault in plain words - #27901
Merged
Merged
Conversation
…L syntax fault with a plain sentence, and brings a new finding into view Claude-Session: https://claude.ai/code/session_01Utp6CbrXDpQYUAJ8MKZpNL Co-authored-by: Claude <noreply@anthropic.com>
…r and findings scroll Claude-Session: https://claude.ai/code/session_01Utp6CbrXDpQYUAJ8MKZpNL Co-authored-by: Claude <noreply@anthropic.com>
…hangeset Claude-Session: https://claude.ai/code/session_01Utp6CbrXDpQYUAJ8MKZpNL Co-authored-by: Claude <noreply@anthropic.com>
Contributor
Author
|
domain:ui#3 · os-bill · session_01Utp6CaJoinvGQSbHeDaWBe 席位核对ACCEPT · head
Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
domain:ui#3 · os-bill · session_01Utp6CaJoinvGQSbHeDaWBe
Requested by Bill · project thread
Fixes #27837
Clause-②: no
Metadata-protocol: none
维护者速读
record.字段名);CEL 语法错误先给一句白话,再用等宽字体原样显示引擎的错误和 ^ 位置标记;打字时新出现的报错会自动滚到可见处。@objectstack/formula的 message 不变,存盘门禁与客户端校验读到的文字不变;回滚即 revert 本 PR。CelPredicateField.tsx(插入字段与滚动)、celAuthoring.ts(按 refusal code 加白话首句)、ObjectFieldInspector.tsx(传入带标签的字段清单)。record.字段名;再输入record.amount *,下方先出白话一句,再出带 ^ 的引擎原文,且这一行在 Remove 按钮上方可见。What changes
The formula field's Formula (CEL) editor is the shared
CelPredicateField. It gains:fieldOptionsprop ({ name, label }[]), the editor shows an Insert field picker: a searchable list of fields by label (machine name beside it), matching on either. Choosing one inserts the CEL reference at the caret, replacing any selection:record.plus the name inrecordscope, the bare name otherwise. The caret lands after the insert.ObjectFieldInspectorpasses the object's other fields (not the formula field itself, which may not reference itself), labelled through the sameuseSafeFieldLabelresolver the canvas and grid use; a field with no label shows its name. No other host passesfieldOptions, so no other editor shows a picker.lintCelPredicatenow reads the refusalcodeandparams.detailthat@objectstack/formula'svalidateExpressionalready returns (itsexpression-refusal.tsvocabulary exists so a localized surface keys its own sentence to the code). For the catch-all CEL codeinvalid-celthe lint issue carriesplain: { key, detail }, and the editor leads withengine.celLint.invalidCel(a plain sentence) followed by the engine'sdetail(its fault plus the source excerpt with the^mark) in a monospace block, so the mark lines up under the spot.messageis unchanged, so the Save gate,clientValidationand the server-verdict dedupe read the producer's words as before. Every other refusal (anunknown-fieldwith its did-you-mean,cel-unknown-function,cel-method-call,cel-template-brace, …) keeps its message: those already carry a prescription for their fault.block: 'nearest'), so in a scrolling inspector a new error line no longer lands below the visible area where the Remove footer sits. A finding present on mount does not scroll the panel.Studio i18n (en, zh) gains
perm.cel.insertField,perm.cel.searchFields,perm.cel.noMatchingFieldsandengine.celLint.invalidCel. Root changeset:@object-ui/app-shellpatch,@object-ui/i18npatch.Tests
CelPredicateField.formulaAuthoring-27837.test.tsx(11 tests): the lint against the REAL@objectstack/formula(record.estimated_hours *→invalid-celwithplain;record.estimated_hour * 2→unknown-fieldkeeps its message, noplain; an inherited property name as a code gets no lead); the editor renders the plain key then the excerpt in aprewith the^; Insert field lists by label, insertsrecord.estimated_hoursat the caret with the caret after it, replaces a selection, searches by label, inserts the bare name in flattened scope, and is absent withoutfieldOptionsor when read-only; findings scroll into view under a focused editor and not on mount.ObjectFieldInspector.formulaFieldPicker-27837.test.tsx(1 test): the real inspector offers the siblingsname,estimated_hours,hourly_rate(notest_costitself) and choosing Estimated Hours writesexpression: 'record.estimated_hours'.Ablations (one per behaviour, each restored to HEAD by the tool)
All through
node scripts/ablation-replace.mjs … -- bash scripts/pm/os-verify-lock.sh -c "pnpm --dir ui exec vitest run (the two new files)"; app-shell tests importsrc, so no dist build is involved.'invalid-cel'row ofPLAIN_LEAD_CODES→ anchor x1→x0, blob 98f36c19747e→61e831add2c1 →Tests 4 failed | 7 passed (11)(the two plain tests, and the two scroll tests, which wait on the plain line) → restored, blob == HEAD.recordscope → anchor x1→x0 →Tests 3 failed | 8 passed (11)(both caret-insert tests and the inspector test) → restored.scrollIntoViewcall → anchor x1→x0 →Tests 1 failed | 10 passed (11)→ restored.Acceptance notes
StudioInspector+ hostedInspectorShell(footerInspectorRemoveButton) +CelPredicateField, real Tailwind theme, Chromium at 1280×720, a filler above the editor so it sits at the bottom of the scroll area, then typingrecord.estimated_hours *. Without the scroll (control leg,scrollIntoViewstubbed out): scroll viewport 68–622, error line 627–720,elementFromPointat the error line = the Remove footer (div.border-t.px-4.py-2.5), so the line is hidden under the footer. With this PR: error line 529–622, inside the viewport,elementFromPoint= the error line. In both legs the footer does NOT overlay the content box (footer top 622 = viewport bottom 622), which agrees with fix(studio): plainer authoring in Studio — option labels first, named rules, labelled fields, honest counts #27830's code read: the shell is not wrong; the line simply lands below the visible area. The probe was not committed.@objectstack/formulacollapses every CEL parse fault intoinvalid-celwith the engine's text asdetail; cel-js itself knows the fault's code (unexpected_token,unterminated_string, …) and its range, andEvalErrorinpackages/formula/src/types.tsdeclarespos?: { start, end }("Source position when known") thatclassifyErrornever fills. A per-fault plain sentence ("the formula ends too early", "a quote is not closed") and a "at character N" would need the formula package to carry cel-js's parse code and range into the refusal params. That is a change to a published package outside this card's file surface: filed by the seat as formula: a CEL parse refusal keeps the parser's error kind and position, so editors can say what is wrong and where in plain words (#27837) #27904 (domain:engine), not made here.invalid-celalso covers type faults (1 + 'a'→ "no such overload: int + string"), so the plain sentence is worded for both: something is missing, extra, out of place, or doesn't fit the values beside it.ui/AGENTS.md✨ Set up Copilot instructions #2 (docs): no hand-written page undercontent/docs/describes the Studio formula editor (only release notes mention it, which are release-owned), so no doc page changed.visibleWhen/readonlyWhen/requiredWhen) share the component and could passfieldOptionstoo; not in this card.Verification
All local readings below are on head
261cf0a4(the branch withorigin/mainmerged in, no conflict).pnpm --filter @object-ui/app-shell run type-checkandpnpm --filter @object-ui/i18n run type-check, afterpnpm --filter '@object-ui/app-shell^...' build: lock VERDICT command-exit 0.ui/test file that namesCelPredicateField,celAuthoring,ObjectFieldInspectororlintCelPredicate(100 files, the two new ones included) pluspackages/i18n/:Test Files 191 passed (191),Tests 2422 passed | 13 skipped (2435). The wholeui/suite is left to CI's Test UI.pnpm --dir ui check:new-line-citations:0 new citation(s).Derived gates: 34 families, each exit captured before any pipe; dispatch-gates --ran reconciles 34 run, 0 NOT-MEASURED
Every other family CI runs (lint, type-check lanes, Test UI, Build and E2E UI) is read from this PR's check-runs, not re-run here.
Generated by Claude Code