Skip to content

Show Context Center AI Context personas as a paginated table with users, entities, token budget and freshness - #35432

Merged
Rohit0301 merged 9 commits into
mainfrom
Rohit0301/ai-persona-ui-convert
Oct 16, 2026
Merged

Rohit0301 merged 9 commits into
mainfrom
Rohit0301/ai-persona-ui-convert

Conversation

@Rohit0301

@Rohit0301 Rohit0301 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes 7469

The Context Center › AI Context page listed personas as cards showing only name, description and rule count. It is now a paginated table showing, for each persona: users, rules, entities included, context budget used, freshness, and an Enabled toggle. Admins can see at a glance which personas have context and how much of the budget it uses.

Most of these columns are not in the persona list response. Fetching the compiled document per row would compile every persona on page load, so this adds one paginated, read-only status endpoint that reads the context cache.

It also fixes a bug: GET /v1/personas?fields=users always returned no users, because list endpoints fill fields through bulk fetchers and PersonaRepository had none for users.

ai-context-table-admin ai-context-table-non-admin ai-context-table-page-2

Type of change:

  • Improvement

High-level design:

Backend

  • New GET /v1/personas/aiContext/status?limit=&before=&after= (admin-only) returns ResultList<PersonaContextStatus>: personaId, cacheState, lastGeneratedAt, entitiesIncluded, tokensEst, lastError.
    • Pages exactly like GET /v1/personas (same listInternal, same filter), so one cursor returns the status of the same personas as the list page.
    • Reads PersonaContextCache.snapshot() (local cache, then Redis) and never compiles. A persona with nothing cached reports STALE with zero counts.
    • tokensEst uses the same chars ÷ 4 estimate as the document endpoint (shared tokensEstimate helper); entitiesIncluded is shared with the document response too.
  • PersonaRepository: registers a bulk users field fetcher (same pattern as TeamRepository.fetchAndSetUsers).

Frontend (ContextCenterAIContextPage.tsx)

  • Core Table replaces the cards. Each page fetches personas (fields=users,contextDefinition) and status in parallel with the same cursor, via usePaging + PaginationCardWithControls. Non-admins skip the status call (0 entities, — budget/freshness, disabled toggle).
  • Persona: FeaturedIcon with the user icon, display name, name.
  • Context budget used: tokens used out of characterBudget ÷ 4; the bar keeps a minimum visible sliver so a small document doesn't look like an empty loading bar.
  • Freshness: getPersonaContextFreshness in PersonaAIContextUtils.ts: Not configured (no rules), Fresh · time, Stale · time, Not generated, Generating, Failed.
  • Enabled toggle: saves via updatePersonaAIContext (same payload as the persona detail page), updates immediately, reverts with a toast on failure.
  • New i18n keys, translated in all 20 locales.

Alternatives rejected: /aiContext/document per row (compiles on a cache miss); /aiContext per row (one request per persona).

Notes

  • Context is cached in memory unless Redis is configured; after a restart without Redis, personas show "Not generated" until context is generated again.
  • The budget setting is stored in characters, so the default 400K-character budget shows as 100K tokens.
  • openPersonaAIContext (shared by the AI Context specs) now pages through the table to find a persona, since a test persona can land past page one.

Tests:

Use cases covered

  • Admin sees users, rules, entities, budget used (tokens) and freshness per persona.
  • Admin toggles Enabled from the table; the change is saved to the backend, and clicking the toggle doesn't open the persona.
  • Clicking a row opens that persona's AI context.
  • Non-admin sees the table with a disabled toggle and never requests cache status.
  • Next / previous page fetch personas and status with the same cursor.
  • GET /v1/personas?fields=users returns assigned users.

Unit tests

  • ContextCenterAIContextPage.test.tsx: column rendering, non-admin, toggle save and revert, row navigation, empty state, pagination
  • PersonaAIContextUtils.test.ts: every branch of getPersonaContextFreshness

Backend integration tests

  • PersonaAIContextIT: status is admin-only; reports FRESH with tokens and generation time after the document is built; pages with the same cursor and total as GET /personas
  • PersonaResourceIT.post_personaWithUsers_200_OK: the list endpoint returns persona users

