Skip to content

fix(platform): load full feedback comments on expansion - #4298

Merged
yannickmonney merged 2 commits into
mainfrom
fix/feedback-full-comment
Oct 4, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/feedback-full-comment

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Fetch stored feedback comments only when the list explicitly marks their preview as truncated; preserve collapsed previews.
  • Scope the admin full-text endpoint by organization and the same non-trashed lifecycle predicate as the list.
  • Retain preview/full data while loading or after read/refetch failures, with truthful localized status/alert semantics.
  • Add real-query/adapter and Hono route regressions for request URLs, boundaries, EN/DE/FR states, authorization and visibility.

Verification

Installed Node, one Vitest worker: UI regressions 9/9; feedback backend 15/15; UI consumers 51/51; backend/locale consumers 274 passed (one unrelated collection blocked by missing local eventsource-parser). Scoped TypeScript diagnostics: zero on six changed files. Targeted type-aware Oxlint, Oxfmt, diff check and commit hooks pass.

The repair regressions fail on reviewed fb3a67a: 9 UI failures and 4 backend failures (2 backend controls pass). See the repair comment for exact head and full evidence. Previous local Bun collection limitations are superseded by the installed-Node runs.

No browser/PostgreSQL/full-stack proof: this repair has light-only admission. Independent exact-head re-review is requested; no self-acceptance or merge.

Closes #3661

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review of PR #4298 (TALE-202 / #3661): REQUEST CHANGES

Exact head: fb3a67a84d0e99d20d49d8b6c64de7fa5313ad73 (based on main 9e8f87f68; I checked the head when I started and again before posting). Reviewer: agent #2 3f9fdcee, run 0adb5797, card TALE-654. Author: Codex #6 8c78cac9, run a03b554f. I'm not the author. I didn't merge, push, move a card, or rerun or cancel CI. I ran light checks only: jsdom and node Vitest on /opt/node/bin/node with one worker, and no browser.

The long-comment path works. Expanding a truncated row fetches and shows the stored text. Two blocking findings remain, and under root's 08:15Z rule they hold until they're closed on an exact head with proof.

B1 (blocking): the full-text read doesn't match what the list shows, so a trashed row's comment stays readable

  • The list: listRecentFeedbackPage (service.ts:342) and the stats fold (service.ts:236) both read WHERE org_id = … AND lifecycle_status IS DISTINCT FROM 'trashed'.
  • The new read: getFeedbackComment (service.ts:214-225) checks only WHERE id = $1 AND org_id = $2.
  • Why it matters: messageFeedback is a Trash-listed soft-delete type (core/governance/soft_delete.ts, governance/trash.ts:96). The Trash page shows no text for these rows (displayExpr: 'NULL'), and an admin can restore them.
  • Effect: with the new route, an admin can read the full comment of a trashed feedback row by id. They can get the id from the Trash listing, or from a list page that was loaded before the row was trashed. No other screen shows that text.
  • Role and org already match: a member gets 403 from both /recent and the new read, and the read is scoped by org.
  • How reachable it is today: I found no code on this head that moves a feedback row into trashed. Only the Trash restore moves one out of it. So today a row would have to arrive already trashed. The list and stats still treat the state as hidden, and the review criterion is "matches the list".
  • Fix: add AND lifecycle_status IS DISTINCT FROM 'trashed' to the read, so a trashed row answers 404 like an unknown id. Add a route test in the existing routes.access.test.ts harness covering: member 403, admin 200, unknown id 404, and the predicate.
  • Proof: route probe R1–R3 drives the real Hono routes with a recording sql:
    • LIST: … FROM app.message_feedback WHERE org_id = $2 AND lifecycle_status IS DISTINCT FROM 'trashed' …
    • READ: SELECT comment FROM app.message_feedback WHERE id = $1 AND org_id = $2, answered 200.
  • Not run: a real-PostgreSQL check with a row in trashed.

B2 (blocking): the loading and error messages are false for rows whose text is already complete or missing

ExpandedComment (recent-feedback-table.tsx:18-49) sends a request on every expand, whatever row.comment holds. It then shows "Loading…" while pending and the error text on failure, and only otherwise data?.comment ?? noComment. The issue asks for a fetch only when the list payload holds just a preview. I tested with the real useBackendQuery, the real metrics adapter and a stubbed backendFetch:

  • P2: a row with no comment sends GET /feedback/recent/:id/comment and says "Loading full comment…". main shows "(no comment)" at once and sends nothing.
  • P3: the same row with a refused read says "Couldn't load the full comment." The row has no comment.
  • P4: a short comment that the list already returned in full is hidden behind "Loading full comment…". If the request fails, the error message replaces it. main shows the comment immediately.
  • P6: once the full text is on screen, a failed refetch replaces it with the error, although react-query still holds the text. Any invalidation can trigger this, and so can re-expanding after the 5-minute staleTime. The cause is that isError is checked before data.

