mirror of
https://github.com/stablyai/orca.git
synced 2026-09-23 16:02:24 +00:00
Introduce optional `task-title` and `display-name` parameters for orchestration tasks, persisting them in the database and propagating them through the RPC and Orca runtime. This allows the CLI, dashboard, activity page, and sidebar to display concise, user-friendly labels for dispatched worker agents instead of verbose, raw system preambles.
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
buildOrchestrationTaskDisplayMetadata,
|
|
ORCHESTRATION_DISPLAY_NAME_MAX_LENGTH,
|
|
ORCHESTRATION_TASK_TITLE_MAX_LENGTH
|
|
} from './orchestration-task-display'
|
|
|
|
describe('buildOrchestrationTaskDisplayMetadata', () => {
|
|
it('uses explicit task title and display name when provided', () => {
|
|
expect(
|
|
buildOrchestrationTaskDisplayMetadata({
|
|
spec: 'Long implementation details',
|
|
taskTitle: 'Checkout race',
|
|
displayName: 'Fix checkout race'
|
|
})
|
|
).toEqual({
|
|
taskTitle: 'Checkout race',
|
|
displayName: 'Fix checkout race'
|
|
})
|
|
})
|
|
|
|
it('derives a task title from the first non-empty spec line', () => {
|
|
expect(
|
|
buildOrchestrationTaskDisplayMetadata({
|
|
spec: '\n\nFix login form\n\nAdd focused tests'
|
|
})
|
|
).toEqual({
|
|
taskTitle: 'Fix login form',
|
|
displayName: 'Fix login form'
|
|
})
|
|
})
|
|
|
|
it('normalizes and caps explicit task display fields', () => {
|
|
const metadata = buildOrchestrationTaskDisplayMetadata({
|
|
spec: 'fallback',
|
|
taskTitle: ` ${'x'.repeat(120)}\n`,
|
|
displayName: ` ${'y'.repeat(220)}\n`
|
|
})
|
|
|
|
expect(metadata.taskTitle).toHaveLength(ORCHESTRATION_TASK_TITLE_MAX_LENGTH)
|
|
expect(metadata.taskTitle.endsWith('...')).toBe(true)
|
|
expect(metadata.displayName).toHaveLength(ORCHESTRATION_DISPLAY_NAME_MAX_LENGTH)
|
|
expect(metadata.displayName.endsWith('...')).toBe(true)
|
|
})
|
|
|
|
it('does not leave a dangling high surrogate when truncating', () => {
|
|
const metadata = buildOrchestrationTaskDisplayMetadata({
|
|
spec: `x${'😀'.repeat(ORCHESTRATION_TASK_TITLE_MAX_LENGTH)}`
|
|
})
|
|
const last = metadata.taskTitle.charCodeAt(metadata.taskTitle.length - 1)
|
|
|
|
expect(metadata.taskTitle.length).toBeLessThanOrEqual(ORCHESTRATION_TASK_TITLE_MAX_LENGTH)
|
|
expect(last < 0xd800 || last > 0xdbff).toBe(true)
|
|
})
|
|
})
|