Repository navigation
Commit f62d1ca
Rework the terminal UI of scan, list, show, get, rollback and vex; faster startup and multi-project scans (#2153)
* Fix a patched peer's hash marking its dependents as patched by the project
pnpm records a project's own patch of a package as a group of that
package's lock key: `a@1.0.0(patch_hash=...)`. It also repeats a patched
package's whole key, hash included, inside the peer group of every
package that depends on it: `b@2.0.0(a@1.0.0(patch_hash=...))`. The
project-patch detector looked for `patch_hash=` anywhere in a key, so
each of those dependents was read as patched by the project.
A scan leaves a package the project patches itself alone, so the
dependents were withheld from Socket patches (twelve packages in one
large pnpm monorepo, beside the twenty-one it really patches) and each
got a `user_patch_conflict` warning.
Only a group at the first level of a key counts now. A pnpm 7 key has no
groups and still carries the hash on its version, and `patched: true`
is read as before.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Add patch measurements, a contents-free patch view and a lookup memory to the API client
What the terminal UI reads from the patch service, and what lets a scan
of several project directories ask about a package once:
- `PatchResponse.statistics` and its types: what the patch service
measured about a patch (exploits blocked, package tests passing, the
size of the change, its run-time cost).
- `fetch_patch_statistics`, `fetch_patch_summary` and
`fetch_patch_with_sources`: the patch view without its file contents
(for measurements and listings) and with each file's content before
the patch (for a diff). The authenticated API leaves the contents out
on request; the public proxy serves one cached view either way.
- `ApiClient::remembering_lookups`: a client that keeps the answers to
its batch and per-package searches and answers a later search it has
the whole answer to without a request. Off unless asked for. Only
answers are kept, never failures, and only for exactly the purl
asked.
- The selection filter exposes whether it carries reachability
findings, and the state of one.
- The walk that finds a checkout's project markers runs on as many
threads as the crawl's walk pool. It is every hosted or vendored
scan's first wait in a large checkout.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Rework the terminal UI of scan, get, rollback, list, show and vex
Human output only: `--json` envelopes, warnings and events are
unchanged.
scan
- Each patched package is one row (severity, package, advisories, what
was measured about the patch, advisories left unpatched), and the run
closes with its totals once: packages patched across how many project
directories, vulnerabilities fixed, what is left to patch and why, the
same for reachable advisories when a selection filter carries
findings, and an estimate of the upgrade work the patches stood in for
(two hours per patched package, stated as an assumption).
- The packages the project patches itself are one note instead of a
warning per package. `--verbose` lists them.
- The status line opens with an activity mark that a ticker keeps
turning for as long as the line shows, so a long step never looks
hung. It draws on a terminal only, under one lock with every other
status write.
- Startup: the search for project directories an agent-mode scan does
not cover runs during the patch lookup, the policy step reuses the
`node_modules` roots the crawl walked instead of walking again, and
the project's own patches are read beside the crawl.
- A scan of several project directories crawls them all at once and
asks the patch service about each package once for the run, then
scans the directories in order as before.
list, show
- `show <patch>` is new: the advisories a patch fixes, what was
measured about it, the files it changes and the diff of each.
- On a terminal `list` is a full-screen table that fills in from the
patch service (advisories, severity, exploits blocked, tests passing,
lines changed, run-time cost, publish date). Enter opens a patch as a
page with its summary and diffs. `show` opens the same page. Both
redraw when the terminal is resized and leave the scrollback as it
was. Pipes, `--yes` and `--verbose` keep the printed listing.
get, rollback, vex
- `get` shows the measurements of the patches it lists and no longer
names each patch again while it downloads and applies.
- `rollback` lists the packages it restored once and shows progress.
- `vex` holds its advisories while it works and prints them folded by
kind, groups the patches it leaves out by reason, and says how to get
the patches installed when nothing could be attested. Its record
fetch asks for views without file contents.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Fix the code review findings in the terminal UI rework
Patch view
- A patch whose `statistics` this build cannot read (a field of another
type, an array where an object belongs) no longer fails the whole patch
view, which `get`, `show` and `vex` read: each measurement is parsed on
its own and one that does not parse is left off.
Scan
- The prefetch of a multi-directory scan stands down where file
descriptors are scarce, as every other part of a run does there. A
crawl that runs out of descriptors reads a directory it could not open
as absent and comes back short.
- Measurement requests keep to the patch API's own window instead of 16
at once (the public proxy's window is small), are not retried (a retry
opened the run's one retry window, which the downloads that follow may
need), and a listing waits at most 1.5 s for them.
- The rows of a dry run and of a report-only scan no longer open with
the check mark of a patch in place: the column stays and is blank.
Rollback
- The status line comes down before a gem's native extension is rebuilt,
which reports its own progress, and goes back up for the next package.
list and show
- The browser cut one read into one key. Several presses that arrive
together (a held arrow, a paste, a slow link) were read as a sequence
it does not know and dropped, and an escape sequence split across two
reads was read as Esc and closed the page. A read is now cut into its
keys, each acted on in order, and the start of a sequence at the end
of a read waits 40 ms for its rest before it is taken for Esc.
- Neither goes full-screen on a terminal that shows no escape sequences
(`TERM=dumb`, a console without VT processing): `list` prints its
entries and `show` its text, as on a pipe.
- `list` puts its table up before it builds the patch service's client,
which can mean a request (a token with no organization named has its
organization looked up). The first read that needs the client builds
it. Advisories are held while the browser has the screen and the one
that explains the rows prints once it is gone.
Shared
- The package naming and folding helpers that scan, list and vex each
wrote out are one copy in `ui/text.rs`.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Read a patch one way and show it on one screen in show and list
`show` and the page a row of `list` opens were one screen fed by two
readers, and `show` kept a second, older way to read a patch on a
terminal: a menu of its files and an external pager.
- One source of patches (`show::Source`) and one reader (`Shown::read`)
serve `show`, the page a `list` row opens and the rows of the `list`
table. A read the service refuses the run's token is asked of the
public service. When that has no such patch either, the refusal is
what is reported, not the public service's "no such patch".
- `show` has one reading screen, the page. The file menu and the pager
are gone: where the page cannot open (a pipe, `--no-pager`, `--yes`, a
terminal that shows no escape sequences, Windows) the summary and the
selected diffs print at once.
- The inline stand-in for the `list` table prints a pick's summary
(`show --stat`) instead of every diff.
- The worst severity and the advisory ids of a patch follow one rule
(`ui::worst_and_ids`) in the `list` row, `show`'s title and the patch
menu. An advisory that names no severity leaves none in the title.
- The reason a `list` page gives for showing the project's own record is
one line ending in one period, whatever the error's text.
Tests: Enter on a `list` row and `show <uuid>` draw the same page line
for line on a pty; a refused token is read from the public service, and
the refusal is reported when that has no such patch; `show --yes` on a
terminal prints at once and opens nothing.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Give an AI coding agent's terminal the plain output a pipe gets
Some agent harnesses run commands on a pseudo-terminal, and there the
CLI took the agent for a person. Measured on one: `list` in a patched
project went full-screen and waited for keys nobody presses, and a
dry-run scan of a large monorepo wrote 122 KB of which 12 KB was output;
the rest was redraws of the status line and color codes, all of it read
back into the agent's context.
- `ui::attended(stream)` is the one place that says whether a stream is
a terminal with a person at it: a terminal, and not one an agent runs
the command in. Every presentation choice asks it instead of
`is_terminal()`: the status line, color and glyphs, the full-screen
`list` and `show`, the arrow-key menus, text fitted to the terminal's
width, the measurements a terminal gets, the update notice. With the
same scan the agent now reads 11.6 KB and no escape sequence, and
`list` prints and exits.
- An agent is recognized by a variable it sets for the commands it runs:
`AI_AGENT`, then each tool's own (`CLAUDECODE`, `CURSOR_AGENT`,
`CODEX_SANDBOX`, `GEMINI_CLI`, `VSCODE_AGENT` and others; the list is
`ui::AGENT_ENV_VARS`). A variable an editor sets in every terminal is
not used, and neither is the bare `AGENT`.
- `SOCKET_PLAIN` overrides the detection, in the vocabulary of the other
toggles: truthy asks for plain output anywhere, any other value keeps
the terminal output for someone working in a terminal an agent
started. Where an agent's variable keeps `list`, `show` or a menu from
opening, one line on stderr names the variable and `SOCKET_PLAIN=0`.
- Typed yes/no confirmations are not presentation and are unchanged:
they are asked on any terminal, and `--yes` answers them.
- `--json` is unchanged.
Tests: the detection's truth table; on a pty, `list` and `scan` under an
agent's variable print without one escape sequence, `SOCKET_PLAIN=0`
brings the table back, and `remove` still asks its question; a source
scan that no terminal check outside `src/ui/` bypasses `ui::attended`.
The hermetic test environment drops the agent variables, so the pty
suites test the terminal output whoever runs them.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Ride out signals in the browser's key wait, and measure a get listing from its top
Two review comments.
- The browser waits 40 ms for the rest of an escape sequence before it
takes a lone Esc for the Esc key. A signal that cut that wait short was
read as the time having passed, so a terminal resized (or a child
exiting) in the middle of an arrow key turned its first byte into Esc
and closed the page: the false Esc the wait exists to prevent. The wait
is now taken up again for the time that is left.
- `get` asked for the measurements of the first 32 patches in the order
the search returned them, then listed the patches by package. A long
listing could show measurements on rows further down and none on the
first ones. The 32 are now the first in the order the listing shows.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Fix the findings of the pre-merge code review
list
- What a project records as a patch's uuid comes from its own files.
`list` on a terminal put it into the path of a request to the patch
service, with the user's token, whatever it was. Only a recorded uuid
that is a UUID is asked about now: any other keeps its row and opens
as the project's own record.
- The browser stays down under `SOCKET_DEBUG`, as the status line does:
the debug lines landed in the middle of its frames.
show
- A search the patch service failed for any reason was asked again of
the public service, whose "nothing for this package" then replaced the
real error. Only a refused token is, and the refusal stays the answer
when the public service has nothing.
- `--file` is checked before every form of output: a path the patch
does not change is `file_not_in_patch` under `--json` and `--silent`
too.
- Of several matching patches, with nobody to ask, the best ranked one
the account can read is shown: a paid patch ranked first no longer
fails the run when a free one is there.
- What the service says about a patch (description, license, advisory
summaries, file paths) is shown without its control characters.
- The page keeps the indentation of code (a tab runs to the next stop)
and shows wide characters, which it had blanked.
scan
- The read made ahead of a multi-directory scan asks the patch service
only what each directory's scan would: not about a package the policy
or a selection filter leaves out, a project the policy excludes, or a
package the project patches itself. What the project patches itself is
read once, with the crawl, and handed to the scan.
- All of a run's measurement requests share one window. Each round had
its own, and a scan of many directories starts a round for each.
- A lookup that fails still names the project directories below that
the run did not cover, as it did before the search for them moved
behind the lookup.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>1 parent d990d0b commit f62d1ca
66 files changed
Lines changed: 12557 additions & 1598 deletions
File tree
- crates
- socket-patch-cli
- src
- commands
- scan
- ui
- tests
- cli
- common
- get
- rollback
- scan
- vex
- socket-patch-core/src
- api
- crawlers
- formats/pnpm
- hosted/memory
- patch
- policy
- docs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | | - | |
314 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
315 | 317 | | |
316 | 318 | | |
317 | 319 | | |
318 | 320 | | |
319 | 321 | | |
320 | 322 | | |
321 | | - | |
322 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
323 | 330 | | |
324 | 331 | | |
325 | 332 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
336 | 346 | | |
337 | 347 | | |
338 | 348 | | |
| |||
1298 | 1308 | | |
1299 | 1309 | | |
1300 | 1310 | | |
1301 | | - | |
| 1311 | + | |
1302 | 1312 | | |
1303 | 1313 | | |
1304 | 1314 | | |
| |||
1309 | 1319 | | |
1310 | 1320 | | |
1311 | 1321 | | |
1312 | | - | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
1320 | 1328 | | |
1321 | 1329 | | |
1322 | 1330 | | |
| |||
1357 | 1365 | | |
1358 | 1366 | | |
1359 | 1367 | | |
1360 | | - | |
| 1368 | + | |
1361 | 1369 | | |
1362 | 1370 | | |
1363 | 1371 | | |
| |||
1414 | 1422 | | |
1415 | 1423 | | |
1416 | 1424 | | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
1427 | 1440 | | |
1428 | | - | |
| 1441 | + | |
1429 | 1442 | | |
1430 | 1443 | | |
1431 | 1444 | | |
| |||
1466 | 1479 | | |
1467 | 1480 | | |
1468 | 1481 | | |
1469 | | - | |
1470 | | - | |
1471 | | - | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
1472 | 1485 | | |
1473 | 1486 | | |
1474 | 1487 | | |
| |||
1542 | 1555 | | |
1543 | 1556 | | |
1544 | 1557 | | |
| 1558 | + | |
1545 | 1559 | | |
1546 | 1560 | | |
1547 | 1561 | | |
| |||
1552 | 1566 | | |
1553 | 1567 | | |
1554 | 1568 | | |
1555 | | - | |
1556 | | - | |
1557 | 1569 | | |
1558 | 1570 | | |
1559 | 1571 | | |
| |||
2302 | 2314 | | |
2303 | 2315 | | |
2304 | 2316 | | |
2305 | | - | |
2306 | | - | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
2307 | 2320 | | |
2308 | 2321 | | |
2309 | | - | |
| 2322 | + | |
2310 | 2323 | | |
2311 | 2324 | | |
2312 | 2325 | | |
2313 | 2326 | | |
2314 | 2327 | | |
2315 | 2328 | | |
2316 | | - | |
2317 | | - | |
2318 | | - | |
2319 | | - | |
2320 | 2329 | | |
2321 | 2330 | | |
2322 | 2331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1911 | 1911 | | |
1912 | 1912 | | |
1913 | 1913 | | |
1914 | | - | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
1915 | 1923 | | |
1916 | 1924 | | |
1917 | 1925 | | |
| |||
1926 | 1934 | | |
1927 | 1935 | | |
1928 | 1936 | | |
1929 | | - | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
1930 | 1947 | | |
1931 | 1948 | | |
1932 | 1949 | | |
| |||
2490 | 2507 | | |
2491 | 2508 | | |
2492 | 2509 | | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
2493 | 2539 | | |
2494 | 2540 | | |
2495 | 2541 | | |
| |||
4861 | 4907 | | |
4862 | 4908 | | |
4863 | 4909 | | |
| 4910 | + | |
| 4911 | + | |
| 4912 | + | |
| 4913 | + | |
| 4914 | + | |
| 4915 | + | |
| 4916 | + | |
| 4917 | + | |
| 4918 | + | |
| 4919 | + | |
| 4920 | + | |
| 4921 | + | |
| 4922 | + | |
| 4923 | + | |
| 4924 | + | |
| 4925 | + | |
| 4926 | + | |
| 4927 | + | |
| 4928 | + | |
| 4929 | + | |
| 4930 | + | |
| 4931 | + | |
| 4932 | + | |
| 4933 | + | |
| 4934 | + | |
| 4935 | + | |
| 4936 | + | |
4864 | 4937 | | |
4865 | 4938 | | |
4866 | 4939 | | |
| |||
0 commit comments