- Added agent-teams-controller as a dependency and updated the bundling configuration to exclude it. - Refactored task management functions to utilize the new taskStore, improving code organization and maintainability. - Introduced new methods for handling task states, including soft deletion and restoration. - Enhanced kanban functionality with improved reviewer management and task column updates. - Updated tests to reflect changes in task creation and approval processes, ensuring robust coverage. - Improved task ID handling and display logic for better user experience across components.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import type { TeamTask } from '@shared/types';
|
|
|
|
const UUID_TASK_ID_PATTERN =
|
|
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
|
|
export function looksLikeCanonicalTaskId(taskId: string): boolean {
|
|
return UUID_TASK_ID_PATTERN.test(taskId.trim());
|
|
}
|
|
|
|
export function deriveTaskDisplayId(taskId: string): string {
|
|
const normalized = taskId.trim();
|
|
if (!normalized) return normalized;
|
|
return looksLikeCanonicalTaskId(normalized) ? normalized.slice(0, 8).toLowerCase() : normalized;
|
|
}
|
|
|
|
export function getTaskDisplayId(task: Pick<TeamTask, 'id' | 'displayId'>): string {
|
|
return task.displayId?.trim() || deriveTaskDisplayId(task.id);
|
|
}
|
|
|
|
export function formatTaskDisplayLabel(task: Pick<TeamTask, 'id' | 'displayId'>): string {
|
|
return `#${getTaskDisplayId(task)}`;
|
|
}
|
|
|
|
export function taskMatchesRef(
|
|
task: Pick<TeamTask, 'id' | 'displayId'>,
|
|
ref: string | null | undefined
|
|
): boolean {
|
|
if (!ref) return false;
|
|
const normalized = ref.trim();
|
|
if (!normalized) return false;
|
|
return task.id === normalized || getTaskDisplayId(task) === normalized;
|
|
}
|