Playwright (UI) tests

  • New PersonaAIContextList.spec.ts: row opens the persona, toggle persists to the backend, non-admin is read-only, pagination uses the same cursor for both requests
  • Registered in .github/playwright/impact-map.json
  • Ran locally against a dev stack: the new spec (4 tests, 3× repeat, 12/12 passed) and the existing PersonaAIContext*.spec.ts suites (45/45 passed)

Local Playwright run: 5 specs × 3 repeats, chromium. Only the auth setup project ran first; entity-data-setup was skipped with --no-deps.

$ npx playwright test --project=setup
  1 passed (18.2s)

$ npx playwright test \
    playwright/e2e/Features/PersonaAIContextList.spec.ts \
    playwright/e2e/Features/PersonaAIContext.spec.ts \
    playwright/e2e/Features/PersonaAIContextRules.spec.ts \
    playwright/e2e/Features/PersonaAIContextRuleCardAndStates.spec.ts \
    playwright/e2e/Features/PersonaAIContextPermissions.spec.ts \
    --project=chromium --no-deps --repeat-each=3 --workers=3

  ✓ PersonaAIContextList.spec.ts                 12 / 12   (4 tests × 3)
  ✓ PersonaAIContext.spec.ts                     87 / 87   (29 tests × 3)
  ✓ PersonaAIContextRules.spec.ts                24 / 24   (8 tests × 3)
  ✓ PersonaAIContextRuleCardAndStates.spec.ts    18 / 18   (6 tests × 3)
  ✓ PersonaAIContextPermissions.spec.ts           6 / 6    (2 tests × 3)

  147 passed (5.0m)

No failures, flakes or retries.

New spec, 4 repeats per test:

$ npx playwright test playwright/e2e/Features/PersonaAIContextList.spec.ts \
    --project=chromium --no-deps --repeat-each=4 --workers=2 --reporter=list
Running 16 tests using 2 workers

  ✓   1 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:186:7 › Persona AI Context — persona table pagination › next page fetches personas and their status with the same cursor (1.7s)
  ✓   2 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:76:7 › Persona AI Context — persona table › clicking a row opens that persona's AI context (2.8s)
  ✓   3 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:76:7 › Persona AI Context — persona table › clicking a row opens that persona's AI context (3.3s)
  ✓   4 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:87:7 › Persona AI Context — persona table › toggling Enabled saves it to the backend without opening the persona (3.4s)
  ✓   5 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:87:7 › Persona AI Context — persona table › toggling Enabled saves it to the backend without opening the persona (3.0s)
  ✓   6 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:119:7 › Persona AI Context — persona table › a non-admin cannot toggle context and never requests cache status (3.0s)
  ✓   8 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:186:7 › Persona AI Context — persona table pagination › next page fetches personas and their status with the same cursor (1.7s)
  ✓   7 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:119:7 › Persona AI Context — persona table › a non-admin cannot toggle context and never requests cache status (2.8s)
  ✓  10 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:186:7 › Persona AI Context — persona table pagination › next page fetches personas and their status with the same cursor (2.0s)
  ✓   9 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:76:7 › Persona AI Context — persona table › clicking a row opens that persona's AI context (2.8s)
  ✓  12 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:87:7 › Persona AI Context — persona table › toggling Enabled saves it to the backend without opening the persona (3.4s)
  ✓  11 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:76:7 › Persona AI Context — persona table › clicking a row opens that persona's AI context (3.4s)
  ✓  14 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:87:7 › Persona AI Context — persona table › toggling Enabled saves it to the backend without opening the persona (3.4s)
  ✓  13 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:119:7 › Persona AI Context — persona table › a non-admin cannot toggle context and never requests cache status (3.3s)
  ✓  15 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:119:7 › Persona AI Context — persona table › a non-admin cannot toggle context and never requests cache status (2.3s)
  ✓  16 [chromium] › playwright/e2e/Features/PersonaAIContextList.spec.ts:186:7 › Persona AI Context — persona table pagination › next page fetches personas and their status with the same cursor (1.9s)

  16 passed (26.5s)

