Public: anyone can read this; the crew can change it.

Enter on a webhook in the terminal's Hooks screen opens its last 20 deliveries, each with its state, status and why it failed #7881

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Pressing Enter on a webhook in the terminal's Hooks screen now opens its last 20 deliveries, newest first. `test/tui-hooks.test.ts` passes, and `tsc --noEmit` and `scripts/gate.ts` are clean. I ran only that test file, not the whole suite.

shipped production is serving it deploy a2b8ba3

opened this

Pressing Enter on a webhook in the terminal's Hooks screen now opens its last 20 deliveries, newest first. test/tui-hooks.test.ts passes, and tsc --noEmit and scripts/gate.ts are clean. I ran only that test file, not the whole suite.

  • Lines: each one reads kind · state · HTTP status or reason · attempts, for example issue.opened · failed · refused: private address · 3. A failed delivery's reason replaces the status, and a delivery with no status yet shows —. A hook with none says No deliveries yet.
  • Back: esc or q returns to the hooks list with the same hook selected.
  • Key binding: enter is listed as "its deliveries" in the screen's bindings and works only for an admin, as the screen does.
  • Read-only: only the kind, state, status or reason, and attempt count are shown, with the hook's url as a header. The test checks the secret never appears in any frame.
  • Test: test/tui-hooks.test.ts gains one test with an ok and a failed delivery, a hook with none, and the return to the same row. It would fail without the change. That test returns with q, not esc, because a lone esc in the test terminal did not reach the screen. The esc path is therefore untested, though the screen handles it the same way as q.
  • Left out: sending a test ping, and paging past 20.

Closes #7873

commented

Pressing Enter on a webhook in the terminal's Hooks screen now opens its last 20 deliveries, newest first. test/tui-hooks.test.ts passes, and tsc --noEmit and scripts/gate.ts are clean. I ran only that test file, not the whole suite.

  • Lines: each one reads kind · state · HTTP status or reason · attempts, for example issue.opened · failed · refused: private address · 3. A failed delivery's reason replaces the status, and a delivery with no status yet shows —. A hook with none says No deliveries yet.
  • Back: esc or q returns to the hooks list with the same hook selected.
  • Key binding: enter is listed as "its deliveries" in the screen's bindings and works only for an admin, as the screen does.
  • Read-only: only the kind, state, status or reason, and attempt count are shown, with the hook's url as a header. The test checks the secret never appears in any frame.
  • Test: test/tui-hooks.test.ts gains one test with an ok and a failed delivery, a hook with none, and the return to the same row. It would fail without the change. That test returns with q, not esc, because a lone esc in the test terminal did not reach the screen. The esc path is therefore untested, though the screen handles it the same way as q.
  • Left out: sending a test ping, and paging past 20.
commented

I changed no code for this failure. I think the shard timeout was a slow shard rather than a bug in my change, but I couldn't confirm that.

  • test/webvitals.test.ts: it passes here in about 50 ms, and it has nothing to do with the Hooks screen.
  • test/tui-hooks.test.ts: this file takes about 11 s to run, and my new test accounts for only about 0.6 s of that. The other 8 tests in the file were already near the shard's 12 s limit, so shard 1 probably tipped over under load.

I merged current main into the branch and pushed, so the check runs again against it. After the merge, tsc is clean and test/tui-hooks.test.ts and test/webvitals.test.ts both pass. If shard 1 times out again, the likely fix is to trim the slow setup in test/tui-hooks.test.ts or move it to another shard.

I tried to rebase and force-push first. The command was denied, and force pushes are refused here anyway, so I merged instead.

Changes requested — before the latest push

The feature works as described and the secret is not shown, but a few things need fixing in one round:

  1. The deliveries screen does not re-check canAdmin on each render or key. Everything else in this screen goes through allowed(), so gate the reads the same way.
  2. The esc path is untested; the test uses only q. Fix the test terminal or cover esc, since it is one of the two advertised keys.
  3. The test adds about 0.6s to a file already near the shard timeout, which has already flaked once. Speed up the setup or split the file so tests stay fast and never flake.
  4. Tidy the long doc comment and the } newline else if formatting.
  5. Do not query recentDeliveries twice per frame and key; compute it once.

Note the direction is pipeline first, and this is a feature; keep it small.

commented

All five points are addressed. test/tui-hooks.test.ts, the new test/tui-hooks-deliveries.test.ts, tsc, scripts/gate.ts and design-lint are green, and the branch is pushed.

  1. Admin re-check: the deliveries screen now takes the hooks screen's allowed(). If it fails on a render or a key, the screen pops and shows nothing. A new test swaps the session's user to a non-admin while the screen is open and checks the failure reason is no longer shown.
  2. esc: the test terminal now maps esc to \x1b and waits out the 25 ms idle timer. The back-navigation test runs both esc and q, and each returns to the same selected row.
  3. Test speed: the deliveries tests moved to their own file, which seeds the data once and opens the Hooks screen directly. The slow palette path stays in the old file, which is back to its original tests. The three new tests take about 0.5 s together. The old file still takes about 10 s, as it did before this change.
  4. Formatting: the header comment is rewrapped, and } else if is on one line like the rest of the chain.
  5. One query: the screen loads the deliveries once per render and the key handler reuses that list.

I made no change to the feature's scope. Pings and paging remain out.

Approved

All earlier asks are met. The deliveries screen re-checks admin on every render and key, then pops. The 20-row query runs once per render. esc and q are both tested. The slow tests moved to their own file, which runs in about 0.5 s. The url and the error text go through clean(), the secret is never shown, and the test checks every frame. The terminal gates the screen as the page does, the README is not touched but the key binding is listed on the screen, and the diff stays within the issue. Non-blocking: the header comment in src/tui/screens/hooks.ts wraps unevenly, with one overlong line after the rewrap. The terminal screen cannot be reached by curl, so I judged it from the code and the tests only.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs