- 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.
19 lines
524 B
TypeScript
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);
|
|
}
|
|
}
|
|
}
|