fix(artifacts): render artifacts from the checked path and serve raw files once

- show_artifact returns the validated path as tool metadata; the chat card
  renders from it and maps repo paths with getWorkspaceFilePath, so local
  repos and moved sessions load the right file
- serve .htm as text/html
- raw file route stats and reads once and adds ETag/Last-Modified with 304
- reuse isPathWithinRoot from utils/fs-safe
- move readShowArtifactCall to frontend/src/lib/artifactTool
This commit is contained in:
Chris Scott committed 2026-10-12 16:43:04 -04:00
1 parent f7b2ffb865
commit 5e2452172c
26 files changed
+489 -58

No files matched your search

-14
View File
@@ -1,14 +0,0 @@
import type { SessionMessageAssistantTool } from '@opencode/client'
import { MANAGER_TOOL_NAME, MANAGER_TOOL_SHOW_ARTIFACT_ACTION, ShowArtifactParamsSchema } from '../schemas/internal-assistant'
import type { ShowArtifactParams } from '../schemas/internal-assistant'
/**
* Reads an assistant tool part as a completed `ocm` `show_artifact` call, or undefined for every
* other tool, action, unfinished state, and set of parameters that does not validate.
*/
export function readShowArtifactCall(part: SessionMessageAssistantTool): ShowArtifactParams | undefined {
if (part.name !== MANAGER_TOOL_NAME || part.state.status !== 'completed') return undefined
if (part.state.input.action !== MANAGER_TOOL_SHOW_ARTIFACT_ACTION) return undefined
const parsed = ShowArtifactParamsSchema.safeParse(part.state.input.params)
return parsed.success ? parsed.data : undefined
}
-2
View File
@@ -48,8 +48,6 @@ export { ClientError, isIntegrationNotFoundError, isMcpServerNotFoundError, isSe
export { assistantText, sessionIDFromEvent, toolContentText } from './content'
export { readShowArtifactCall } from './artifact'
export { configModelRef, formatOpenCodeModelRef, parseOpenCodeModelRef, selectConfiguredModelRef } from './modelRef'
export {