Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ function t(key: string, options?: Record<string, unknown>): string {
return template.replace(/{{(\w+)}}/g, (_, name) => String(options?.[name] ?? ''));
}

function writeStdinItem(result: unknown): FlowToolItem {
function writeStdinItem(
result: unknown,
input: Record<string, unknown> = {
session_id: 42,
chars: '',
},
): FlowToolItem {
return {
id: 'tool-writestdin-1',
type: 'tool',
Expand All @@ -34,10 +40,7 @@ function writeStdinItem(result: unknown): FlowToolItem {
timestamp: Date.now(),
toolCall: {
id: 'call-writestdin-1',
input: {
session_id: 42,
chars: '',
},
input,
},
toolResult: {
success: true,
Expand Down Expand Up @@ -65,6 +68,17 @@ function execControlItem(input: Record<string, unknown>, result: unknown): FlowT
}

describe('buildWriteStdinCardModel', () => {
it('does not display the appended enter after the input text', () => {
const model = buildWriteStdinCardModel(writeStdinItem({}, {
session_id: 42,
chars: 'yes',
append_enter: true,
}), t);

expect(model.primaryText).toBe('yes');
expect(model.copyText).toBe('yes');
});

it('surfaces session-not-found results as a completed notice', () => {
const model = buildWriteStdinCardModel(writeStdinItem({
status: 'session_not_found',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,10 @@ export function buildWriteStdinCardModel(
: result.sessionId;
const displaySessionId = sessionId ?? result.requestedSessionId;
const chars = typeof input.chars === 'string' ? input.chars : '';
const appendEnter = Boolean(input.append_enter);
const isPollOnly = chars.length === 0;
const primaryText = isPollOnly
? t('toolCards.execProcess.pollSession', { id: displaySessionId ?? '?' })
: appendEnter
? `${chars}\\n`
: chars;
: chars;
const resultNoticeText = result.status === 'session_not_found'
? t('toolCards.execProcess.sessionNotFound', {
id: displaySessionId ?? '?',
Expand Down
Loading