The best way to control Claude Code, Codex and more from any computer or phone
| 1 | // Count per draft so overlapping pastes cannot release each other and strand chips. |
| 2 | class PendingDraftWork { |
| 3 | private readonly counts = new Map<string, number>(); |
| 4 | |
| 5 | begin(draftKey: string): void { |
| 6 | this.counts.set(draftKey, (this.counts.get(draftKey) ?? 0) + 1); |
| 7 | } |
| 8 | |
| 9 | end(draftKey: string): void { |
| 10 | const remaining = (this.counts.get(draftKey) ?? 0) - 1; |
| 11 | if (remaining > 0) this.counts.set(draftKey, remaining); |
| 12 | else this.counts.delete(draftKey); |
| 13 | } |
| 14 | |
| 15 | has(draftKey: string): boolean { |
| 16 | return (this.counts.get(draftKey) ?? 0) > 0; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | // Keep claims across composer remounts. |
| 21 | export const pendingDraftWork = new PendingDraftWork(); |