Fix:

  • Fetch only when the projection was truncated. A list flag such as commentTruncated is safest. A client-side test like length > 500 && endsWith('…') would misread a real 501-character comment that ends in "…".
  • Otherwise render row.comment, or noComment when it's null.
  • While a truncated row loads, or after its read fails, keep the preview visible with a status or error line under it.
  • Prefer data over isError.

N1 (non-blocking): the tests don't pin the request or the states

  • The PR's only test mocks useBackendQuery. I mutated the adapter URL to /feedback/comment/:id: the PR's test still passed, and my probe P1 failed. The test also never renders the loading or error state.
  • The PR adds no route test. The PR body says local collection is blocked, but the existing feedback route harness runs here under installed Node: 4 files, 13/13 tests including my probes, in an 11 s run.

N2 (low, not run in a browser): the loading and error lines aren't announced

They are plain Text, with no role="status", role="alert" or aria-live. A screen-reader user who expands a row hears nothing when the full comment arrives or fails to load.

Contract checks

Check Result
A long comment shows its full accepted text ✅ P1: no request while collapsed. Expand calls backendFetch('/feedback/recent/fb-long/comment', {orgId:'org-1'}), shows "Loading full comment…", then the text past the 500-character cut. R2: an admin gets the stored comment (values ['fb-1','o1']), and an unknown id gets 404.
Loading and error messages are truthful ❌ B2
Collapsed previews are unchanged ✅ The comment column is untouched by the diff. P1: the collapsed cell renders the list's 501-character projection, and the tail is absent before expand.
The read is authorized and owned like the list ❌ B1 on lifecycle. ✅ on role and org (R1, R2).
EN/DE/FR strings ✅ The keys are in all three files. P5 renders the DE and FR loading and error strings, with the DE/FR expand labels. de-CH falls back to de.
The regression fails on main ✅ The PR's test against main's component source fails 1/1 ("Unable to find … /accepted explanation ending/"). It passes 1/1 at the head. My probe file passes 7/7 at the head and fails 7/7 on main's source.

Evidence at the head (Node 24, --maxWorkers 1)

  • PR test: 1/1.
  • Review probes (client project): 7/7.
  • Route probe plus the feedback backend tests (server project): 13/13.
  • Tests of code that imports the changed files:
    • client: analytics/feedback/, list-conventions, use-backend-query, use-backend-client, session-probe-observers: 8 files, 49/49;
    • server: app/lib/backend/ and loader-preload: 23 files, 254/254.
  • oxfmt --check and oxlint --type-aware on the 6 TS files, and git diff --check: all clean.
  • The probes were untracked, I removed them, and the worktree is back on main. Sources and logs are attached to TALE-654.

Not run

  • CI: Checks, Build, SAST, E2E and Commitlint have all been queued since 12:13:25Z, and no check has run on this head.
  • Local tsc.
  • PostgreSQL and full-stack checks, including the issue's 645-character reproduction.
  • Real browser, screen reader, visual analyzer, and the manual and E2E suites.

Verdict: REQUEST CHANGES at fb3a67a84d0e99d20d49d8b6c64de7fa5313ad73. Repairs go through the manager (TALE-357). A re-review needs a new exact head with B1 and B2 closed and tests that fail on this head.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

TALE-202 repair — distinct exact-head re-review requested

PR: #4298
New exact head: 909da9f233c45f2765530007acc91f44cc17ecb0.
Prior REQUEST_CHANGES receipt 09f1df86-961b-4a4f-85b6-d6e7c7267cfd / TALE-654 remains preserved; this is an author repair, not acceptance.

  • B1: full-comment SQL now uses the same lifecycle_status IS DISTINCT FROM 'trashed' predicate as the list. Real Hono access regressions verify member 403, admin 200, unknown/trashed 404, organization parameters and lifecycle predicate.
  • B2: the list emits commentTruncated; only explicitly flagged rows fetch on expansion. Short, null, empty and complete 501-character ellipsis-ending comments use their supplied text without a request. Preview stays visible during initial loading/failure; successful full data takes precedence over refetch errors.
  • N1/N2: tests use the real query hook and metrics adapter with only final backendFetch controlled, pin the request URL/org, verify no request while collapsed, deferred loading/success/failure and failed-refetch retained data. Status and alert roles plus a polite live region cover announcements. EN/DE/FR state tests pass without new translation keys. Collapsed previews are unchanged.

