feat(lanes): show Add Lane auto-setup summary before closing modal
The three setup calls (profile/agents/mcp) fired after worktree creation but their outcome was only logged to the console. Keep the modal open with a ✓/✗ summary for a few seconds (or until dismissed) so the user actually sees what happened, matching the original F5 design.
This commit is contained in:
@@ -58,6 +58,25 @@ export function AddLaneModal({
|
||||
setSetupResult(null);
|
||||
};
|
||||
|
||||
// The setup summary (below) is shown for a few seconds before the modal
|
||||
// auto-closes, so the user actually sees whether profile/agents/mcp
|
||||
// succeeded instead of the modal vanishing the instant the lane exists.
|
||||
const closeTimerRef = useRef<number | null>(null);
|
||||
const finishAndClose = useCallback(() => {
|
||||
if (closeTimerRef.current !== null) {
|
||||
window.clearTimeout(closeTimerRef.current);
|
||||
closeTimerRef.current = null;
|
||||
}
|
||||
reset();
|
||||
onClose();
|
||||
}, [onClose]);
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (closeTimerRef.current !== null) window.clearTimeout(closeTimerRef.current);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
// Look up the repo's branches once the path settles - debounced so every
|
||||
// keystroke while typing a path doesn't fire a request against a path that
|
||||
// isn't finished yet.
|
||||
@@ -128,9 +147,9 @@ export function AddLaneModal({
|
||||
});
|
||||
}
|
||||
|
||||
reset();
|
||||
setBusy(false);
|
||||
onAdded(result.lane);
|
||||
onClose();
|
||||
closeTimerRef.current = window.setTimeout(finishAndClose, 3000);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
setBusy(false);
|
||||
@@ -144,9 +163,8 @@ export function AddLaneModal({
|
||||
// into after the very first character. useCallback keeps the identity stable
|
||||
// across renders so only mount/unmount (and a real onClose change) refocuses.
|
||||
const handleCancel = useCallback(() => {
|
||||
reset();
|
||||
onClose();
|
||||
}, [onClose]);
|
||||
finishAndClose();
|
||||
}, [finishAndClose]);
|
||||
|
||||
return (
|
||||
<ConfirmModal
|
||||
@@ -156,7 +174,7 @@ export function AddLaneModal({
|
||||
cancelLabel={t("destructive.cancel")}
|
||||
destructive={false}
|
||||
busy={busy}
|
||||
disabled={!sourceRepo.trim() || !title.trim() || !branches}
|
||||
disabled={!!setupResult || !sourceRepo.trim() || !title.trim() || !branches}
|
||||
onConfirm={submit}
|
||||
onCancel={handleCancel}
|
||||
>
|
||||
@@ -214,6 +232,38 @@ export function AddLaneModal({
|
||||
<p className="text-[10px] text-status-warning">{branchesError}</p>
|
||||
)}
|
||||
|
||||
{setupResult && (
|
||||
<div className="rounded-md border border-border-light bg-surface-0 p-2 space-y-1">
|
||||
<p className="text-[10px] font-medium text-fg-secondary">{t("addLaneSetupTitle")}</p>
|
||||
{(
|
||||
[
|
||||
{
|
||||
label: t("addLaneSetupProfile"),
|
||||
ok: setupResult.profile !== "failed",
|
||||
skipped: setupResult.profile === "skipped",
|
||||
},
|
||||
{ label: t("addLaneSetupAgents"), ok: setupResult.agents === "ok" },
|
||||
{ label: t("addLaneSetupMcp"), ok: setupResult.mcp === "ok" },
|
||||
] as const
|
||||
).map((row) => (
|
||||
<p key={row.label} className="flex items-center gap-1.5 text-[11px] text-fg-primary">
|
||||
<span
|
||||
className={
|
||||
"skipped" in row && row.skipped
|
||||
? "text-fg-muted"
|
||||
: row.ok
|
||||
? "text-status-success"
|
||||
: "text-status-danger"
|
||||
}
|
||||
>
|
||||
{"skipped" in row && row.skipped ? "–" : row.ok ? "✓" : "✗"}
|
||||
</span>
|
||||
{row.label}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<p role="alert" className="text-xs text-status-danger">
|
||||
{error}
|
||||
|
||||
@@ -158,7 +158,8 @@ describe("AddLaneModal", () => {
|
||||
expect(onAdded).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ id: 9, status: "provisioning" })
|
||||
);
|
||||
expect(onClose).toHaveBeenCalled();
|
||||
// The setup summary stays on screen for a few seconds before auto-closing.
|
||||
await waitFor(() => expect(onClose).toHaveBeenCalled(), { timeout: 4000 });
|
||||
});
|
||||
|
||||
it("shows a server error and leaves the modal open instead of closing silently", async () => {
|
||||
@@ -228,6 +229,31 @@ describe("AddLaneModal", () => {
|
||||
await user.click(screen.getByRole("button", { name: "Add lane" }));
|
||||
|
||||
await waitFor(() => expect(onAdded).toHaveBeenCalled());
|
||||
await waitFor(() => expect(onClose).toHaveBeenCalled(), { timeout: 4000 });
|
||||
});
|
||||
|
||||
it("shows the setup summary and lets the user dismiss it early instead of waiting out the auto-close timer", async () => {
|
||||
vi.mocked(api.lanes.branches).mockResolvedValue({ branches: ["main"], current: "main" });
|
||||
vi.mocked(api.lanes.worktree).mockResolvedValue({
|
||||
lane: { id: 44, title: "demo3", cwd: "/lanes/demo3", status: "provisioning" } as Lane,
|
||||
});
|
||||
const onClose = vi.fn();
|
||||
renderModal({ onClose });
|
||||
const user = userEvent.setup();
|
||||
|
||||
const repoField = screen.getByLabelText("Source repository");
|
||||
await focusField(user, repoField);
|
||||
await user.type(repoField, "/Users/tester/projects/repo");
|
||||
await screen.findByLabelText("Branch to fork from");
|
||||
await user.type(screen.getByLabelText("Title"), "demo3");
|
||||
await user.click(screen.getByRole("button", { name: "Add lane" }));
|
||||
|
||||
expect(await screen.findByText("Setup")).toBeInTheDocument();
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
|
||||
const [dismissButton] = screen.getAllByRole("button", { name: "Cancel" });
|
||||
if (!dismissButton) throw new Error("Cancel button not found");
|
||||
await user.click(dismissButton);
|
||||
expect(onClose).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user