Skip to content

Commit a6544d8

Browse files
committed
Merge origin/main into claude/project-thread-j77l7i (#36129 related tab)
Claude-Session: https://claude.ai/code/session_01L6bhgUZTwDqtEFzNFCVTri Co-authored-by: Claude <noreply@anthropic.com>
2 parents d2de1eb + 8807dcb commit a6544d8

38 files changed

Lines changed: 2093 additions & 320 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@object-ui/core': patch
3+
'@object-ui/i18n': patch
4+
'@object-ui/plugin-list': patch
5+
'@object-ui/plugin-detail': patch
6+
'@object-ui/app-shell': patch
7+
---
8+
9+
feat(ui): a record page's related tab is the child object's full list
10+
11+
Clause-②: yes (widening) — a new export `ListConditionsBlock` (`@object-ui/plugin-list`, the condition row as a host element, not a registered node type) and its `ListConditionsHostProps`; a new slot `RelatedListConditionsSlotContext` and its `RelatedListConditionsProps` (`@object-ui/plugin-detail`), which the record page fills (`@object-ui/app-shell`); new exports `ConditionDiscardButton` and its type `ConditionDiscardButtonProps` (`@object-ui/plugin-list`) and `withHeaderSortPick` (`@object-ui/core`); new i18n keys in every `@object-ui/i18n` locale pack (`listConditions.chips.discard`, `listConditions.chips.discardHint`, `detail.relatedNoMatches`, `detail.deleteRowsTitle`, and the count family `detail.deleteRowsConfirmation` with its plural slots `_zero`, `_one`, `_two`, `_few`, `_many`, `_other` as each pack needs them); nothing removed or renamed
12+
Metadata-protocol: none
13+
14+
On a record page, a related list opened as its own tab now works like the object's list page:
15+
16+
- The first row names the child list (its tile and title) on the left and keeps **+ Add** on the right. The **Open in list** button is gone.
17+
- The second row is the list page's own condition row: **Sort** (several levels) and **Filter**, with no view switch, view settings or search. On a narrow tab or in the drawer their labels fold to icons.
18+
- The table is the list page's grid: the column menu, cell editing as on the list page wherever the reader may edit the child object, row selection with the floating bulk bar (bulk delete asks once, deletes the selection in one batch call where the data source has one, and says how many rows went and how many did not), and the footer row, whose calculations cover every matching row, not just the loaded ones. A tab grouped by status draws no footer row.
19+
- Rows load as the page scrolls instead of in pages.
20+
- The tab title still counts every child; the footer counts the rows the filter keeps.
21+
- What the reader changes (sort, filter, footer calculations) lasts while they stay on the record, for that reader only, across its tabs and between its page and its drawer, and is gone after a reload or on another record. **Discard** appears once something changed and puts the tab back; there is no Save. The list page's Discard and this one are one button.
22+
23+
Upgrade note: the header sort and the column widths and order that an earlier version remembered for a related tab in a reader's record-page preference (`sys_user_preference`) no longer apply: the tab opens in its declared order, and its column widths and order are now kept in the reader's browser, as the list page's are, so they start from the default once. Nothing stored is deleted. The default sort and columns of every related list are unchanged.
24+
25+
`@object-ui/core` adds `withHeaderSortPick`, the list page's rule for how a header sort joins an existing multi-level sort, now shared with the related tab. `@object-ui/app-shell`'s list Discard is drawn by `ConditionDiscardButton`; it looks and behaves as before.

‎scripts/pm/fleet-write/execute.mjs‎

Lines changed: 51 additions & 9 deletions
Large diffs are not rendered by default.

‎scripts/pm/fleet-write/ops.mjs‎

Lines changed: 131 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@
865865
* 31368 records them: 「你应该能自主读到所有的安全问题才是合理的」.
866866
*
867867
* row request the payload carries
868-
* `advisory_list` `GET …/security-advisories?state=S&per_page=100[&after=C]`, and nothing else `public_key` alone
868+
* `advisory_list` `GET …/security-advisories?state=S&per_page=100[&after=C]`, and at most one `GET /repos/{repo}` `public_key` alone
869869
*
870870
* The caller names NO state and NO query parameter: the row lists every state
871871
* in `ADVISORY_LIST_STATES` (`triage`, `draft` and `closed`, every unpublished
@@ -883,7 +883,23 @@
883883
* origin and path are the relay's own API and this collection, its `state` the
884884
* walk's own, and the cursor one value in `ADVISORY_LIST_CURSOR_SHAPE`
885885
* (`advisoryListNextCursor`); the next path is the relay's own spelling with
886-
* that cursor, never the link. A link that is none of these, a page that is not
886+
* that cursor, never the link. The collection is this one under either
887+
* spelling: `/repos/{repo}/security-advisories`, or the numeric
888+
* `/repositories/{id}/security-advisories` GitHub's `Link` headers use for a
889+
* request made on the named path (its pagination guide's example; this
890+
* repository's own pull-files links, `scripts/pm/check-governed-merges.mjs`)
891+
* — the numeric one only when `{id}` equals the repository's own id, which the
892+
* walk reads ONCE, with one `GET /repos/{repo}`, the first time a link names
893+
* one (`advisoryListRepoIdOf`: 200, its own full name, a positive integer),
894+
* ⛔ never an id taken from the link; a read that fails is a FAILED action
895+
* naming its status alone (`advisoryListRepoIdUnreadText`). Other query
896+
* parameters of the link (`per_page`, a `page` beside the cursor) are never
897+
* read. A refused link prints its SHAPE beside the fixed sentence
898+
* (`advisoryListLinkShape`): the next-link count, the origin as the relay's or
899+
* another, the path with the owner, the name and every id replaced by a
900+
* placeholder, the query parameter NAMES, and whether `state` and `after`
901+
* stand as the walk needs — ⛔ never a host, id, state, cursor or any other
902+
* value, so the next mismatch reads from the job log. A link that is none of these, a page that is not
887903
* a list of advisories in the state asked for, an advisory whose `severity` is
888904
* not one of `ADVISORY_LIST_SEVERITIES` or null or whose `created_at` or
889905
* `updated_at` is neither null nor an ISO-8601 string
@@ -919,18 +935,19 @@
919935
* no byte read-back for it: opening the parts IS its read-back.
920936
*
921937
* ⛔ What crosses the public run: that the listing landed or failed, the HTTP
922-
* status, `advisoryListCall` (the call, its states in braces) and the padded
923-
* ciphertext. NEVER an id, a count, a state, a severity, a cursor, a page
924-
* number, or a byte or part count of the listing.
938+
* status, `advisoryListCall` (the call, its states in braces), the padded
939+
* ciphertext and, on a refused next link, that link's shape. NEVER an id, a
940+
* count, a state, a severity, a cursor, a page number, or a byte or part count
941+
* of the listing.
925942
*
926943
* The grant and the gate are `advisory_read`'s. Its `grant` is `read` on the
927944
* stroke-scoped `repository-advisories`, so the validator writes
928945
* `permission_repository_advisories=read` for its stroke through the
929946
* workflow's existing input; it travels `alone`; and its `senderGate` is
930947
* `target-write` from `ADVISORY_READ_SENDER_GATES`: write, maintain or admin on
931948
* the target, which every stroke passes before its first request. A row naming
932-
* any other gate is refused before the first GET. The first live run measures
933-
* what the read grant lists and the form of the `Link` cursor. A refusal there
949+
* any other gate is refused before the first GET. The repository read rides
950+
* the stroke's literal `metadata: read`. A refusal there
934951
* is a FAILED action carrying `ADVISORY_LIST_ACCESS_REMEDY`, ⛔ never a retry
935952
* under a wider token.
936953
*
@@ -2480,35 +2497,129 @@ export const ADVISORY_LIST_CURSOR_REFUSED =
24802497
'collection or this state, or a cursor that is not exactly one value in its declared shape — so nothing was sealed or emitted';
24812498

24822499
/**
2483-
* The next cursor of a full page (header): `{ after }` — `null` when the `Link` header names no `rel="next"`, which ends
2484-
* the walk — or `{ fail }` with `ADVISORY_LIST_CURSOR_REFUSED`. A next link is followed only when there is exactly one,
2485-
* its origin is `api`'s and its path is exactly `repo`'s collection, its `state` is exactly the walk's, and it carries
2486-
* exactly one `after` in `ADVISORY_LIST_CURSOR_SHAPE`. Pure; never throws.
2500+
* The collection a next link may name by the repository's NUMERIC id (header: "The one row that LISTS advisories"):
2501+
* `/repositories/{id}/security-advisories`, the spelling GitHub's `Link` headers use for the collection the request
2502+
* named as `/repos/{owner}/{name}/…`. The id is decimal digits with no sign and no leading zero, at most 20. It is
2503+
* followed only when it equals the repository's own id, read once by the walk (`advisoryListRepoIdOf`).
24872504
*/
2488-
export function advisoryListNextCursor(link, { api, repo, state }) {
2489-
if (link === null || link === undefined || link === '') return { after: null };
2490-
if (typeof link !== 'string') return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2505+
export const ADVISORY_LIST_NUMERIC_COLLECTION_SHAPE = /^\/repositories\/([1-9][0-9]{0,19})\/security-advisories$/;
2506+
2507+
/**
2508+
* The repository's own numeric id from the answer of `GET /repos/{repo}`: a positive safe integer, as a decimal string,
2509+
* when the answer is 200 with an `id` of that shape and a `full_name` equal to `repo` (case-insensitively, as the
2510+
* platform names a repository); otherwise `null`. Pure; never throws.
2511+
*/
2512+
export function advisoryListRepoIdOf(answer, repo) {
2513+
const json = answer?.json;
2514+
if (answer?.status !== 200 || json === null || typeof json !== 'object' || Array.isArray(json)) return null;
2515+
if (typeof json.full_name !== 'string' || json.full_name.toLowerCase() !== String(repo).toLowerCase()) return null;
2516+
return Number.isSafeInteger(json.id) && json.id > 0 ? String(json.id) : null;
2517+
}
2518+
2519+
/** What a walk prints when the repository's own id, needed to judge a numeric next link, could not be read: the status alone. */
2520+
export function advisoryListRepoIdUnreadText(status) {
2521+
return `a full page's Link header names the collection by a repository id, and the repository's own id could not be read (GET of the repository answered HTTP ${status}) to compare it with — nothing was sealed or emitted`;
2522+
}
2523+
2524+
/**
2525+
* The next cursor of a full page (header): `{ after }` — `null` when the `Link` header names no `rel="next"`, which ends
2526+
* the walk — or `{ fail }` with `ADVISORY_LIST_CURSOR_REFUSED`, or `{ needsRepoId: true }` when the one next link
2527+
* names the collection by a numeric id and `repoId` was not given (the walk reads the repository's own id once and
2528+
* asks again). A next link is followed only when there is exactly one, its origin is `api`'s, its path is exactly
2529+
* `repo`'s collection — as `/repos/{repo}/security-advisories`, or as `/repositories/{id}/security-advisories` with
2530+
* `{id}` exactly `repoId`, the repository's own (`ADVISORY_LIST_NUMERIC_COLLECTION_SHAPE`) — its `state` is exactly
2531+
* the walk's, and it carries exactly one `after` in `ADVISORY_LIST_CURSOR_SHAPE`. Other query parameters (`per_page`,
2532+
* a `page` beside the cursor, an empty `before`) are never read: the next path is the relay's own spelling. Pure;
2533+
* never throws.
2534+
*/
2535+
export function advisoryListNextCursor(link, { api, repo, state, repoId = null }) {
2536+
const nexts = advisoryListNextLinks(link);
2537+
if (nexts === null) return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2538+
if (nexts.length === 0) return { after: null };
2539+
if (nexts.length > 1) return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2540+
let url;
2541+
let base;
2542+
try {
2543+
url = new URL(nexts[0]);
2544+
base = new URL(api);
2545+
} catch {
2546+
return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2547+
}
2548+
if (url.origin !== base.origin) return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2549+
const states = url.searchParams.getAll('state');
2550+
const afters = url.searchParams.getAll('after');
2551+
if (states.length !== 1 || states[0] !== state || afters.length !== 1 || !ADVISORY_LIST_CURSOR_SHAPE.test(afters[0])) return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2552+
if (url.pathname === `/repos/${repo}/security-advisories`) return { after: afters[0] };
2553+
const numeric = ADVISORY_LIST_NUMERIC_COLLECTION_SHAPE.exec(url.pathname);
2554+
if (!numeric) return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2555+
if (repoId === null || repoId === undefined) return { needsRepoId: true };
2556+
return String(repoId) === numeric[1] ? { after: afters[0] } : { fail: ADVISORY_LIST_CURSOR_REFUSED };
2557+
}
2558+
2559+
/** The targets of a `Link` header's `rel="next"` links — `[]` for none or an empty header, `null` for one that is no string. */
2560+
function advisoryListNextLinks(link) {
2561+
if (link === null || link === undefined || link === '') return [];
2562+
if (typeof link !== 'string') return null;
24912563
const nexts = [];
24922564
for (const m of link.matchAll(/<([^>]*)>((?:\s*;\s*[^;,]*)*)/g)) {
24932565
const rel = /;\s*rel\s*=\s*"?([^";]*)"?/i.exec(m[2]);
24942566
// RFC 8288 §3.3: a relation type compares case-insensitively.
24952567
if (rel && rel[1].trim().toLowerCase().split(/\s+/).includes('next')) nexts.push(m[1]);
24962568
}
2497-
if (nexts.length === 0) return { after: null };
2498-
if (nexts.length > 1) return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2569+
return nexts;
2570+
}
2571+
2572+
/** The path segments a refused link's shape prints as they are; every other segment prints as a placeholder. */
2573+
const ADVISORY_LIST_SHAPE_WORDS = Object.freeze(['repos', 'repositories', 'security-advisories']);
2574+
2575+
/**
2576+
* The diagnostic a refused next link prints in the job log (header): the link's SHAPE, ⛔ never a value — how many
2577+
* next links, whether the first is on the relay's API origin, its path with the owner, the name and every id or other
2578+
* segment replaced by a placeholder (and whether they are this repository's), its query parameter NAMES, and of its
2579+
* `state` and `after` only whether each is the walk's, how many there are and whether a cursor is in its shape.
2580+
* No host, owner, name, id, state, cursor or other value is ever printed. Pure; never throws.
2581+
*/
2582+
export function advisoryListLinkShape(link, { api, repo, state, repoId = null }) {
2583+
const nexts = advisoryListNextLinks(link);
2584+
if (nexts === null) return 'link shape: the Link header is no string';
2585+
if (nexts.length === 0) return 'link shape: no rel="next" link';
2586+
const parts = [`${nexts.length} rel="next" link(s)`];
24992587
let url;
25002588
let base;
25012589
try {
25022590
url = new URL(nexts[0]);
25032591
base = new URL(api);
25042592
} catch {
2505-
return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2593+
return `link shape: ${parts[0]}; the first is no absolute URL`;
25062594
}
2507-
if (url.origin !== base.origin || url.pathname !== `/repos/${repo}/security-advisories`) return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2595+
parts.push(url.origin === base.origin ? "on the relay's API origin" : 'on another origin');
2596+
const segs = url.pathname.split('/').slice(1);
2597+
const [own0, own1] = String(repo).split('/');
2598+
const shown = [];
2599+
let note = '';
2600+
for (let k = 0; k < segs.length; k++) {
2601+
const seg = segs[k];
2602+
if (k === 1 && segs[0] === 'repos' && segs.length > 2) {
2603+
shown.push('OWNER', 'NAME');
2604+
const same = seg === own0 && segs[2] === own1;
2605+
const folded = !same && seg.toLowerCase() === String(own0).toLowerCase() && segs[2].toLowerCase() === String(own1).toLowerCase();
2606+
note = same ? ' (OWNER/NAME this repository)' : folded ? ' (OWNER/NAME this repository in another letter case)' : ' (OWNER/NAME another repository)';
2607+
k++;
2608+
} else if (k === 1 && segs[0] === 'repositories') {
2609+
shown.push('ID');
2610+
note = !/^[1-9][0-9]{0,19}$/.test(seg) ? ' (ID not a repository id)' : repoId === null || repoId === undefined ? ' (ID not compared: the repository id was not read)' : String(repoId) === seg ? " (ID this repository's)" : ' (ID another repository\'s)';
2611+
} else if (ADVISORY_LIST_SHAPE_WORDS.includes(seg) || seg === '') shown.push(seg);
2612+
else shown.push(/^[0-9]+$/.test(seg) ? 'N' : 'SEG');
2613+
}
2614+
parts.push(`path /${shown.join('/')}${note}`);
2615+
const names = [...url.searchParams.keys()].map((n) => (/^[a-z_]{1,32}$/.test(n) ? n : 'NAME'));
2616+
parts.push(`query names [${names.join(',')}]`);
25082617
const states = url.searchParams.getAll('state');
2618+
parts.push(`state ${states.length === 0 ? 'absent' : states.length > 1 ? `${states.length} values` : states[0] === state ? "the walk's" : 'not the walk\'s'}`);
25092619
const afters = url.searchParams.getAll('after');
2510-
if (states.length !== 1 || states[0] !== state || afters.length !== 1 || !ADVISORY_LIST_CURSOR_SHAPE.test(afters[0])) return { fail: ADVISORY_LIST_CURSOR_REFUSED };
2511-
return { after: afters[0] };
2620+
const cursor = (c) => (ADVISORY_LIST_CURSOR_SHAPE.test(c) ? 'in its shape' : c.length > ADVISORY_LIST_CURSOR_MAX_CHARS ? 'over its length cap' : c.length === 0 ? 'empty' : 'with a character outside its alphabet');
2621+
parts.push(`after ${afters.length === 0 ? 'absent' : afters.length > 1 ? `${afters.length} values` : cursor(afters[0])}`);
2622+
return `link shape: ${parts.join('; ')}`;
25122623
}
25132624

25142625
/** The severities a listed advisory may carry, beside null (the platform's own enum for the field). */

0 commit comments

Comments
 (0)