Skip to content

feature(web/monitor): start session modal with pre-flight + 5-min confirmation#172

Open
jamby77 wants to merge 1 commit into
feature/monitor-web-sessions-listfrom
feature/monitor-web-start-session-modal
Open

feature(web/monitor): start session modal with pre-flight + 5-min confirmation#172
jamby77 wants to merge 1 commit into
feature/monitor-web-sessions-listfrom
feature/monitor-web-start-session-modal

Conversation

@jamby77
Copy link
Copy Markdown
Collaborator

@jamby77 jamby77 commented May 11, 2026

Summary

PR 9 of 25 in docs/plans/specs/monitor-command/plan-implementation.md. Stacked on top of #171 (PR 8). Lands the start-session modal with the full pre-flight context the spec describes: provider restrictions, ACL state with the exact ACL SETUSER snippet when +monitor is missing, the health-gate verdict, and a throughput / capture-size estimate.

  • New components (one-per-file convention):
    • pages/monitor/start-session-modal.tsx — form + lifecycle
    • pages/monitor/preflight-panel.tsx — 4-section read-only display
  • API client gains preflight() and startSession()
  • Monitor.tsx grows a Start session button in the header that opens the modal; on success, invalidates the sessions list query so the new row shows immediately rather than waiting for the next 5 s poll
  • Form fields:
    • Duration: integer + unit selector (seconds / minutes); minimum 1
    • Requested by: optional free-text, sent to the API and shown in the sessions table
  • 5-minute confirmation guard: if the chosen duration exceeds 5 min, the first Submit click swaps the panel to a yellow warning ("Sessions over 5 minutes can produce significant load. Confirm to proceed.") and changes the primary button to "Yes, start session". Second click fires the start.
  • Pre-flight refreshes whenever duration changes (so the size estimate stays accurate as the user adjusts), via useEffect with cancelled-flag cleanup.
  • State reset on close: duration / unit / requestedBy / preflight / confirming / error all clear when the modal closes, so reopening always shows defaults. Confirmation auto-clears when duration drops back below 5 min.

Test plan

  • pnpm --filter web exec tsc --noEmit → exit 0
  • No new lint errors in touched files
  • Run dev: MONITOR_DEV_PREVIEW=true pnpm dev:api and VITE_MONITOR_DEV_PREVIEW=true pnpm dev:web
  • Browser: click Start session → modal opens, pre-flight panel populates within ~1 s
  • All four pre-flight sections render: Provider (with restrictions list when applicable), ACL (badge + raw rules + remediation snippet when needed), Health gate (allow/skip badge + signals table), Throughput estimate (ops/sec, output KB/s, estimated lines + bytes)
  • Duration to 6 minutes → first Submit shows the amber confirmation panel with the exact spec wording; primary button becomes "Yes, start session"
  • Drop duration back to 30 s → confirmation panel clears automatically
  • Cancel → reopen → form is back to defaults (30 s, no requestedBy)
  • Submit a 3 s session with requestedBy:test → modal closes; row appears in the table within the 5 s poll window with that requestedBy value; status transitions running → completed
  • Drop the API dev preview gate → modal Submit returns 404; error appears in the modal red text

Notes for reviewers

  • Bug caught and fixed during live testing. The original useEffect(open) only cleared preflight / confirming / error on close; duration / unit / requestedBy carried over. A user who closed the modal at 6 min would still see 6 min when they reopened — and the unrelated state actually tripped the confirmation guard on what looked like a fresh open. Now everything resets on close.
  • Net diff: 425 lines. Slightly above the 400 target. Composition: modal 196 + preflight panel 134 + API client extensions 72 + Monitor.tsx wiring 24. Splitting modal vs panel would have left an orphan PR.
  • Web-side unit tests still deferred. The pure helpers (formatBytes, formatDuration, the percent / threshold formatters) are cheap to cover and should land alongside the live-tail UI in PR 10 as a small batch — flagged.
  • Screenshots saved to docs/assets/:
    • pr9-start-session-modal.png (initial pre-flight)
    • pr9-confirmation-dialog.png (5-min guard)

