Restore custom Kapa chat with trigger-based support handoff - #466
Restore custom Kapa chat with trigger-based support handoff#466dannyneira wants to merge 48 commits into
Conversation
Adds an always-on Create ticket action in the Kapa chat UI, includes transcript context in submissions, and provides a preview/webhook backend endpoint for handoff testing. Co-Authored-By: Oz <oz-agent@warp.dev>
Set the handoff endpoint to non-prerendered so static/SSR build inputs resolve correctly in CI and Vercel. Co-Authored-By: Oz <oz-agent@warp.dev>
Move the custom handoff POST route to /kapa-handoff and remove the stale /api/kapa-handoff file to avoid CI/Vercel SSR rollup conflicts with the /api docs page. Co-Authored-By: Oz <oz-agent@warp.dev>
Co-authored-by: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
This reverts commit fd762df.
This reverts commit 93f73dd.
This reverts commit c805b22.
This reverts commit a6048d3.
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR restores the custom Kapa chat UI, adds a support handoff flow, updates Kapa-related environment configuration, and expands CSP allowances for the chat dependencies.
Concerns
- The new
/api/support-handoffroute is public and forwards ticket-creation payloads without server-side abuse protection. - The route falls back to a hard-coded external endpoint, so missing configuration can still send user email and chat transcript data to an implicit destination.
Security
- Public support ticket forwarding needs server-side bot/rate-limit protection or a validated challenge token before it is exposed.
- User support data should only be forwarded to an explicitly configured endpoint.
Verdict
Found: 0 critical, 2 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| return `https://app.kapa.ai/${kapaProjectId}/conversations/${kapaThreadId}`; | ||
| } | ||
|
|
||
| export const POST: APIRoute = async ({ request }) => { |
There was a problem hiding this comment.
|
|
||
| export const POST: APIRoute = async ({ request }) => { | ||
| const supportHandoffEndpointUrl = | ||
| SUPPORT_HANDOFF_ENDPOINT_URL || DEFAULT_SUPPORT_HANDOFF_ENDPOINT_URL; |
There was a problem hiding this comment.
SUPPORT_HANDOFF_ENDPOINT_URL will still forward user email and chat transcripts to that endpoint. Fail closed when the env var is absent so PII only leaves via an explicitly configured destination.
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Co-Authored-By: Warp Agent <agent@warp.dev>
Root cause: astro-expressive-code's Vite plugin rewrites Shiki's bundled theme registry (shiki/dist/themes.mjs) and strips every theme that is not listed as a string in the Expressive Code `themes` config. Starlight passes its themes as theme objects, so the registry was emptied to `bundledThemesInfo = []` across the whole Vite module graph. The Kapa side-chat island's runtime createHighlighter(['github-light', 'github-dark']) then threw "theme is not included in this bundle" and every chat code block fell back to plaintext. The same stripping also broke the earlier server-side /api/highlight-code approach. Fix: set `removeUnusedThemes: false` in the Expressive Code config so the registry ships intact. Theme data is still lazy-loaded, so only the two requested GitHub themes are ever fetched in the browser, and docs pages (build-time Expressive Code rendering) are unaffected. Co-Authored-By: Warp Agent <agent@warp.dev>
Two flicker sources in the Kapa side-chat markdown rendering: 1. Inline code rendered as full code blocks. react-markdown v9+ no longer passes the `inline` flag to the `code` component, so the existing `if (inline)` branch never ran and every inline code span (e.g. `.rpm`, `zypper`) rendered as a framed ChatCodeBlock with a copy button and horizontal scrollbar. During streaming these frames popped in and out of the prose, causing large layout shifts. Fenced blocks are always emitted as <pre><code>, so block handling now lives in the `pre` component and bare `code` renders as a plain inline chip (already styled by KapaChatLauncher.css). 2. Per-token highlight churn. The `deferHighlight` prop (true while the answer is streaming) was accepted but never honored, so every streamed token queued a Shiki highlight of the partial code and the block flipped between plaintext and (stale) highlighted DOM. The highlight effect now skips work entirely while `deferHighlight` is set and highlights the final text once when streaming settles. Highlighted HTML is also keyed to the exact code text + theme it was produced for, so stale markup is never rendered. Co-Authored-By: Warp Agent <agent@warp.dev>
Shiki's codeToHtml output separates each <span class="line"> with a
literal newline character, which the chat code block's
`white-space: pre` already renders as a line break. The extra
`.sl-kapa-codeblock code .line { display: block }` rule added a second
break per line, so every highlighted code block rendered with a blank
line between each line of code. Drop the rule and keep the line spans
inline.
Co-Authored-By: Warp Agent <agent@warp.dev>
Summary
Create tickethandoff in the custom UI (conversation length >= 3, downvote, uncertainty)mailto:handoff draft instead of relying on the prior server endpointPUBLIC_KAPA_PROJECT_IDenv supportValidation
Co-Authored-By: Warp Agent agent@warp.dev