agent-ecosystem/src/main/services/team/inboxLock.ts
iliya a6eabc840c feat: enhance team message handling and UI components
- Updated `dev:kill` script to use a dedicated Node.js script for improved process termination.
- Enhanced `TeamProvisioningService` to trigger team refresh events for live lead replies, improving message handling.
- Refactored message deduplication logic in `handleGetData` to prevent duplicate messages from lead sessions and lead processes.
- Introduced `validateOpenPathUserSelected` function to allow user-selected paths while enforcing security checks.
- Improved UI components in `TeamListView` and `ActivityItem` for better user experience and accessibility.
- Added progress bar for task completion in `DashboardView`, enhancing task tracking visibility.
2026-02-23 17:34:30 +02:00

19 lines
524 B
TypeScript

const WRITE_LOCKS = new Map<string, Promise<void>>();
export async function withInboxLock<T>(inboxPath: string, fn: () => Promise<T>): Promise<T> {
const prev = WRITE_LOCKS.get(inboxPath) ?? Promise.resolve();
let release!: () => void;
const mine = new Promise<void>((resolve) => {
release = resolve;
});
WRITE_LOCKS.set(inboxPath, mine);
await prev;
try {
return await fn();
} finally {
release();
if (WRITE_LOCKS.get(inboxPath) === mine) {
WRITE_LOCKS.delete(inboxPath);
}
}
}