From d33c5260fdd4c58bb8e5843d330c2378db53f1ca Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Wed, 24 Jun 2026 00:24:26 -0700 Subject: [PATCH] fix: cap orchestration task link token length (#6246) --- .../terminal-pane/terminal-handle-links.test.ts | 9 +++++++++ .../terminal-pane/terminal-orchestration-task-links.ts | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/terminal-pane/terminal-handle-links.test.ts b/src/renderer/src/components/terminal-pane/terminal-handle-links.test.ts index b4d12bfb1..f76733d67 100644 --- a/src/renderer/src/components/terminal-pane/terminal-handle-links.test.ts +++ b/src/renderer/src/components/terminal-pane/terminal-handle-links.test.ts @@ -160,6 +160,15 @@ describe('extractOrchestrationTaskLinks', () => { { taskId: 'task_worker', startIndex: 5, endIndex: 16 } ]) }) + + it('caps orchestration task IDs by full token length', () => { + const maxLengthTaskId = `task_${'a'.repeat(123)}` + + expect(extractOrchestrationTaskLinks(`Open ${maxLengthTaskId}`)).toEqual([ + { taskId: maxLengthTaskId, startIndex: 5, endIndex: 133 } + ]) + expect(extractOrchestrationTaskLinks(`Open task_${'a'.repeat(124)}`)).toEqual([]) + }) }) describe('findTerminalHandleTarget', () => { diff --git a/src/renderer/src/components/terminal-pane/terminal-orchestration-task-links.ts b/src/renderer/src/components/terminal-pane/terminal-orchestration-task-links.ts index fdd90fb40..63b48c44e 100644 --- a/src/renderer/src/components/terminal-pane/terminal-orchestration-task-links.ts +++ b/src/renderer/src/components/terminal-pane/terminal-orchestration-task-links.ts @@ -8,7 +8,7 @@ export type ParsedOrchestrationTaskLink = { export const ORCHESTRATION_TASK_PREFIX = 'task_' -const MAX_ORCHESTRATION_TASK_BODY_LENGTH = 128 +const MAX_ORCHESTRATION_TASK_TOKEN_LENGTH = 128 const ORCHESTRATION_TASK_BOUNDARY_CHAR = /[A-Za-z0-9_-]/ export function extractOrchestrationTaskLinks(lineText: string): ParsedOrchestrationTaskLink[] { @@ -28,11 +28,14 @@ export function extractOrchestrationTaskLinks(lineText: string): ParsedOrchestra const tokenEnd = findOrchestrationTaskTokenEnd(lineText, bodyStart) searchStart = Math.max(tokenEnd, bodyStart + 1) const bodyLength = tokenEnd - bodyStart - if (bodyLength === 0 || bodyLength > MAX_ORCHESTRATION_TASK_BODY_LENGTH) { + if (bodyLength === 0) { continue } const taskId = lineText.slice(startIndex, tokenEnd) + if (taskId.length > MAX_ORCHESTRATION_TASK_TOKEN_LENGTH) { + continue + } if ( ORCHESTRATION_TASK_BOUNDARY_CHAR.test(lineText[startIndex - 1] ?? '') || ORCHESTRATION_TASK_BOUNDARY_CHAR.test(lineText[tokenEnd] ?? '')