Stacked PR

Base branch is feature/monitor-web-sessions-list (#171), so the diff shown is ONLY PR 9 changes.

@jamby77 jamby77 force-pushed the feature/monitor-web-sessions-list branch from f1a2480 to 40cea3b Compare May 12, 2026 11:07
@jamby77 jamby77 force-pushed the feature/monitor-web-start-session-modal branch from ab6acde to 36dedbc Compare May 12, 2026 11:07
@jamby77 jamby77 force-pushed the feature/monitor-web-sessions-list branch from 40cea3b to b90faee Compare May 12, 2026 12:39
@jamby77 jamby77 closed this May 12, 2026
@jamby77 jamby77 force-pushed the feature/monitor-web-start-session-modal branch from 36dedbc to b90faee Compare May 12, 2026 12:39
@github-actions github-actions Bot locked and limited conversation to collaborators May 12, 2026
@jamby77 jamby77 reopened this May 13, 2026
@jamby77 jamby77 force-pushed the feature/monitor-web-sessions-list branch from 3486890 to d6a775f Compare May 13, 2026 12:34
…firmation

A modal launched from the Monitor page lets the operator start a capture
session with full pre-flight context: provider restrictions, ACL state
(with the exact ACL SETUSER snippet when +monitor is missing), the
health-gate verdict for the moment, and a throughput / capture-size
estimate based on current ops/sec × duration.

- New components (one-per-file convention):
  - pages/monitor/start-session-modal.tsx (form + lifecycle)
  - pages/monitor/preflight-panel.tsx (4-section read-only display)
- API client gains preflight() and startSession()
- Monitor.tsx grows a Start session button in the header that opens
  the modal; on success, invalidates the sessions list query so the
  new row shows immediately rather than waiting for the next 5s poll
- Form fields:
  - duration: integer + unit selector (seconds / minutes); minimum 1
  - requestedBy: optional free-text, sent to the API and shown in the
    sessions table
- 5-minute confirmation guard: if the chosen duration exceeds 5 min,
  the first Submit click swaps the panel to a yellow warning ("Sessions
  over 5 minutes can produce significant load. Confirm to proceed.")
  and changes the primary button to "Yes, start session". Second click
  fires the start.
- Pre-flight refreshes whenever the duration changes (so the size
  estimate stays accurate as the user adjusts), via a useEffect with
  cancelled-flag cleanup to avoid races.
- State reset on close: duration/unit/requestedBy/preflight/confirming/
  error all clear when the modal closes, so reopening always shows
  defaults. (Caught during live testing — a pre-fix run had carry-over
  state from a previous open.)
- Confirmation auto-clears when duration drops back below 5 minutes.

Verification (Playwright, live):
- Click Start session → modal opens, pre-flight panel populates within
  ~1s with provider 'self-hosted', ACL hasMonitor:true, health:healthy,
  estimated 3 lines / 144 B for the default 30s.
- Duration to 6 minutes → first Submit shows the amber confirmation
  panel with the exact spec wording; primary button becomes
  "Yes, start session".
- Reset to 3s + requestedBy=pr9-final → Submit → modal closes, new
  row appears in the table within the 5s poll window with the
  requestedBy value, status running → completed.
- Reopening the modal after Cancel shows defaults (30s, no
  requestedBy) — fixes a state-carry-over bug spotted during testing.

Screenshots:
- docs/assets/pr9-start-session-modal.png (initial pre-flight)
- docs/assets/pr9-confirmation-dialog.png (5-min guard)

Part of PR 9 of 25 in
docs/plans/specs/monitor-command/plan-implementation.md.
@jamby77 jamby77 force-pushed the feature/monitor-web-start-session-modal branch from 8aefbac to a86cd6b Compare May 13, 2026 12:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant