Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: serialize inbox card and pull request actions through one lock

[._.]/ Adam Eivydea68b50b229
diff --git a/client/src/components/github/GitHubNotificationCard.jsx b/client/src/components/github/GitHubNotificationCard.jsx
index 7191a960c3..dc0cb036b7 100644
--- a/client/src/components/github/GitHubNotificationCard.jsx
+++ b/client/src/components/github/GitHubNotificationCard.jsx
@@ -116,18 +116,23 @@ export default function GitHubNotificationCard({ notification: sourceNotificatio
setLocalUpdate({ source: sourceNotification, notification: updated });
onUpdated?.(row, updated);
};
- const onAction = async (row, action, run) => {
- if (disabled || inFlight.current) return false;
+ const runMutation = async work => {
+ if (disabled || inFlight.current) return null;
inFlight.current = true;
setPending(true);
+ try { return await work(); }
+ finally {
+ inFlight.current = false;
+ setPending(false);
+ }
+ };
+ const onAction = (row, action, run) => runMutation(async () => {
const updated = await (action === 'agent'
? resolveGitHubNotificationWithAgent(row.accountId, row.threadId, run)
: applyGitHubNotificationAction(row.accountId, row.threadId, action)).catch(() => null);
- inFlight.current = false;
- setPending(false);
if (updated) applyUpdate(row, updated);
return Boolean(updated);
- };
+ });
const [reviewing, setReviewing] = useState(false);
const [picking, setPicking] = useState(false);
const handled = notification.state !== 'open';
@@ -237,7 +242,8 @@ export default function GitHubNotificationCard({ notification: sourceNotificatio
<Rocket size={13} aria-hidden="true" /> Review deployment
</button>
)}
- {notification.pullRequest && <GitHubPullRequestActions notification={notification} onUpdated={applyUpdate} />}
+ {notification.pullRequest && <GitHubPullRequestActions notification={notification} onUpdated={applyUpdate}
+ busy={busy} runMutation={runMutation} />}
{agent && !picking && !notification.pullRequest && (
<button
type="button"
diff --git a/client/src/components/github/GitHubPullRequestActions.jsx b/client/src/components/github/GitHubPullRequestActions.jsx
index 6996edbb2b..9e014cf6b4 100644
--- a/client/src/components/github/GitHubPullRequestActions.jsx
+++ b/client/src/components/github/GitHubPullRequestActions.jsx
@@ -1,4 +1,4 @@
-import { useId, useRef, useState } from 'react';
+import { useId, useState } from 'react';
import { Link } from 'react-router';
import { MergeAction, PullRequestReviewButton, DEFAULT_MERGE_METHOD, ACTION_STATUS_LABEL, actionStatusForTask } from '../apps/tabs/PullRequestActionControls';
import GitHubAgentPinForm from './GitHubAgentPinForm';
@@ -6,9 +6,8 @@ import { actOnGitHubNotificationPullRequest } from '../../services/api';
import toast from '../ui/Toast';
import { useCosTaskUpdates } from '../../hooks/useCosTaskUpdates';
-export default function GitHubPullRequestActions({ notification, onUpdated }) {
+export default function GitHubPullRequestActions({ notification, onUpdated, busy: disabled = false, runMutation }) {
const id = useId();
- const inFlight = useRef(false);
const [busy, setBusy] = useState(null);
const [armed, setArmed] = useState(false);
const [method, setMethod] = useState(DEFAULT_MERGE_METHOD);
@@ -29,25 +28,22 @@ export default function GitHubPullRequestActions({ notification, onUpdated }) {
status: task.metadata?.preflightFailure ? 'failed' : task.metadata?.preflightResultTaskId ? 'active' : actionStatusForTask(task.status) });
});
- const execute = async (action, pin = {}) => {
- if (inFlight.current) return;
- inFlight.current = true;
+ const execute = (action, pin = {}) => runMutation(async () => {
setBusy(action);
setError('');
const result = await actOnGitHubNotificationPullRequest(notification.accountId, notification.threadId, {
action, ...(action === 'merge' ? { method, deleteBranch } : pin),
}, { silent: true }).catch(err => { setError(err.message || 'The PR action failed'); return null; });
- inFlight.current = false;
setBusy(null);
if (!result) return;
setArmed(false);
setReviewAction(null);
onUpdated(notification, result.notification);
toast.success(result.merged ? `Merged PR #${pr.number}` : result.duplicate ? 'A review is already queued' : result.started ? 'Review started' : 'Review queued');
- };
+ });
return (
- <div className="flex max-w-full min-w-0 flex-wrap items-center gap-1.5">
+ <fieldset disabled={disabled} className="flex max-w-full min-w-0 flex-wrap items-center gap-1.5">
{current && !current.merged && (
current.taskId ? <Link className="text-xs text-port-accent hover:underline" to={`/cos/tasks?task=${encodeURIComponent(current.taskId)}&source=${current.action === 'do-review' ? 'user' : 'internal'}`}>Review: {ACTION_STATUS_LABEL[current.status] || 'View task'}</Link>
: current.appId ? <Link className="text-xs text-port-accent hover:underline" to={`/apps/${encodeURIComponent(current.appId)}/pull-requests`}>Review requested — view PRs</Link> : null
@@ -64,6 +60,6 @@ export default function GitHubPullRequestActions({ notification, onUpdated }) {
busy={Boolean(busy)} onSubmit={pin => execute(reviewAction, pin)} onCancel={() => setReviewAction(null)} />}
{error && <p role="alert" className="w-full break-words text-xs text-port-error">{error}</p>}
{!error && notification.pullRequestAttempt?.reason === 'GITHUB_PR_NOT_READY' && <p className="w-full text-xs text-gray-400">Auto-merge is waiting for passing checks and merge readiness.</p>}
- </div>
+ </fieldset>
);
}
diff --git a/client/src/pages/GitHub.test.jsx b/client/src/pages/GitHub.test.jsx
index 9bc1e3f189..37f400fa00 100644
--- a/client/src/pages/GitHub.test.jsx
+++ b/client/src/pages/GitHub.test.jsx
@@ -504,6 +504,44 @@ describe('GitHub inbox tab', () => {
expect(screen.getByRole('button', { name: 'Merge #7' })).toBeTruthy();
});
+ it('holds notification actions while a PR merge is pending', async () => {
+ const notification = { ...NOTIFICATION, pullRequest: { number: 7, mergeEligible: true } };
+ mock.getGitHubNotifications.mockResolvedValue({ notifications: [notification], sync: {} });
+ let finishMerge;
+ mock.actOnGitHubNotificationPullRequest.mockImplementationOnce(() => new Promise(resolve => { finishMerge = resolve; }));
+ await renderInbox();
+ fireEvent.click(screen.getByRole('button', { name: 'Merge' }));
+ act(() => {
+ fireEvent.click(screen.getByRole('button', { name: 'Merge #7' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Done' }));
+ });
+ try {
+ expect(screen.getByRole('button', { name: 'Done' })).toBeDisabled();
+ expect(mock.applyGitHubNotificationAction).not.toHaveBeenCalled();
+ } finally {
+ await act(async () => { finishMerge({ merged: true, notification: { ...notification, pullRequest: null } }); });
+ }
+ });
+
+ it('holds an armed PR merge while a notification action is pending', async () => {
+ const notification = { ...NOTIFICATION, pullRequest: { number: 7, mergeEligible: true } };
+ mock.getGitHubNotifications.mockResolvedValue({ notifications: [notification], sync: {} });
+ let finishDone;
+ mock.applyGitHubNotificationAction.mockImplementationOnce(() => new Promise(resolve => { finishDone = resolve; }));
+ await renderInbox();
+ fireEvent.click(screen.getByRole('button', { name: 'Merge' }));
+ act(() => {
+ fireEvent.click(screen.getByRole('button', { name: 'Done' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Merge #7' }));
+ });
+ try {
+ expect(screen.getByRole('button', { name: 'Merge #7' })).toBeDisabled();
+ expect(mock.actOnGitHubNotificationPullRequest).not.toHaveBeenCalled();
+ } finally {
+ await act(async () => { finishDone({ ...notification, state: 'done' }); });
+ }
+ });
+
it('links reviews to their owning task queues through completion and preflight handoff', async () => {
mock.getGitHubNotifications.mockResolvedValue({ notifications: [
{ ...NOTIFICATION, pullRequest: { number: 7, doReviewEligible: true },