web: add memory document view

This commit is contained in:
2026-07-26 16:45:12 +09:00
parent a5d207821d
commit 3369dbd1eb
6 changed files with 236 additions and 14 deletions
@@ -191,17 +191,26 @@ Deno.test("workspace Tickets surface uses read-only Backend Ticket APIs", async
);
});
Deno.test("workspace Memory Staging surface uses read-only scoped memory API", async () => {
Deno.test("workspace Memory surfaces use read-only scoped memory APIs", async () => {
const memoryNav = await Deno.readTextFile(
new URL("../sidebar/MemoryNavSection.svelte", import.meta.url),
);
const memoryLoad = await Deno.readTextFile(
const memoryDocumentLoad = await Deno.readTextFile(
new URL("./../../../routes/w/[workspaceId]/memory/+page.ts", import.meta.url),
);
const memoryDocumentPage = await Deno.readTextFile(
new URL(
"./../../../routes/w/[workspaceId]/memory/+page.svelte",
import.meta.url,
),
);
const memoryStagingLoad = await Deno.readTextFile(
new URL(
"./../../../routes/w/[workspaceId]/memory/staging/+page.ts",
import.meta.url,
),
);
const memoryPage = await Deno.readTextFile(
const memoryStagingPage = await Deno.readTextFile(
new URL(
"./../../../routes/w/[workspaceId]/memory/staging/+page.svelte",
import.meta.url,
@@ -209,17 +218,28 @@ Deno.test("workspace Memory Staging surface uses read-only scoped memory API", a
);
assert(
memoryNav.includes("workspaceRoute(workspaceId, '/memory/staging')") &&
memoryNav.includes("workspaceRoute(workspaceId, '/memory')") &&
memoryNav.includes("durable workspace memory") &&
memoryNav.includes("workspaceRoute(workspaceId, '/memory/staging')") &&
memoryNav.includes("pending extraction candidates"),
"Memory sidebar section should link to the workspace Memory Staging surface",
"Memory sidebar section should link to Document and Staging surfaces",
);
assert(
memoryLoad.includes("workspaceApiPath(params.workspaceId") &&
memoryLoad.includes('"/memory/staging"') &&
memoryPage.includes("Memory Staging") &&
memoryPage.includes("Workspace Server memory authority") &&
memoryPage.includes("data.staging.data.invalid_count") &&
memoryPage.includes("entry.record.evidence"),
memoryDocumentLoad.includes("workspaceApiPath(params.workspaceId") &&
memoryDocumentLoad.includes('"/memory"') &&
memoryDocumentPage.includes("Memory Document") &&
memoryDocumentPage.includes("This view is read-only") &&
memoryDocumentPage.includes("data.memory.data.body_md") &&
memoryDocumentPage.includes("data.memory.data.updated_at"),
"Memory Document page should read the scoped API and expose the durable document without mutation controls",
);
assert(
memoryStagingLoad.includes("workspaceApiPath(params.workspaceId") &&
memoryStagingLoad.includes('"/memory/staging"') &&
memoryStagingPage.includes("Memory Staging") &&
memoryStagingPage.includes("Workspace Server memory authority") &&
memoryStagingPage.includes("data.staging.data.invalid_count") &&
memoryStagingPage.includes("entry.record.evidence"),
"Memory Staging page should read the scoped API and expose staged records without mutation controls",
);
});
@@ -7,6 +7,7 @@
};
let { currentPath = '/', workspaceId }: Props = $props();
let documentHref = $derived(workspaceId ? workspaceRoute(workspaceId, '/memory') : '/');
let stagingHref = $derived(workspaceId ? workspaceRoute(workspaceId, '/memory/staging') : '/');
</script>
@@ -15,6 +16,11 @@
<span>Memory</span>
</header>
<a class="objective-link" class:active={currentPath === documentHref} href={documentHref}>
<span class="item-title">Document</span>
<span class="item-meta">durable workspace memory</span>
</a>
<a class="objective-link" class:active={currentPath.startsWith(stagingHref)} href={stagingHref}>
<span class="item-title">Staging</span>
<span class="item-meta">pending extraction candidates</span>
@@ -318,6 +318,14 @@ export type RepositoryLogResponse = {
diagnostics: Diagnostic[];
};
export type MemoryDocumentResponse = {
body_md: string;
created_at: string;
updated_at: string;
bytes: number;
record_source: string;
};
export type MemoryCandidateKind =
| "preference"
| "working_assumption"
@@ -0,0 +1,123 @@
<script lang="ts">
import { formatDate } from '$lib/workspace/api/http';
import type { PageProps } from './$types';
let { data }: PageProps = $props();
const lineCount = $derived(data.memory.data?.body_md.split('\n').length ?? 0);
</script>
<svelte:head>
<title>Memory Document · Yoi Workspace</title>
<meta name="description" content="Workspace Memory Document" />
</svelte:head>
<section class="card memory-document-card">
<div class="detail-heading">
<div>
<p class="eyebrow">Workspace memory</p>
<h2>Memory Document</h2>
</div>
{#if data.memory.data}
<span>{data.memory.data.bytes} bytes</span>
{/if}
</div>
<p class="section-note">
Durable workspace Memory as a single Markdown document. This view is read-only.
</p>
{#if data.memory.data}
<div class="memory-document-summary" aria-label="Memory document summary">
<div>
<span>Updated</span>
<strong>{formatDate(data.memory.data.updated_at)}</strong>
</div>
<div>
<span>Created</span>
<strong>{formatDate(data.memory.data.created_at)}</strong>
</div>
<div>
<span>Lines</span>
<strong>{lineCount}</strong>
</div>
<div>
<span>Source</span>
<strong>{data.memory.data.record_source}</strong>
</div>
</div>
{#if data.memory.data.body_md.trim().length === 0}
<p>No Memory document content is present.</p>
{:else}
<pre class="memory-document-body">{data.memory.data.body_md}</pre>
{/if}
{:else if data.memory.error}
<p class="error">{data.memory.error}</p>
{:else}
<p>Waiting for <code>/api/w/{data.workspaceId}/memory</code></p>
{/if}
</section>
<style>
.memory-document-card {
overflow: hidden;
}
.memory-document-summary {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 0.75rem;
margin: 1rem 0;
}
.memory-document-summary div {
border: 1px solid var(--line);
border-radius: 0.75rem;
background: var(--bg-raised);
padding: 0.8rem;
}
.memory-document-summary span {
color: var(--text-muted);
display: block;
font-size: 0.76rem;
font-weight: 600;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.memory-document-summary strong {
color: var(--text);
display: block;
font-size: 0.95rem;
margin-top: 0.25rem;
overflow-wrap: anywhere;
}
.memory-document-body {
background: var(--bg-raised);
border: 1px solid var(--line);
border-radius: 0.9rem;
color: var(--text);
font-family: var(--font-mono);
font-size: 0.88rem;
line-height: 1.6;
margin: 1rem 0 0;
overflow: auto;
padding: 1rem;
white-space: pre-wrap;
}
@media (max-width: 900px) {
.memory-document-summary {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 640px) {
.memory-document-summary {
grid-template-columns: 1fr;
}
}
</style>
@@ -0,0 +1,13 @@
import { loadJson, workspaceApiPath } from "$lib/workspace/api/http";
import type { MemoryDocumentResponse } from "$lib/workspace/sidebar/types";
import type { PageLoad } from "./$types";
export const load: PageLoad = async ({ fetch, params }) => {
return {
workspaceId: params.workspaceId,
memory: await loadJson<MemoryDocumentResponse>(
fetch,
workspaceApiPath(params.workspaceId, "/memory"),
),
};
};