Light verification, installed /opt/node/bin/node, one Vitest worker:

  • Final feedback UI regression: 9/9; UI/consumer sweep: 7 files, 51/51.
  • Final feedback backend: 3 files, 15/15.
  • Backend adapter/locale/consumer sweep: 25 files passed, 274/274 tests; one unrelated suite cannot collect because local eventsource-parser is missing (conversations.wire.test.ts). No dependency installation or unrelated source changes.
  • Scoped TypeScript compiler diagnostics on six changed files (not whole-workspace tsc): 0 diagnostics.
  • Targeted Oxlint type-aware, Oxfmt, git diff check and commit hooks: passed. Hook local opengrep is cache-conditional, not a claim that full SAST ran.
  • Regression proof with implementation source at reviewed fb3a67a84d0e99d20d49d8b6c64de7fa5313ad73: all 9 UI cases failed; backend regression suite had 4 failures with 2 positive controls passing. Repaired source restored and final focused suites passed. Logs retained in task delivery.

Security/docs sweep: same admin authorization and tenant scope, now matching lifecycle visibility. Parameterized SQL and existing encoded adapter URL retained. Internal metrics read; no public API/docs contract or migration changes needed. Existing locale wording retained. DOM accessibility assertions passed, not a real screen-reader claim.

Unrun proof: PostgreSQL, browser/screen reader/visual analyzer, full-stack 645-character fixture, manual/E2E suites and full platform suite (no heavy admission). CI remains to be observed; no CI rerun or cancellation, merge or self-review. Please arrange a distinct exact-head re-review against this head, preserving the existing receipt and outstanding admission gates.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent re-review of PR #4298 (TALE-202 / #3661) after the B1/B2 repair: ACCEPT (source level)

Exact head: 909da9f233c45f2765530007acc91f44cc17ecb0. It is the reviewed head fb3a67a8 plus one commit touching 6 files. I confirmed the head at 15:06:44Z and again at 15:23:24Z before posting.

Reviewer: agent #2 3f9fdcee, run 763c809d, card TALE-679. Author: Codex #6 8c78cac9, repair run dca5f590 (settled 14:53Z), handoff 5f5bf098 on TALE-202. I'm not the author.

I didn't merge, push, move a card, or rerun or cancel CI. I ran light checks only: jsdom and Node Vitest on /opt/node/bin/node with one worker, with no browser and no PostgreSQL.

B1 and B2 are both closed at this head. Under root's 08:15Z rule, my REQUEST CHANGES receipt 09f1df86 (TALE-654) no longer blocks.

B1 (closed): the full-comment read now uses the list's lifecycle predicate

  • The fix: getFeedbackComment (service.ts:214-226) now reads WHERE id = $1 AND org_id = $2 AND lifecycle_status IS DISTINCT FROM 'trashed'. That is the same predicate as listRecentFeedbackPage (service.ts:343) and the stats fold (:237).

  • Null states: lifecycle_status is a nullable text column (0013_contacts_feedback_support.sql). IS DISTINCT FROM keeps rows with no state visible, as the list does.

  • Route regression (routes.access.test.ts): a member gets 403 and no SQL runs. An admin gets 200, an unknown id gets 404, a trashed row gets 404, and the read gets the values ['fb-1','o1'].

  • Fails on fb3a67a8, passes here: with fb3a67a8's sources under the head's tests, 4 of 6 route tests fail:

    • the trashed read answers 200 instead of 404;
    • the read's SQL lacks the predicate;
    • the list has no truncation flag.

    The 2 controls pass. At the head, all 6 pass.

  • Mutants:

    • dropping the predicate fails 3 tests;
    • letting members read fails 1;
    • answering an unknown id with 200 {comment:null} fails 2.
  • Probe RP2: the recorded read is SELECT comment FROM app.message_feedback WHERE id = ? AND org_id = ? AND lifecycle_status IS DISTINCT FROM 'trashed' with values ["fb-long","o1"]. The recorded list query carries the same predicate.

  • Not run: a real PostgreSQL row in trashed. The test fake returns no row only when the SQL text contains the predicate.

B2 (closed): only truncated rows fetch, the preview stays, and fetched data beats an error

  • Server flag: the list now emits commentTruncated: (row.comment?.length ?? 0) > 500 (service.ts:387).
  • Fetch gate: the component asks for the full comment only when row.commentTruncated === true, and passes 'skip' otherwise (recent-feedback-table.tsx:27; useBackendQuery supports 'skip').
  • What the row shows: a truncated row shows data.comment once its read has data. Every other case shows row.comment, or "(no comment)" when there is none.
  • State lines: the loading and error lines render under the preview, and only while data === undefined.
  • Fails on fb3a67a8, passes here: all 9 UI tests fail on fb3a67a8's component and pass at the head. Examples:
    • null, empty and short rows: "expected … not to be called";
    • while loading, the preview is found once instead of twice;
    • after a failed refetch, the full text is gone.
  • Mutants, each killed (failing tests in brackets):
    • fetch on every expand (4);
    • hide the preview while pending or failed (5);
    • error wins over data (1);
    • fetched text never shown (2);
    • no loading line (4);
    • server flag >= (1);
    • server flag removed (1).
  • My probes at the head, 7/7:
    • CP1: the server's own /recent page goes to the table, holding a 645-character comment as in the issue, a short one, a null one and a stored 501-character one. Requests go only to the two flagged rows. The 645-character text with its ending appears, the short and null rows show at once, and no loading or error line remains.
    • CP3: under the app's own retry policy, two transport failures keep "Loading full comment…", the alert never appears, and the third attempt shows the text.
    • CP4: re-expanding after a refused read shows the loading line, not the old error, and the preview stays.
    • CP6: a comment cleared since the list loaded shows "(no comment)" with no error.

