Skip to content

fix(app-shell): cut the record discussion read's last page at the row budget, decline a thread past it - #39308

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-39296-client-read-row-budget
Dec 3, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-39296-client-read-row-budget

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #39296
Clause-②: no
Metadata-protocol: none

维护者速读

  • 在同时设了分页大小和单次读取行数上限的部署上,列表页评论栏和手机评论页现在与记录页一致:评论没超上限时显示全部评论,超过上限时显示已有的「无法加载此记录的评论」提示,不再只显示前几页。
  • 属于记录评论专题,替在这类部署上查看评论的用户解决「评论条数在不同页面上对不上、少了也不提示」的问题。
  • 只影响这类部署上评论正好碰到行数上限的记录;出错时最坏是多发几次被拒的读取或多显示一次提示,改动可直接撤回。
  • 无

What changes

On a deployment with both a data page size and OS_DATA_QUERY_ROW_BUDGET, the client's direct discussion read (readEveryPage, used by the list-page comments column, the phone comments page and every comment read the record page payload does not serve) paged $top: pageSize, $skip: rows.length with no last-page cut, and on a later page's 400 QUERY_ROW_BUDGET_EXCEEDED kept the pages read. The record page payload's read (readWholeStream in packages/rest/src/record-page-routes.ts) cuts its last page at the budget and answers a thread past it with the refusal. Premise re-read on main at f808641: holds as the card states.

The budget is not served to the client (the refusal envelope carries code and status; the number appears only in the message prose, which this change does not parse), so no new client/server surface is added. The refusal locates the budget instead, under the data door's own contract (refuse, never clamp: a page is refused exactly when $skip + $top is past the budget):

  • ui/packages/app-shell/src/views/useRecordDiscussion.ts — readEveryPage: a later page the row budget declines is asked again with a smaller $top, halving between the largest $top answered and the smallest refused (at most about log2 of the page size extra reads; a refused one never reaches the driver). That ends the last page at the budget. A thread that ends inside the cut page is read whole; one with rows past it (the cut page still answers hasMore, or no row of the page fits) rethrows the server's own refusal, which the caller records declined (the existing state from fix(app-shell): a record discussion the row budget declines is not shown as empty #39287, drawn with the existing "We couldn't load the comments for this record." note, no new wording). Any other later 400 keeps today's behaviour. The FeedReadVerdict doc for declined gains the paged case.
  • The reaction read (readCommentReactionRows) goes through the same readEveryPage, so it follows the same rule: reactions that fit are all shown; reactions past the budget throw, and the comments show without reactions, as the payload's refused reaction read (reactionRows null) does.
  • ui/packages/app-shell/src/views/useRecordDiscussion.test.tsx — a new describe over a double of the data door's read limits (page size, budget; refuse never clamp).
  • ui/packages/app-shell/src/views/ObjectView.phoneCommentsPage-39086.test.tsx — the existing case "does not report gone a thread the deployment's row budget keeps out of the read" pinned the short-list consequence (the read kept two rows and the page then asked findOne for the thread). It now pins the aligned behaviour: the declined note shows, the thread is not judged gone (findOne not called), the page stays on the thread.
  • .changeset/39296-discussion-read-row-budget-cut.md — @object-ui/app-shell patch.

Read first, by risk: (1) readEveryPage in useRecordDiscussion.ts — the probe loop and the two throw refusal exits; (2) the new describe "a paged discussion against the row budget" in useRecordDiscussion.test.tsx, whose door double is the contract the probe relies on; (3) the edited phone comments page case.

Tests

  • New describe "useRecordDiscussion — a paged discussion against the row budget": page 3 / budget 7 / 7 comments gives all 7 and pins the reads [[undefined, undefined], [3, 3], [6, 3], [6, 1]]; page 3 / budget 6 / 7 comments gives declined and no rows; page 3 / budget 8 / 10 comments gives declined; page 2 / budget 5 / 5 reactions shows all 5; 6 reactions shows the comment without reactions and pins the reads [[undefined, undefined], [2, 2], [4, 2], [4, 1]].
  • Ablation (scripts/ablation-replace.mjs, committed first, restored to HEAD): mutating the later-page branch back to "break on declined" turns all 5 new cases red (6 of 7 comments; undefined instead of declined twice; [4] instead of [5] reactions; reaction reads stop at 3); restore proven (blob == HEAD, git diff HEAD empty).
  • Every ui/ test file that reads the discussion (42 files) and @object-ui/app-shell type-check are green on the tree of 28e3191 (its ui/ files byte-identical to the runs; the last commit adds only the changeset).
Test and ablation readings
pnpm --dir ui exec vitest run useRecordDiscussion.test.tsx RecordDetailView.feedLoadFailure-29188.test.tsx ObjectView.phoneCommentsPage-39086.test.tsx
 Test Files  3 passed (3)
      Tests  49 passed (49)

