Skip to content

Commit 904549a

Browse files
fix: improve reload toast UX and non-blocking reload (anomalyco#229)
* fix: improve reload toast UX and allow forcing reload during active runs * fix: redesign reload toast to be less modal-like and warn about active tasks * fix: move reload toast to top-center * chore: refresh tauri Cargo.lock
1 parent 9cea5b6 commit 904549a

5 files changed

Lines changed: 67 additions & 52 deletions

File tree

‎packages/app/src/app/app.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,6 +2351,7 @@ export default function App() {
23512351
dismissLabel={t("reload.toast_dismiss", currentLocale())}
23522352
busy={reloadBusy()}
23532353
canReload={canReloadEngine()}
2354+
hasActiveRuns={anyActiveRuns()}
23542355
onReload={() => reloadWorkspaceEngine()}
23552356
onDismiss={() => setReloadToastDismissedAt(Date.now())}
23562357
/>

‎packages/app/src/app/components/reload-workspace-toast.tsx‎

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,79 @@
11
import { Show } from "solid-js";
2-
import { AlertTriangle, RefreshCcw } from "lucide-solid";
2+
import { AlertTriangle, RefreshCcw, X } from "lucide-solid";
33

44
import Button from "./button";
55

66
export type ReloadWorkspaceToastProps = {
77
open: boolean;
88
title: string;
99
description: string;
10-
warning: string;
10+
warning?: string;
1111
blockedReason?: string | null;
1212
error?: string | null;
1313
reloadLabel: string;
1414
dismissLabel: string;
1515
busy?: boolean;
1616
canReload: boolean;
17+
hasActiveRuns: boolean;
1718
onReload: () => void;
1819
onDismiss: () => void;
1920
};
2021

2122
export default function ReloadWorkspaceToast(props: ReloadWorkspaceToastProps) {
2223
return (
2324
<Show when={props.open}>
24-
<div class="fixed top-6 right-6 z-50 w-[min(420px,calc(100vw-2rem))]">
25-
<div class="rounded-2xl border border-gray-6/70 bg-gray-1/95 p-4 shadow-xl backdrop-blur animate-in fade-in slide-in-from-top-11 duration-200">
26-
<div class="flex items-start gap-3">
27-
<div class="mt-0.5 flex h-9 w-9 items-center justify-center rounded-full border border-amber-7/30 bg-amber-7/10 text-amber-11">
28-
<RefreshCcw size={16} />
29-
</div>
30-
<div class="flex-1 space-y-2">
31-
<div>
32-
<div class="text-sm font-semibold text-gray-12">{props.title}</div>
33-
<div class="text-xs text-gray-10">{props.description}</div>
34-
</div>
35-
<div class="text-xs text-gray-10">{props.warning}</div>
36-
<Show when={props.blockedReason}>
37-
<div class="flex items-start gap-2 rounded-lg border border-amber-7/30 bg-amber-7/10 px-3 py-2 text-xs text-amber-11">
38-
<AlertTriangle size={14} class="mt-0.5 shrink-0" />
39-
<span>{props.blockedReason}</span>
40-
</div>
41-
</Show>
42-
<Show when={props.error}>
43-
<div class="rounded-lg border border-red-7/30 bg-red-7/10 px-3 py-2 text-xs text-red-11">
44-
{props.error}
45-
</div>
25+
<div class="fixed top-6 left-1/2 -translate-x-1/2 z-50 w-[min(480px,calc(100vw-2rem))]">
26+
<div
27+
class="
28+
flex items-center gap-3 p-2 pr-3 rounded-full
29+
border border-gray-6/50 bg-gray-2/95 shadow-xl backdrop-blur-md
30+
animate-in fade-in slide-in-from-top-4 duration-300
31+
"
32+
>
33+
{/* Icon Circle */}
34+
<div class={`
35+
flex h-9 w-9 shrink-0 items-center justify-center rounded-full
36+
${props.hasActiveRuns ? 'bg-amber-3 text-amber-11' : 'bg-blue-3 text-blue-11'}
37+
`}>
38+
<RefreshCcw size={16} class={props.busy ? "animate-spin" : ""} />
39+
</div>
40+
41+
{/* Text Content */}
42+
<div class="flex-1 min-w-0 flex flex-col justify-center">
43+
<div class="flex items-center gap-2">
44+
<span class="text-sm font-medium text-gray-12 truncate">
45+
{props.title}
46+
</span>
47+
<Show when={props.hasActiveRuns}>
48+
<span class="inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider bg-amber-4 text-amber-11">
49+
Active Tasks
50+
</span>
4651
</Show>
4752
</div>
53+
54+
<Show when={props.description}>
55+
<div class="text-xs text-gray-10 truncate leading-none mt-0.5">
56+
{props.hasActiveRuns
57+
? <span class="text-amber-11 font-medium">Reloading will stop active tasks.</span>
58+
: props.description
59+
}
60+
</div>
61+
</Show>
4862
</div>
49-
<div class="mt-3 flex justify-end gap-2">
50-
<Button
51-
variant="ghost"
52-
class="h-8 px-3 text-xs"
63+
64+
{/* Actions */}
65+
<div class="flex items-center gap-2 shrink-0 pl-2 border-l border-gray-5/50">
66+
<button
5367
onClick={() => props.onDismiss()}
54-
disabled={props.busy}
68+
class="px-2 py-1.5 text-xs font-medium text-gray-10 hover:text-gray-12 transition-colors"
5569
>
5670
{props.dismissLabel}
57-
</Button>
71+
</button>
5872
<Button
59-
variant="secondary"
60-
class="h-8 px-3 text-xs"
73+
variant={props.hasActiveRuns ? "danger" : "primary"}
74+
class="h-7 px-3 text-xs rounded-full font-medium"
6175
onClick={() => props.onReload()}
62-
disabled={!props.canReload}
76+
disabled={props.busy || !props.canReload}
6377
>
6478
{props.reloadLabel}
6579
</Button>

‎packages/app/src/app/system-state.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ export function createSystemState(options: {
188188
if (!reloadRequired()) return false;
189189
if (!options.client()) return false;
190190
if (reloadBusy()) return false;
191-
if (anyActiveRuns()) return false;
192191
if (options.mode() !== "host") return false;
193192
return true;
194193
});
@@ -207,10 +206,10 @@ export function createSystemState(options: {
207206
return;
208207
}
209208

210-
if (anyActiveRuns()) {
211-
setReloadError("Waiting for active tasks to complete before reloading.");
212-
return;
213-
}
209+
// if (anyActiveRuns()) {
210+
// setReloadError("Waiting for active tasks to complete before reloading.");
211+
// return;
212+
// }
214213

215214
setReloadBusy(true);
216215
setReloadError(null);

‎packages/app/src/i18n/locales/en.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,13 +554,14 @@ export default {
554554
"settings.updates_desktop_only": "Updates are only available in the desktop app.",
555555

556556
// ==================== Reload ====================
557-
"reload.toast_title": "Reload required",
558-
"reload.toast_description": "You need to reload your workspace for these changes to take effect.",
559-
"reload.toast_warning": "Reloading may interrupt active sessions or workflows.",
560-
"reload.toast_warning_active": "Active runs detected. Reloading now would interrupt them.",
557+
"reload.toast_title": "Updates available",
558+
"reload.toast_description": "Reload workspace to apply config changes.",
559+
"reload.toast_warning": "Stops all active tasks.",
560+
"reload.toast_warning_active": "Reloading stops {count} active tasks.",
561561
"reload.toast_reload": "Reload",
562+
"reload.toast_reload_stopped": "Reload & Stop Tasks",
562563
"reload.toast_reloading": "Reloading...",
563-
"reload.toast_dismiss": "Dismiss",
564+
"reload.toast_dismiss": "Later",
564565
"reload.toast_blocked_host": "Reloading is only available in Host mode.",
565566
"reload.toast_blocked_connect": "Connect to this workspace to reload.",
566567
"reload.toast_blocked_runs": "Waiting for active tasks to complete before reloading.",

‎packages/desktop/src-tauri/Cargo.lock‎

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)