|
| 1 | +# Requests View Architecture |
| 2 | + |
| 3 | +This document is normative for the Studio Requests view. |
| 4 | + |
| 5 | +The Requests view is a database-session view that presents request-level observability data in the existing Studio shell. The first implementation uses deterministic dummy data, but its UI contract is shaped so real request, span, and log data can replace that source later without changing navigation. |
| 6 | + |
| 7 | +## Scope |
| 8 | + |
| 9 | +This architecture governs: |
| 10 | + |
| 11 | +- routing into `view=requests` |
| 12 | +- sidebar and command-palette entry points |
| 13 | +- request list ordering and summary columns |
| 14 | +- in-place request expansion |
| 15 | +- trace and log detail toggling |
| 16 | +- dummy request/span/log data shape |
| 17 | + |
| 18 | +## Canonical Components |
| 19 | + |
| 20 | +- [`ui/studio/Navigation.tsx`](../ui/studio/Navigation.tsx) |
| 21 | +- [`ui/studio/CommandPalette.tsx`](../ui/studio/CommandPalette.tsx) |
| 22 | +- [`ui/studio/Studio.tsx`](../ui/studio/Studio.tsx) |
| 23 | +- [`ui/studio/views/requests/RequestsView.tsx`](../ui/studio/views/requests/RequestsView.tsx) |
| 24 | +- [`ui/hooks/use-navigation.tsx`](../ui/hooks/use-navigation.tsx) |
| 25 | +- [`ui/hooks/use-ui-state.ts`](../ui/hooks/use-ui-state.ts) |
| 26 | + |
| 27 | +## Non-Negotiable Rules |
| 28 | + |
| 29 | +- Requests routing MUST use the existing URL-backed `view` param with the value `requests`. |
| 30 | +- The left navigation MUST render Requests in the Studio block immediately after Console and before SQL while database-backed Studio views are available. |
| 31 | +- The request list MUST render most recent requests first. |
| 32 | +- Summary rows MUST include timestamp, service, path, message, and duration. |
| 33 | +- Request expansion MUST happen in place under the clicked row instead of navigating away or opening a modal. |
| 34 | +- Expanded request state and the selected detail view MUST use `useUiState` with deterministic request-scoped keys. |
| 35 | +- Trace details MUST show proportional span durations for external requests and Prisma OpenTelemetry-style subsystem spans when dummy data includes them. |
| 36 | +- Log details MUST handle both string messages and structured object payloads without dropping the original structured object. |
| 37 | + |
| 38 | +## Dummy Data Contract |
| 39 | + |
| 40 | +Until Studio is wired to a real request source, dummy rows live in the Requests view module. Each request row MUST include: |
| 41 | + |
| 42 | +- a stable request id |
| 43 | +- timestamp |
| 44 | +- service |
| 45 | +- method and path |
| 46 | +- status |
| 47 | +- message |
| 48 | +- duration in milliseconds |
| 49 | +- trace id |
| 50 | +- zero or more trace spans |
| 51 | +- zero or more associated log lines |
| 52 | + |
| 53 | +Each span MUST include: |
| 54 | + |
| 55 | +- stable span id |
| 56 | +- display name |
| 57 | +- service |
| 58 | +- kind (`request`, `framework`, `external`, or `prisma`) |
| 59 | +- start offset in milliseconds |
| 60 | +- duration in milliseconds |
| 61 | +- nesting depth |
| 62 | +- status |
| 63 | + |
| 64 | +Each log line MUST include: |
| 65 | + |
| 66 | +- stable log id |
| 67 | +- timestamp |
| 68 | +- level |
| 69 | +- service |
| 70 | +- message as either a string or structured object |
| 71 | + |
| 72 | +## UI State Contract |
| 73 | + |
| 74 | +The expanded request id MUST be stored through `useUiState` using: |
| 75 | + |
| 76 | +- `requests:expanded-request` |
| 77 | + |
| 78 | +The active detail view for each expanded request MUST be stored through `useUiState` using: |
| 79 | + |
| 80 | +- `requests:${requestId}:detail-view` |
| 81 | + |
| 82 | +These keys keep request-detail interaction consistent with the existing Studio UI state architecture and avoid introducing component-local shared view state. |
| 83 | + |
| 84 | +## Forbidden Patterns |
| 85 | + |
| 86 | +- Do not introduce a second routing system for requests. |
| 87 | +- Do not store expanded request state in module globals. |
| 88 | +- Do not replace structured log objects with stringified summaries as the source data. |
| 89 | +- Do not open trace or log details in a modal or side panel for the default row click behavior. |
| 90 | + |
| 91 | +## Testing Requirements |
| 92 | + |
| 93 | +Requests view changes MUST include tests for: |
| 94 | + |
| 95 | +- `view=requests` routing in `Studio` |
| 96 | +- sidebar placement directly under Console |
| 97 | +- newest-first dummy request list rendering with the required summary columns |
| 98 | +- in-place row expansion |
| 99 | +- trace detail rendering for external and Prisma spans |
| 100 | +- log detail rendering for both string and structured object payloads |
0 commit comments