An answer travels in a submit_answer tool call, and the model writes its line breaks there as the two characters \n. The console draws exactly what it is given, so a customer read \n\n where a paragraph break belonged. The layout escapes are now unfolded once, where model text enters: the answer, the Wish draft, the quick replies and the excerpts all pass one door. Answers stored before this change are unfolded as they are drawn, so the history reads correctly without touching the database.
40 lines
1.8 KiB
TypeScript
40 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { readdir, readFile } from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
|
|
// The console's bundler (Turbopack) cannot follow the NodeNext `.js` imports inside the contracts
|
|
// entry point, and that entry would carry zod and every schema into the browser. The console
|
|
// takes only types from it; values come from entries that import nothing.
|
|
async function sources(directory: string): Promise<string[]> {
|
|
const entries = await readdir(directory, { withFileTypes: true });
|
|
const nested = await Promise.all(
|
|
entries.map(entry => {
|
|
const location = path.join(directory, entry.name);
|
|
if (entry.isDirectory()) return sources(location);
|
|
return /\.tsx?$/.test(entry.name) ? [location] : [];
|
|
}),
|
|
);
|
|
return nested.flat();
|
|
}
|
|
|
|
describe('console bundle', () => {
|
|
it('imports only types from the contracts entry point', async () => {
|
|
const valueImports: string[] = [];
|
|
for (const file of await sources('apps/web/src')) {
|
|
const text = await readFile(file, 'utf8');
|
|
for (const match of text.matchAll(/^\s*(?:import|export)\s+(?!type\b)[^;]*?\bfrom\s+'@wishforge\/contracts'/gm))
|
|
valueImports.push(`${file}: ${match[0].trim()}`);
|
|
}
|
|
expect(valueImports).toEqual([]);
|
|
});
|
|
it('takes the provider catalog, release risk reasons, path rules, wish format, permissions, models and text from entries that import nothing', async () => {
|
|
const manifest = JSON.parse(await readFile('packages/contracts/package.json', 'utf8'));
|
|
for (const entry of ['providers', 'release-risk', 'path-rules', 'wish', 'permissions', 'models', 'text']) {
|
|
expect(manifest.exports[`./${entry}`]).toBe(`./src/${entry}.ts`);
|
|
expect(await readFile(`packages/contracts/src/${entry}.ts`, 'utf8')).not.toMatch(
|
|
/^\s*(?:import|export)\b.*\bfrom\s/m,
|
|
);
|
|
}
|
|
});
|
|
});
|