Skip to content

feat(ai): richer control context in prompts (inherited props, enums, caps) - #382

Open
dobrinyonkov wants to merge 3 commits into
masterfrom
split/pr3-prompt-quality
Open

feat(ai): richer control context in prompts (inherited props, enums, caps)#382
dobrinyonkov wants to merge 3 commits into
masterfrom
split/pr3-prompt-quality

Conversation

@dobrinyonkov

Copy link
Copy Markdown
Contributor

What this does

Improves the context the AI assistant sends to the model when you inspect a UI5 control. Independent of the multi-provider work — this only touches the prompt builder.

Three commits:

  1. Raise prompt section caps to ~2000 tokens. More of the control's state reaches the model before truncation.
  2. Render inherited properties, grouped with types. The prompt now shows where each property comes from and its type, so the model reasons about the control more accurately.
  3. Render an "Enums used" subsection. For enum-typed properties, list the valid values so the model suggests real options instead of guessing.

Why separate

This is prompt-quality work that rode along in the multi-provider branch but has nothing to do with providers. It touches only PromptBuilder.js and controlUtils.js. Splitting it out keeps the provider PRs focused and lets this land or revert on its own.

Testing

npx grunt karma:CI — 610 tests pass.

Bump per-section character caps in PromptBuilder from 800/400 to
8000 (properties, bindings, aggregations, console errors) and
BINDING_VALUE_CAP from 100 to 1200 (~300 tokens).

Update tests that reference the old cap sizes.
Widen the Prompt Builder's property section to carry the selected control's
inherited property groups and a typed, cleaner property line for each entry.

- controlUtils: additive typeNames sibling on properties.own and each
  properties.inheritedN, carrying the raw declared type string. Preserve
  meta.controlName on inherited groups so the prompt heading can name the
  declaring class. types dictionary and DataView consumers are unchanged.

- PromptBuilder: replace the flat {value, isDefault} property line shape
  with '- <name>: <TypeName> = <value>', appending '(default)' when the
  entry is marked default and omitting the type slot when typeNames[key]
  is empty. Strings are JSON-quoted (so embedded quotes stay escaped);
  booleans, numbers, null, undefined render literally; objects and arrays
  are JSON.stringify'd and capped at 500 characters. Combined 8000-char
  budget across own + all inherited groups with outer-first truncation:
  deepest inherited group is dropped whole; own alone overflow is
  truncated with '... [truncated]'.

Closes issue 01 of .scratch/ai-prompt-control-api-reference.
…ed properties

Widen the Prompt Builder's control block with an 'Enums used:' subsection that
lists the full set of valid values for each enum-typed property on the selected
control. The subsection lands after all property groups and before Bindings:.

- Detection per property: typeof types[key] === 'object' AND typeNames[key] is
  a non-empty string. Members come from Object.keys(types[key]) in insertion
  order (which matches the UI5 enum's declared order at runtime).
- Line format: '- <enum type name>: V1 | V2 | V3 | ...'. One line per unique
  enum type across own + all inherited groups; dedup key is the type name.
- Section capped at 2000 characters via a new module-level ENUMS_CAP constant,
  consistent with the existing per-section caps. Truncation appends the
  standard '... [truncated]' marker.
- Custom-library enums (object types[key], missing typeNames[key]) are
  silently skipped from the subsection; the corresponding property line is
  unaffected. Non-enum properties (types[key] is a primitive string) never
  produce an entry.
- Subsection omitted entirely when no property has a resolvable enum.

No change to controlUtils, AssistantController, or any other consumer.

Closes issue 02 of .scratch/ai-prompt-control-api-reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant