diff --git a/lib/api/routes/companion.js b/lib/api/routes/companion.js index 021702d..8ef9c02 100644 --- a/lib/api/routes/companion.js +++ b/lib/api/routes/companion.js @@ -43,7 +43,8 @@ spacesScopedRouter.get('/', asyncWrap(async (req, res) => { const turnSchema = z.object({ text: z.string().min(1), - view: z.object({ entityType: z.string(), entityId: z.string() }).partial().optional() + // nullish: the rail sends `view: null` when not on a specific entity. + view: z.object({ entityType: z.string(), entityId: z.string() }).partial().nullish() }); spacesScopedRouter.post('/turn', diff --git a/tests/api/companion.test.js b/tests/api/companion.test.js index d889b77..12f484f 100644 --- a/tests/api/companion.test.js +++ b/tests/api/companion.test.js @@ -45,7 +45,7 @@ describe('companion API', () => { it('POST /turn streams SSE events and persists messages', async () => { const res = await auth(request(app).post(`/api/spaces/${spaceId}/companion/turn`)) - .send({ text: 'make a task to validate the CSV' }); + .send({ text: 'make a task to validate the CSV', view: null }); // rail sends view:null expect(res.status).toBe(200); expect(res.headers['content-type']).toMatch(/text\/event-stream/);