Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/client/components/chat-ui/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { Button } from "../ui/button"
import { Textarea } from "../ui/textarea"
import { ScrollArea } from "../ui/scroll-area"
import { cn } from "../../lib/utils"
import { cn, generateUUID } from "../../lib/utils"
import { useComposer } from "../../hooks/useComposer"
import { useIsStandalone } from "../../hooks/useIsStandalone"
import { useVoiceRecorder } from "../../hooks/useVoiceRecorder"
Expand Down Expand Up @@ -540,7 +540,10 @@ const ChatInputInner = forwardRef<ChatInputHandle, Props>(function ChatInput({
if (!file) break

activeUploadsRef.current += 1
const tempId = crypto.randomUUID()
// Not crypto.randomUUID(): that is secure-context only, so it is
// undefined when Kanna is opened over plain http on a LAN/Tailscale
// hostname, and every upload would throw before it started.
const tempId = generateUUID()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Fallback Lacks Regression Coverage

The fix now depends on generateUUID() when crypto.randomUUID is unavailable, but neither the upload flow nor the related transcript-jump flow has a regression test for that fallback. Add coverage with crypto.randomUUID absent so these plain-HTTP workflows cannot silently regress.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex

const previewUrl = file.type.startsWith("image/") ? URL.createObjectURL(file) : undefined
const generation = uploadGenerationRef.current

Expand Down
6 changes: 5 additions & 1 deletion src/client/lib/chat-navigation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { generateUUID } from "./utils"

/**
* The router-state contract for opening a chat *at a message*.
*
Expand Down Expand Up @@ -29,7 +31,9 @@ export interface ChatJumpLocationState {
}

export function buildChatJumpLocationState(role: ChatJumpRole): ChatJumpLocationState {
return { jumpToRole: role, jumpRequestId: crypto.randomUUID() }
// generateUUID, not crypto.randomUUID: the latter is secure-context only and
// is undefined over plain http on a LAN/Tailscale hostname.
return { jumpToRole: role, jumpRequestId: generateUUID() }
}

/** Reads the jump out of an opaque `useLocation().state`, or null if absent. */
Expand Down