ablation-replace: ok mutation landed: anchor 1 -> 0, blob b9207fd03cad -> 1adab7c57ba6
     x reads a thread that fits a budget the page does not divide whole (page 3, budget 7, 7 comments)
       AssertionError: expected [ 'Comment 1', 'Comment 2', ...(4) ] to have a length of 7 but got 6
     x records a thread past the budget as declined, not the pages read (page 3, budget 6, 7 comments)
       AssertionError: expected undefined to be 'declined'
     x records a thread past a budget the page does not divide as declined (page 3, budget 8, 10 comments)
       AssertionError: expected undefined to be 'declined'
     x reads every reaction that fits the budget, by the same rule (page 2, budget 5, 5 reactions)
       AssertionError: expected [ 4 ] to deeply equal [ 5 ]
     x shows the comments without reactions when the reactions run past the budget
      Tests  5 failed | 12 passed (17)
ablation-replace: ok restored: blob == HEAD (b9207fd03cad) and `git diff HEAD` is empty

pnpm --dir ui exec vitest run --maxWorkers=2 (every ui test file naming useRecordDiscussion, readRecordComments or sys_comment)
 Test Files  42 passed (42)
      Tests  690 passed (690)

pnpm --filter @object-ui/app-shell run type-check   -> exit 0, 0 error TS lines

