The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | const NEW_TASK_DRAFT_PREFIX = "new-task:"; |
| 2 | |
| 3 | export function newTaskDraftKey(draftId: string): string { |
| 4 | return `${NEW_TASK_DRAFT_PREFIX}${draftId}`; |
| 5 | } |
| 6 | |
| 7 | export function isNewTaskDraftKey(draftKey: string): boolean { |
| 8 | return draftKey.startsWith(NEW_TASK_DRAFT_PREFIX); |
| 9 | } |
| 10 | |
| 11 | export function restoredNewTaskDraftKey(messageId: string): string { |
| 12 | return newTaskDraftKey(`restored-${messageId}`); |
| 13 | } |
| 14 | |
| 15 | export function parseLegacyNewTaskDraftKey( |
| 16 | draftKey: string, |
| 17 | ): { readonly environmentId: string; readonly projectId: string } | null { |
| 18 | if (!isNewTaskDraftKey(draftKey)) { |
| 19 | return null; |
| 20 | } |
| 21 | const scope = draftKey.slice(NEW_TASK_DRAFT_PREFIX.length); |
| 22 | const separator = scope.lastIndexOf(":"); |
| 23 | if (separator <= 0 || separator === scope.length - 1) { |
| 24 | return null; |
| 25 | } |
| 26 | return { environmentId: scope.slice(0, separator), projectId: scope.slice(separator + 1) }; |
| 27 | } |