mirror of
https://github.com/stablyai/orca.git
synced 2026-10-12 16:03:03 +00:00
* feat(native-chat): visual directive grammar and host read for a chat's visuals folder
A shared grammar for the ::orca-visual{file="..." title="..."} reply line,
the per-chat visuals folder location on the owning host, and the
agentSession.readVisual runtime method that reads one visual with lexical and
canonical containment, a 512 KiB bounded read and UTF-8 refusal.
* feat(native-chat): render chat visuals inline and in the right sidebar
Native-chat assistant replies render a ::orca-visual{...} line as the chat's
HTML visual in an opaque, scripts-only sandboxed frame: CSP first, the host
frame navigation guard registered before content runs, live theme without a
reload, fitted height, links opened in the viewer's browser only from a real
gesture, lazy mount, and one muted line when the visual cannot be shown.
Open in sidebar shows the same frame in the right sidebar, widened while it
is open and restored after.
* fix(native-chat): visual CI fixes, shared height governor, live-turn streaming hold
Registers agentSession.readVisual from the methods index so the structured
method file stays under its line budget, replaces reflective reads with checked
narrowing, moves the pure height governor to src/shared for mobile, and holds a
half-written directive tail while the turn works (structured text rows carry no
running state).
* fix(native-chat): harden the visual read and link opening
Re-checks after the open that the chat's visuals folder is still the real
directory at Orca's path, reports unexpected filesystem faults by code without
host paths, and lets one click in a visual open at most one page.
* fix(native-chat): keep visual lines out of plain-text reply surfaces; review fixes
One shared helper drops visual lines (outside fenced code) from reply text where
it becomes plain text: the structured status summary that feeds the sidebar row,
dashboard, notifications, phone rows and handoffs, and AI Vault reply previews.
Review fixes: height also counts a pinned body's overflow, only the live
frontier row holds a half-written visual line, the runaway-height stop needs the
same step repeated, and any host refusal evicts the cached revision.
* fix(native-chat): resolve the visuals folder without the removed journal-paths helper
Main removed the per-chat journal paths and the journal database's state
directory; the visuals folder keeps the same sha256 layout on its own and the
read method uses the profile state directory the chat host is opened in.
* fix(native-chat): review round 2 fixes; copy a reply without its visual lines
Reply previews in Agent Session History drop visual lines per text part before
lines are folded; the frame adds a body's overflow only when the body really
overflows; fence tracking follows CommonMark closers and openers; the copy
button copies a reply without visual lines; a coded read fault keeps its cause.
* fix(native-chat): update the frame's theme ref after render; read the visuals folder pair at once
* test(native-chat): declare agentSession.readVisual on the cross-version agent-session surface
* fix(native-chat): copying a reply keeps its code blocks and indentation
Removing visual lines now closes only the gap each removal leaves, instead of
collapsing blank lines across the whole reply and trimming its indentation; the
visuals folder is checked parent first again so a broken path answers the same
way every time.
43 lines
2.0 KiB
TypeScript
43 lines
2.0 KiB
TypeScript
// `agentSession.readVisual` — one HTML visual from a chat's own visuals folder.
|
|
//
|
|
// Additive: an older host answers `method_not_found` (a phone gets `forbidden` from the mobile
|
|
// allowlist gate on a host without the entry), and the client shows the visual as unavailable.
|
|
// The host resolves the folder from its own state directory and record; a client supplies only the
|
|
// session id and a bare file name.
|
|
|
|
import { LOCAL_EXECUTION_HOST_ID } from '../../../../shared/execution-host'
|
|
import {
|
|
ReadVisualParams,
|
|
type AgentSessionReadVisualResult
|
|
} from '../../../../shared/rpc-contract/agent-session-visual-params'
|
|
import { nativeChatVisualsFolderFor } from '../../../native-chat/native-chat-visuals-folder'
|
|
import { getProfileUserDataPath } from '../../../orca-profiles/profile-storage-paths'
|
|
import { readNativeChatVisualFile } from '../../../native-chat/native-chat-visual-file-read'
|
|
import { defineMethod } from '../core'
|
|
import { requireInstalledStructuredHost } from './structured-agent-session-gate'
|
|
|
|
export const STRUCTURED_AGENT_SESSION_VISUAL_METHODS = [
|
|
defineMethod({
|
|
name: 'agentSession.readVisual',
|
|
params: ReadVisualParams,
|
|
handler: async (params, ctx): Promise<AgentSessionReadVisualResult> => {
|
|
const host = await requireInstalledStructuredHost(ctx)
|
|
const record = host.deps.store.getRecord(params.sessionId)
|
|
if (!record) {
|
|
return { ok: false, error: 'session_not_found' }
|
|
}
|
|
// Structured chats run on their owning runtime's own filesystem; any other location has no
|
|
// visuals folder this process can read.
|
|
if (
|
|
record.location.executionHostId !== LOCAL_EXECUTION_HOST_ID ||
|
|
record.location.wslDistro
|
|
) {
|
|
return { ok: false, error: 'unsupported_location' }
|
|
}
|
|
// The same state directory the chat host and its journal are opened in on this process.
|
|
const folder = nativeChatVisualsFolderFor(getProfileUserDataPath(), params.sessionId)
|
|
return readNativeChatVisualFile(folder, params.file, params.knownRevision)
|
|
}
|
|
})
|
|
]
|