fix(web): distinguish empty resident context
This commit is contained in:
@@ -47,6 +47,13 @@
|
|||||||
return 'Generation failed';
|
return 'Generation failed';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function surfaceSummary(availability: SubjektivResidentSurfaceAvailability): string {
|
||||||
|
if (availability !== 'ready') return 'No current generated context is available to use.';
|
||||||
|
return snapshot?.body_md.trim()
|
||||||
|
? 'Current generated context is available.'
|
||||||
|
: 'A current empty surface exists; there is no resident context to show.';
|
||||||
|
}
|
||||||
|
|
||||||
function subjectStateLabel(state: 'active' | 'retired'): string {
|
function subjectStateLabel(state: 'active' | 'retired'): string {
|
||||||
return state === 'active' ? 'Available' : 'Retired';
|
return state === 'active' ? 'Available' : 'Retired';
|
||||||
}
|
}
|
||||||
@@ -95,7 +102,7 @@
|
|||||||
<span>Resident context</span>
|
<span>Resident context</span>
|
||||||
{#if surface}
|
{#if surface}
|
||||||
<strong class="availability is-{surface.availability}">{surfaceLabel(surface.availability)}</strong>
|
<strong class="availability is-{surface.availability}">{surfaceLabel(surface.availability)}</strong>
|
||||||
<p>{surface.availability === 'ready' ? 'Current generated context is available.' : 'No current generated context is available to use.'}</p>
|
<p>{surfaceSummary(surface.availability)}</p>
|
||||||
{:else}
|
{:else}
|
||||||
<strong>Unavailable</strong>
|
<strong>Unavailable</strong>
|
||||||
<p>The resident context status could not be read.</p>
|
<p>The resident context status could not be read.</p>
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
// @vitest-environment happy-dom
|
// @vitest-environment happy-dom
|
||||||
|
|
||||||
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/svelte";
|
import {
|
||||||
|
cleanup,
|
||||||
|
fireEvent,
|
||||||
|
render,
|
||||||
|
screen,
|
||||||
|
waitFor,
|
||||||
|
} from "@testing-library/svelte";
|
||||||
import { afterEach, expect, test, vi } from "vitest";
|
import { afterEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
const { gotoMock } = vi.hoisted(() => ({
|
const { gotoMock } = vi.hoisted(() => ({
|
||||||
@@ -181,7 +187,9 @@ test("preserves invalid and rejected role drafts with accessible errors", async
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("warns about an unknown create outcome without replaying the POST", async () => {
|
test("warns about an unknown create outcome without replaying the POST", async () => {
|
||||||
const fetchMock = vi.fn(() => Promise.reject(new TypeError("connection reset")));
|
const fetchMock = vi.fn(() =>
|
||||||
|
Promise.reject(new TypeError("connection reset"))
|
||||||
|
);
|
||||||
vi.stubGlobal("fetch", fetchMock);
|
vi.stubGlobal("fetch", fetchMock);
|
||||||
render(SubjectIndexPage, { data: subjectIndexData() } as never);
|
render(SubjectIndexPage, { data: subjectIndexData() } as never);
|
||||||
|
|
||||||
@@ -218,7 +226,8 @@ test("renders a ready resident surface and committed Memory lifecycle states", a
|
|||||||
availability: "ready" as const,
|
availability: "ready" as const,
|
||||||
snapshot: {
|
snapshot: {
|
||||||
snapshot_id: "snapshot-1",
|
snapshot_id: "snapshot-1",
|
||||||
body_md: "# Resident context\n\nUse the **current** committed record.",
|
body_md:
|
||||||
|
"# Resident context\n\nUse the **current** committed record.",
|
||||||
memory_refs: [{ memory_id: "memory-1", revision: 3 }],
|
memory_refs: [{ memory_id: "memory-1", revision: 3 }],
|
||||||
built_from_store_revision: 9,
|
built_from_store_revision: 9,
|
||||||
created_at: "2026-01-02T03:04:05Z",
|
created_at: "2026-01-02T03:04:05Z",
|
||||||
@@ -308,6 +317,7 @@ test("distinguishes ready-empty, stale, failed, unavailable, and request error s
|
|||||||
} as never);
|
} as never);
|
||||||
expect(screen.getByText("Resident context is current but empty.")).not
|
expect(screen.getByText("Resident context is current but empty.")).not
|
||||||
.toBeNull();
|
.toBeNull();
|
||||||
|
expect(screen.getByText(/current empty surface exists/)).not.toBeNull();
|
||||||
expect(screen.getByText("No committed Memories yet.")).not.toBeNull();
|
expect(screen.getByText("No committed Memories yet.")).not.toBeNull();
|
||||||
|
|
||||||
await view.rerender(
|
await view.rerender(
|
||||||
|
|||||||
Reference in New Issue
Block a user