Skip to content

Commit 3bf7654

Browse files
committed
Show big warning if user tries to flash unstable firmware
1 parent 5c4f550 commit 3bf7654

3 files changed

Lines changed: 55 additions & 3 deletions

File tree

src/lib/components/FirmwareChannelSelector.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@
6161
{#if channel === 'stable'}
6262
<CircleCheckBig color="#22c55e" />
6363
<p class="text-green-500">This is the recommended channel.</p>
64+
<!--
6465
{:else if channel === 'beta'}
6566
<TriangleAlert color="#eab308" />
6667
<p class="text-yellow-500">This channel might contain bugs.</p>
68+
-->
6769
{:else}
6870
<TriangleAlert color="#ef4444" />
69-
<p class="text-red-500">Avoid this channel unless you know what you're doing.</p>
71+
<p class="text-red-500 font-bold">DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING</p>
7072
{/if}
7173
</div>
7274
</div>

src/routes/flashtool/+page.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { MessageCircleQuestion, SquareTerminal } from '@lucide/svelte';
33
import { browser } from '$app/environment';
44
import { PUBLIC_DISCORD_INVITE_URL } from '$env/static/public';
5+
import type { FirmwareChannel } from '$lib/api/firmwareCDN';
56
import Container from '$lib/components/Container.svelte';
67
import FirmwareChannelSelector from '$lib/components/FirmwareChannelSelector.svelte';
78
import TextInput from '$lib/components/input/TextInput.svelte';
@@ -58,6 +59,7 @@
5859
5960
let showHelpDialog = $state(false);
6061
62+
let channel = $state<FirmwareChannel>('stable');
6163
let version = $state<string | null>(null);
6264
let board = $state<string | null>(null);
6365
let eraseBeforeFlash = $state<boolean>(false);
@@ -105,7 +107,7 @@
105107

106108
{#if manager}
107109
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight">Select Channel</h3>
108-
<FirmwareChannelSelector bind:version disabled={isFlashing} />
110+
<FirmwareChannelSelector bind:channel bind:version disabled={isFlashing} />
109111

110112
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight">Select Board</h3>
111113
<FirmwareBoardSelector {version} bind:selectedBoard={board} disabled={isFlashing} />
@@ -127,7 +129,14 @@
127129
</div>
128130

129131
{#if version && board}
130-
<FirmwareFlasher {version} {board} {manager} {eraseBeforeFlash} bind:isFlashing />
132+
<FirmwareFlasher
133+
{version}
134+
{board}
135+
{manager}
136+
{eraseBeforeFlash}
137+
showNonStableWarning={channel !== 'stable'}
138+
bind:isFlashing
139+
/>
131140
{/if}
132141
{:else if port && !connectFailed}
133142
<div class="flex flex-col items-center gap-2">

src/routes/flashtool/FirmwareFlasher.svelte

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Microchip, TriangleAlert } from '@lucide/svelte';
33
import { DownloadAndVerifyBoardBinary } from '$lib/api/firmwareCDN';
44
import { Button } from '$lib/components/ui/button';
5+
import * as Dialog from '$lib/components/ui/dialog';
56
import { Progress } from '$lib/components/ui/progress';
67
import FlashManager from './FlashManager';
78
@@ -10,6 +11,7 @@
1011
board: string;
1112
manager: FlashManager;
1213
eraseBeforeFlash: boolean;
14+
showNonStableWarning: boolean;
1315
isFlashing?: boolean;
1416
}
1517
@@ -18,9 +20,11 @@
1820
board,
1921
manager,
2022
eraseBeforeFlash,
23+
showNonStableWarning,
2124
isFlashing = $bindable(false),
2225
}: Props = $props();
2326
27+
let riskAcknowledgeStatus = $state<'none' | 'shown' | 'accepted'>('none');
2428
let progressName = $state<string | null>(null);
2529
let progressPercent = $state<number | null>(null);
2630
let error = $state<string | null>(null);
@@ -65,6 +69,10 @@
6569
}
6670
async function FlashDevice() {
6771
if (isFlashing) return;
72+
if (showNonStableWarning && riskAcknowledgeStatus !== 'accepted') {
73+
riskAcknowledgeStatus = 'shown';
74+
return;
75+
}
6876
try {
6977
isFlashing = true;
7078
await FlashDeviceImpl();
@@ -76,6 +84,39 @@
7684
}
7785
</script>
7886

87+
<!-- Risk acknowledgement modal -->
88+
<Dialog.Root open={riskAcknowledgeStatus === 'shown'}>
89+
<Dialog.Content>
90+
<Dialog.Header>
91+
<Dialog.Title>⚠️ Unstable Firmware Warning</Dialog.Title>
92+
<Dialog.Description>
93+
You are about to install <strong class="text-red-500">experimental, non-stable firmware</strong>.
94+
<br /><br />
95+
This firmware is <strong class="text-red-500">not intended for general use</strong> and may contain
96+
serious bugs, regressions, or incomplete features.
97+
<br /><br />
98+
<strong class="text-red-500">No support is provided for issues caused by non-stable firmware.</strong>
99+
</Dialog.Description>
100+
</Dialog.Header>
101+
102+
<div class="flex justify-end gap-2">
103+
<Button
104+
variant="secondary"
105+
onclick={() => (riskAcknowledgeStatus = 'none')}
106+
>
107+
Cancel
108+
</Button>
109+
110+
<Button
111+
variant="destructive"
112+
onclick={() => (riskAcknowledgeStatus = 'accepted')}
113+
>
114+
I UNDERSTAND AND ACCEPT ALL RISKS
115+
</Button>
116+
</div>
117+
</Dialog.Content>
118+
</Dialog.Root>
119+
79120
<div class="flex flex-col items-stretch justify-start gap-4">
80121
<!-- Flash button -->
81122
<Button onclick={FlashDevice} disabled={!manager || isFlashing}>

0 commit comments

Comments
 (0)