Manual testing performed

  1. Seeded a local stack with 37 personas (1–8 users each), a glossary with 12 terms and 18 tables, and rules of different types and asset caps.
  2. As admin, checked users, entities, token budget and freshness against /aiContext/status, and paged through the table.
  3. Toggled Enabled and reloaded; the state persisted.
  4. Restarted the server without Redis; personas showed "Not generated" until context was generated again.

UI screen recording:

Screenshots

Admin — page 1: users, rules, entities, token budget, freshness and Enabled toggle per persona

Admin — page 2: cursor pagination (Page 2 of 3, 15 records per page)

Non-admin (Data Consumer): read-only; cache status isn't requested, so entities show 0, budget and freshness show —, and toggles are disabled

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests around the new logic.

Replace the persona cards with a table of users, rules, entities,
context budget used (estimated tokens), freshness and an Enabled toggle.

Add GET /v1/personas/aiContext/status, an admin-only endpoint that pages
like GET /v1/personas and reads each persona's cached context without
compiling it, so the table never triggers document generation.

Fix GET /v1/personas?fields=users returning no users: list endpoints fill
fields through bulk fetchers and PersonaRepository had none for users.

Let the Playwright persona helper page through the table to find a
persona, and add a spec for the table flows.
@github-actions github-actions Bot added the UI UI specific issues label Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Rohit0301 Rohit0301 self-assigned this Oct 14, 2026
@Rohit0301 Rohit0301 added the safe to test Add this label to run secure Github workflows on PRs label Oct 14, 2026
@Rohit0301
Rohit0301 marked this pull request as ready for review October 14, 2026 09:48
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 928 → 929
- 1 added, 0 removed, 10 changed spec-list

New source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/support/fixtures/userPages.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/persona/PersonaClass.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/user/UserClass.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/entity.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/personaAIContext.ts
  openmetadata-ui/src/main/resources/ui/src/components/PaginationComponent/PaginationComponent.tsx
  openmetadata-ui/src/main/resources/ui/src/components/common/NextPrevious/NextPrevious.tsx
  openmetadata-ui/src/main/resources/ui/src/components/common/NextPreviousWithOffset/NextPreviousWithOffset.tsx
  openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 1 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 1 warning(s) across 1 changed file(s).

Count Rule
1 openmetadata-imports/no-lower-layer-page-imports
All findings
Location Rule Message
🟡 src/utils/PersonaAIContextUtils.ts:36:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 77%
77.75% (126552/162757) 64.41% (80083/124320) 65.62% (26707/40694)

Page clicks wrote only the page number to the URL, so a reload or browser
Back restored page N while fetching page 1. The cursor is now saved with
the page and the table fetches whatever cursor the URL holds.

Move PersonaContextStatus from a Java record and a hand-written TS
interface to type/personaContextStatus.json, so both are generated, and
record the endpoint contract in a decision record.
Rohit0301 and others added 3 commits October 14, 2026 18:12
#35348 resized Button and ButtonUtility to the Figma icon spec without
updating the visual-regression baselines, so every PR fails the same
seven snapshots (header buttons, the domain picker and page actions
shrink, shifting the content around them). Replace them with the
screenshots CI captured in the pinned Playwright container.
…ui-convert

# Conflicts:
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/VisualRegression/__snapshots__/aiModePages.spec.ts-snapshots/ai-explore.png
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/VisualRegression/__snapshots__/metricList.spec.ts-snapshots/metric-list-narrow.png
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/VisualRegression/__snapshots__/staticPages.spec.ts-snapshots/glossary.png
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/VisualRegression/__snapshots__/staticPages.spec.ts-snapshots/landing-page-sidebar-collapsed.png
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/VisualRegression/__snapshots__/staticPages.spec.ts-snapshots/landing-page.png
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/VisualRegression/__snapshots__/staticPages.spec.ts-snapshots/settings.png
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/VisualRegression/__snapshots__/staticPages.spec.ts-snapshots/users.png
@Rohit0301
Rohit0301 added this pull request to the merge queue Oct 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 15, 2026
@github-actions github-actions Bot added the merge conflict Conflicts with the latest main; removed from the merge queue label Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-10-15T09:10:38Z)

