Show the customer's terminal session on the support ticket page
React · React · intermediate · modification
Agents kept asking customers to paste their failing command into the reply, although the contact form already has a "What did you run?" box; the ticket page just never showed it. This shows it the way the docs site shows CLI sessions. `package.json` adds `prismjs` (pinned exactly like the rest of our dependencies, at 1.26.0, the version the docs site uses, so the shared token colours look the same), and `package-lock.json` gets its registry entry. `src/tickets/TerminalSession.jsx` (new) splits the session into lines, strips the `$ ` from command lines, passes the other line numbers to the Command Line plugin as `data-output`, writes the text into the `<code>` element and highlights it with `Prism.highlightElement`; it shows "No terminal session." when there is none. `src/tickets/TicketDetail.jsx` adds the section under the message. `src/tickets/TerminalSession.test.jsx` (new) renders a session with two commands and an error line, checking the text, the prompts and which lines get one, and renders a ticket without a session.
Support dashboard of DeployHub, an app-hosting platform: a React 18.3 single-page app built with Vite 5, function components, tests with Vitest 2, @testing-library/react 16 and jsdom (`npm test`). It is served from `support.deployhub.example`, the same origin as the support API, and agents sign in with a session cookie that the browser sends with every same-origin API request; the dashboard sends no Content-Security-Policy header. `TicketDetail` receives `ticket` from `GET /api/support/tickets/:id` (existing, unchanged). `ticket.terminalSession` is the contact-form field as stored: a string of 1 to 4000 characters, any characters (the form's textarea accepts anything), with line breaks stored as `\n` (the API turns `\r\n` into `\n`), or `null` when the customer left it blank (blank or whitespace-only input is stored as `null`); a ticket's fields never change after it is opened. This is the first use of Prism in the dashboard. The global stylesheet `src/styles.css` (existing, unchanged, imported once by the app) already has the docs site's colours for Prism's `.token` classes, plus `.muted` and `.note-text`. CI runs `npm ci` and `npm test` on every pull request; it has no dependency audit step. `package-lock.json` (lockfileVersion 3) is shown trimmed to its top-level fields, the root entry and the entry this PR adds; the other entries are unchanged and all resolve from `https://registry.npmjs.org/`.
Requirements
- The agent's ticket page (`TicketDetail`) gets a "Terminal session" section under "Message". It shows `ticket.terminalSession`, the text the customer pasted into the contact form's "What did you run?" box. A line that starts with `$ ` (dollar, space) is a command: it shows with a `$` prompt, without the typed `$ `, highlighted as bash. Every other line is output and shows as plain text, with no prompt. Every character the customer typed shows as itself. When the ticket has none (`null`), the section says "No terminal session."
- The session is written by the customer, and anyone with a free DeployHub account can open a ticket. Nothing a customer pastes may change the agent's page beyond showing as text, or act in the agent's session: support agents are signed in with sessions that can read any customer's project settings and environment variables and issue account credits.
- Highlighting uses PrismJS with its Command Line plugin, the same setup as the public docs site. Unchanged: the ticket heading, the customer line and the message. The new component has tests that run with the existing `npm test`.
Files touched
- package.json
- package-lock.json
- src/tickets/TicketDetail.jsx
- src/tickets/TerminalSession.jsx
- src/tickets/TerminalSession.test.jsx