N1 (closed): the tests use the real request URL and cover the states

  • The PR's UI test now keeps the real useBackendQuery and metrics adapter and stubs only backendFetch. It pins the call ('/feedback/recent/feedback-1/comment', {orgId:'org-1'}).
  • The adapter-URL mutant that passed the old test now fails it (1 test).
  • Loading, success, failure and failed-refetch are each tested.

N2 (closed): live status and error semantics

  • The loading line has role="status" and the error line has role="alert". Both sit with the comment text in an aria-live="polite" region (:31-46).
  • Removing each of the three fails tests: status 4, alert 3, the live region 1.

EN/DE/FR

  • The repair adds no keys. All three catalogs carry loadingComment and commentLoadFailed, and de-CH falls back to de.
  • My CP2 asserts the literal catalog strings rather than the EN fallback, and checks that the preview stays in both locales:
    • DE: "Vollständiger Kommentar wird geladen …" and "Der vollständige Kommentar konnte nicht geladen werden.", with the expand button "Zeile ausklappen".
    • FR: "Chargement du commentaire complet…" and "Impossible de charger le commentaire complet.", with the expand button "Développer la ligne".

Non-blocking notes

  1. Announcement length (a11y, not run with a screen reader): the polite region wraps the comment text itself. So when the full text arrives, a screen reader reads the whole comment, up to 5,000 characters. The alert also sits inside the polite region. A screen-reader pass should confirm this is acceptable; a short "full comment loaded" status is the alternative.
  2. One client test case can't come from the server: 'a'.repeat(500) + '…' with commentTruncated: false. A stored 501-character comment is longer than the 500-character projection, so the server flags it, and it fetches and shows the same text (CP1). The handoff's "complete 501-character ellipsis-ending comments use their supplied text without a request" holds only for a row whose flag is false. This isn't a defect, because a length-derived flag can't be wrong.
  3. The PR's EN/DE/FR test reads its expected strings through i18n.t. A missing DE or FR key would fall back to EN on both sides and still pass. CP2 covers the literal strings.

Evidence at the head (Node 24.21, --maxWorkers 1)

  • PR tests: UI 9/9, run with vitest.ui.config.ts as in CI's test:ui. Feedback backend 15/15 across 3 files.
  • Negative control: fb3a67a8's 4 source files with the head's tests. UI: 9/9 fail. Route: 4 fail and the 2 controls pass. Afterwards the files were restored and the worktree is clean.
  • Mutants: 14 one-change mutants, all killed.
  • Review probes: route 9/9 (the head's file plus RP1–RP3) and client 7/7.
  • Consumers:
    • UI 43/43 (analytics/feedback/, list-conventions, use-backend-query);
    • server 256/256 (backend/domains/feedback/, app/lib/backend/).
  • Lint and format:
    • oxlint --type-aware --type-check reports 0 diagnostics on the 6 changed files and on their importers (analytics/feedback/, metrics.ts, contract/, domains/feedback/). I first checked that it reports a planted TS2322.
    • oxfmt --check and git diff --check are clean.
  • Composition: the head merges cleanly with main dcfca9819. No PR file has changed on main since the base 9e8f87f68.
  • The probes were untracked, and I removed them; the worktree is clean. Scripts, logs and probe sources are attached to TALE-679.

Not run

  • CI: these runs have been queued since 14:49:56Z, and no check has run on this head, so it isn't green:
    • Checks 37210709598
    • Build 37210709713
    • E2E 37210709672
    • SAST 37210709656
    • Commitlint 37210709595
  • Local tsc.
  • PostgreSQL and full-stack checks, including the issue's 645-character reproduction.
  • A real browser, a screen reader, the visual analyzer, and the manual and E2E suites.

Verdict: ACCEPT at 909da9f233c45f2765530007acc91f44cc17ecb0 (source level). B1 and B2 are closed. Merging still needs green CI on this exact head and a distinct merger. I merge nothing in this run.

@yannickmonney
yannickmonney merged commit 4a33e48 into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/feedback-full-comment branch October 4, 2026 22:52
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.

bug(platform): expanded feedback comments cannot show text beyond the server’s 500-character preview

1 participant