Acceptance notes

  • Card acceptance, client door: page 3 / budget 7 gives 7 comments; budget 6 gives the declined state; both red without the fix. The server door is fix(rest): serve the record page discussion whole past the data page size #39294's readWholeStream, unchanged here.
  • The client still does not know the budget: each read that meets it spends a few refused probes (bounded by log2 of the page size) to find the cut. A served limit would remove them, but it would be a new client/server surface, which the claim rules out; not filed.
  • A later page refused with any other 400 still ends the paging with the pages read standing (pre-existing, not the budget's case, not reached by any door this change knows of).

Verification

Two minutes: pnpm --dir ui exec vitest run packages/app-shell/src/views/useRecordDiscussion.test.tsx from the repo root (after building @objectstack/spec and the @objectstack packages ui/ imports) — expect 17 passed, including the five cases of "a paged discussion against the row budget".

Local gates (dispatch-gates --commands, 39 derived): 36 run green, 3 NOT MEASURED (check-comment-mask-corpus, check:query-options-erasure, check:type-check-debt timed out on a shared box; CI runs them); --ran reconciliation: 39 accounted, 0 unrun. overlap-check: merges cleanly with origin/main dc4a2cd.


Generated by Claude Code

… budget, decline a thread past it

Claude-Session: https://claude.ai/code/session_01Utp6Ca2yTZZiHWkyVgD2oK
Co-authored-by: Claude <noreply@anthropic.com>
…ne on the phone comments page

Claude-Session: https://claude.ai/code/session_01Utp6Ca2yTZZiHWkyVgD2oK
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6Ca2yTZZiHWkyVgD2oK

L1: ACCEPT (code and evidence) · PR #39308 at head 28e3191 (gh api …/pulls/39308 .head.sha, read before the CI below) · CI not yet concluded, so the PR stays draft until the floor and all checks are green on this head.

Seat, 2026-12-03T11:48Z: conditions met. CI at 28e3191b57: 38 success · 15 expected skip · 0 failed · 0 pending; mergeable_state clean; l1-face CLEAN. K: behind main by 3 (compare API), so K < 15. The batch-budget disagreement in the last note is filed as #39313 (sub-issue of #39077). Landing: zone marks ready and arms auto-merge; Fixes #39296 closes the card.

What I read. The body of card #39296 and its comments: triage 7375009116, claim 7375083193, os-dev-report 7376601317 (2026-12-03T11:22Z). The PR body. The net diff against main dc4a2cd (4 files; git merge-tree merges cleanly). On origin/main I read the door contract (planQueryReadWindow / assertQueryReadRows in packages/types/src/query-read-limits.ts, ProtocolDataCrudFacet.findData in packages/metadata-protocol/src/protocol-data-crud.ts), readWholeStream in packages/rest/src/record-page-routes.ts, the client adapter's hasMore and $count handling, and the declined consumers (RecordDetailView, objectViewCommentsShared). I ran l1-face.mjs --pr 39308 2026-12-03T11:23Z and read the check-runs 2026-12-03T11:24Z.

Face. Shape, first line Fixes #39296, keywords, releases path, changeset, NUL suspects and declarations are all ok. The floor checks and the full check set were NOT MEASURED: at 2026-12-03T11:24Z, 19 runs had succeeded, 0 had failed, and 22 were in progress (Lint ×9, Type Check · source/consumer, Type Check UI, Test UI 1–9/16, Build & E2E UI). Dogfood and Skills-docs are not owed. Fixes is right: the card's acceptance is on the client door, and the server door is #39294's, unchanged here.

The halving probe against the door's contract.

  • Refusal comes first. With a limit named, planQueryReadWindow refuses when offset + limit > rowBudget. It never clamps, and it throws before engine.find, so a refused probe does no driver work. An answered probe costs one find plus one count.
  • hasMore is truthful. The client sends no $count: false, so findData takes the count arm and computes hasMore = offset + rows < count. That is the exact signal the "rows past the cut" exit needs.
  • Error code, not message text. The declined verdict still comes from the code, via answeredLoadFailure(err)?.code === 'QUERY_ROW_BUDGET_EXCEEDED'. No message prose is parsed.
  • Edge cases, traced by hand:
    • pageSize 1: no probe runs, because refused − answered = 1. The read rethrows and records declined, which is right: the page before said hasMore.
    • Budget an exact multiple of the page: the last page answers hasMore: false, so the thread is read whole. With one more row, the single probe at $top: 1 is refused and the read is declined.
    • Budget smaller than the first page: the first read is refused before the loop, and that path is unchanged.
    • Concurrent inserts or deletes between probes: the result is either a fresh-read answer or declined. A zero-row answer that still says hasMore stops short, but that needs a race and the main loop already behaves that way.
  • Independent check. I wrote a scratch simulation (sim/sim.mjs) of the door (refuse, never clamp, count-based hasMore), the head's readEveryPage and fix(rest): serve the record page discussion whole past the data page size #39294's readWholeStream. Over pageSize 1–16, budget 1–60 and thread length 0–70 (68,160 cases):
    • client and payload disagree in 0 cases;
    • the client never returns a short list;
    • the client makes at most ⌈log2 pageSize⌉ extra reads (worst case 4).

Agreement with the payload on the card's cases. With page 3 and budget 7, both give 7; the test pins the reads [[–,–],[3,3],[6,3],[6,1]]. With budget 6, both give declined. Reactions use the same readEveryPage: reactions past the budget throw, records becomes null, and the comments show without reactions. That matches the payload, where a refused reaction arm gives reactionRows null.

Surface. No guess and no new client or server surface: the PR only sends the $top and $skip the read already sent. The files stay within the claim's file surface; the phone-comments host test is named there. The host-test change is right: with pageCap 2 and budget 2, the old case pinned the short list (2 rows, then findOne for c3). The case now pins declined, the existing note, no findOne, and the page staying on the thread, which is the card's intended behaviour. Leaving other later-page 400s as they are is fine: for the same filter at a page size no larger than the first page, the only later-page 400 a door produces is the budget's. It is pre-existing and noted in the PR body.

Evidence.

  • Ablation is pinned to this head. The mutation ran on blob b9207fd03cad, which is useRecordDiscussion.ts at 28e3191, and the restore check reads blob == HEAD. All 5 new cases went red, each for the expected reason. The last commit 311d554→28e3191b adds only the changeset.
  • Positive control. The door double refuses when $skip + $top > budget, as the real door does. The reads-sequence assertions show that the cut actually happens.
  • Gap. The budget-6 and budget-8 cases assert the verdict and empty items, but not the reads. The other cases cover that, so it does not block.

Changeset sentences, checked against the diff and main:

  1. The title is true.
  2. "list page's comments and the phone comments page read … page by page": true. Both go through readRecordComments, and objectViewCommentsShared serves the column and the page.
  3. "A later page … refused with 400 QUERY_ROW_BUDGET_EXCEEDED, and the read kept the pages before it": true of main.
  4. "page 3, budget 7: 6 of 7": true.
  5. "past the budget … shown as its first pages with a count, while the record page showed the whole discussion or its 'could not load' notice": true after fix(rest): serve the record page discussion whole past the data page size #39294.
  6. "asks the refused page again with a smaller page, ending it at the budget": true.
  7. "records the existing declined verdict … 'We couldn't load the comments for this record.' notice, as the record page does": true. The string is en.ts commentsLoadFailed, and objectViewCommentsShared maps declined to commentsFailed with no Retry.
  8. "reaction read follows the same rule …": true for each read.

PR body footer. _Generated by [Claude Code](https://claude.ai/code/session_…)_ under --- is exactly AGENTS.md's session-URL form for PR bodies, so there is no deviation. The commit trailers are the model-free pair.

Clause-②: no. No published accept-set change: the change is client-only, and the request and response shapes are untouched. No contract review is owed.

Non-blocking, not filed. The client splits reaction reads into batches of 100 comment ids, and the row budget applies to each batch separately. The payload reads one $in today, and #39309 (card #39297, open) moves it to chunks of 500. So for threads over 100 comments, whether reactions are declined can differ between the two doors. This is pre-existing, outside this PR's surface, and best judged in #39309's review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record discussion client read keeps a short list at the row budget where the record page payload answers the whole thread or the budget refusal

2 participants