fix: resolve chat prompt read-only state for subagent sessions
Allows prompting subagent sessions without needing the parent record Keeps subagents read-only when prompting is disabled Covers root and subagent cases with unit tests
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import type { Session } from '@opencode-ai/sdk/v2';
|
||||
|
||||
import { resolveChatPromptReadOnly } from './chatPromptReadOnly';
|
||||
|
||||
const session = (parentID?: string): Session => ({
|
||||
id: 'session',
|
||||
slug: 'session',
|
||||
title: 'Session',
|
||||
version: '1',
|
||||
projectID: 'project',
|
||||
directory: '/repo',
|
||||
parentID,
|
||||
time: { created: 1, updated: 1 },
|
||||
});
|
||||
|
||||
describe('resolveChatPromptReadOnly', () => {
|
||||
test('allows prompting a subagent without requiring its parent record', () => {
|
||||
expect(resolveChatPromptReadOnly(session('parent'), true, true)).toBe(false);
|
||||
});
|
||||
|
||||
test('keeps a subagent read-only when prompting is disabled', () => {
|
||||
expect(resolveChatPromptReadOnly(session('parent'), false, false)).toBe(true);
|
||||
});
|
||||
|
||||
test('preserves the surface read-only state for root sessions', () => {
|
||||
expect(resolveChatPromptReadOnly(session(), true, true)).toBe(true);
|
||||
expect(resolveChatPromptReadOnly(session(), true, false)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user