The entry left the queue before it was built, so no checks ran against it.

Conflicts with the latest main — rebase, then re-queue.

…ui-convert

# Conflicts:
#	.github/playwright/impact-map.generated.json
@github-actions github-actions Bot removed the merge conflict Conflicts with the latest main; removed from the merge queue label Oct 15, 2026
@Rohit0301
Rohit0301 enabled auto-merge October 15, 2026 09:20
@Rohit0301
Rohit0301 added this pull request to the merge queue Oct 15, 2026
@karanh37
karanh37 removed this pull request from the merge queue due to a manual request Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-10-15T17:21:21Z)

Blocked the queue: integration-tests-mysql-elasticsearch, integration-tests-postgres-opensearch

…s API

The status endpoint rebuilt its paging with ResultList(data, before,
after, total), which Base64-encodes the cursors it is given. The cursors
from listInternal are already encoded, so every before/after it returned
was double-encoded and paged to an empty result. Reuse the persona
page's Paging as is, and assert in the IT that both APIs return the same
cursor and that the next page is not empty.
@gitar-bot

gitar-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 closed / 2 findings

🟡 Medium risk · The new admin toggle persists persona AI-context enablement, so an unintended change could alter context available in persona-driven responses.

Turns the Context Center AI Context persona list into a paginated table showing users, entities, token budget and freshness per persona, backed by a new admin-only GET /v1/personas/aiContext/status endpoint that reads the context cache without compiling. Also fixes GET /v1/personas?fields=users returning no users. Resolved the URL page-number/cursor mismatch that made Back show page 1, and the missing decision record for the new status API contract. No open issues remain.

✅ 2 closed
✅ Bug: Page number survives in URL but cursor doesn't, so Back shows page 1

📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx:77-85 📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx:115-117 📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx:119-129
handlePageNavigation calls handlePageChange(newPage) without cursor data. usePaging writes currentPage=N to the URL and reads it back on mount (initialCurrentPage), but fetchPersonas() on mount always runs with no cursor. Say a user goes to page 2 and clicks a row (the row navigates to the persona), then presses browser Back. The pager now says page 2 but shows page 1's personas. paging.before is undefined, so Previous does nothing, and Next labels page 2's data as page 3. A reload breaks the same way. Fix: pass { cursorType, cursorValue: cursor } to handlePageChange, and on the initial fetch use pagingCursor.cursorType/cursorValue from usePaging. Or, if the page shouldn't survive navigation, reset the page to 1 on mount.

✅ Quality: New aiContext/status REST contract has no decision record

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/PersonaResource.java:475-489 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/teams/PersonaResource.java:750-756 📄 openmetadata-ui/src/main/resources/ui/src/rest/PersonaAPI.ts:91-105
This PR adds a public REST contract: GET /v1/personas/aiContext/status, with limit/before/after parameters and the PersonaContextStatus payload (personaId, cacheState, lastGeneratedAt, entitiesIncluded, tokensEst, lastError). The UI depends on it through a hand-written TS interface in PersonaAPI.ts. Nothing in docs/decisions/ covers it. The record would say: "The persona AI-context status endpoint pages with the same listInternal cursor and filter as GET /v1/personas, so one cursor works for both. It only reads PersonaContextCache, never compiles, and reports an uncached persona as STALE with zero counts. tokensEst is ceil(chars/4), the same as the document endpoint." Separately, java.md says public REST response shapes belong in openmetadata-spec JSON Schema. Defining PersonaContextStatus there would generate the TS type, so the hand-written interface couldn't drift from the Java record.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Rohit0301
Rohit0301 enabled auto-merge October 15, 2026 18:48
@sonarqubecloud

Copy link
Copy Markdown

@Rohit0301
Rohit0301 added this pull request to the merge queue Oct 15, 2026
@sonarqubecloud

Copy link
Copy Markdown

Merged via the queue into main with commit 812f2ce Oct 16, 2026
84 of 85 checks passed
@Rohit0301
Rohit0301 deleted the Rohit0301/ai-persona-ui-convert branch October 16, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants