Files
waggle-os/packages/server/tests/local/default-workspace.test.ts
shumeiko.it e9ed8c0765 refactor(server): read workspace state, briefings and workspaces from the memory contract (P1.5)
- Workspace state, the "Workspace Now" block, the home briefing and the
  proactive handlers read the workspace's memory through server.memory:
  decisions are memories of kind 'decision', critical ones or ones worded
  as decisions; summaries list memories most important first. They no
  longer open workspace .mind files, so the builders are async and
  ProactiveContext carries `memory` instead of `getWorkspaceMindDb`.
- The home briefing counts extracted personal facts that are neither
  confirmed nor archived as awaiting review (memory-status.ts).
- Workspace routes count memories through the contract, seed template
  starter memories with remember() in the background (origin
  'workspace-template'), export memories through list(), and deleting a
  workspace forgets its memory scope and clears its awareness items before
  the directory is removed; the delete is refused if forgetting fails.
  agentState.releaseWorkspace() replaces closeWorkspaceMind for callers.
- The command palette searches personal memory and the active workspace's
  memory (UF-033).
- chat.ts drops the MindDB-flake diagnostics; the mind cache they guarded
  no longer serves chat turns.
2026-10-24 13:19:06 +02:00

42 lines
1.5 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import type { FastifyInstance } from 'fastify';
import { buildLocalServer } from '../../src/local/index.js';
describe('local server default workspace wiring', () => {
let tmpDir: string;
let server: FastifyInstance | null = null;
let previousEmbeddingProvider: string | undefined;
beforeEach(() => {
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-default-workspace-'));
previousEmbeddingProvider = process.env.EMBEDDING_PROVIDER;
process.env.EMBEDDING_PROVIDER = 'mock';
});
afterEach(async () => {
if (server) {
await server.close();
server = null;
}
if (previousEmbeddingProvider === undefined) {
delete process.env.EMBEDDING_PROVIDER;
} else {
process.env.EMBEDDING_PROVIDER = previousEmbeddingProvider;
}
fs.rmSync(tmpDir, { recursive: true, force: true });
});
it('activates the boot-created default workspace instead of the literal default id', async () => {
server = await buildLocalServer({ dataDir: tmpDir });
const defaultWorkspaceId = server.workspaceManager.getDefault();
expect(defaultWorkspaceId).toBeTruthy();
expect(server.agentState.activeWorkspaceId).toBe(defaultWorkspaceId);
expect(server.agentState.orchestrator.getWorkspaceId()).toBe(defaultWorkspaceId);
expect(server.workspaceManager.get('default')).toBeNull();
});
});