From d3ef22605f9fd2293e3478b6b59d941e1a426f58 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Fri, 4 Dec 2026 13:03:04 +0800 Subject: [PATCH 1/4] fix(upstreams): persist failover order from drag sorting --- scripts/shots/mock/commands.ts | 9 +- scripts/shots/mock/config.ts | 24 ++++- scripts/ui/upstreams.pw.ts | 27 +++++- src-tauri/Cargo.lock | 2 + src-tauri/Cargo.toml | 2 + src-tauri/src/lib.rs | 1 + src-tauri/src/upstreams.rs | 131 +++++++++++++++++++++++++++- src-tauri/tests/control_plane.rs | 73 ++++++++++++++++ src/upstreams/UpstreamTable.tsx | 2 +- src/upstreams/UpstreamsPage.tsx | 72 ++++++++------- src/upstreams/api.ts | 3 + src/upstreams/upstreamOrder.i18n.ts | 5 -- src/upstreams/upstreamOrder.ts | 9 -- 13 files changed, 300 insertions(+), 60 deletions(-) diff --git a/scripts/shots/mock/commands.ts b/scripts/shots/mock/commands.ts index 8faa5a04..b704dc3f 100644 --- a/scripts/shots/mock/commands.ts +++ b/scripts/shots/mock/commands.ts @@ -14,9 +14,9 @@ import type { Adopted, ConnView, Tested } from "@/connection/api"; import type { AppInfo, HotkeyView, LanguageView, MenubarStyle, NoticeMode, ThemeView, UiZoom } from "@/settings/api"; import type { Offer, UpdateView } from "@/updateFlow"; import type { UpstreamStats } from "@/upstreams/api"; -import type { ClientsResponse, CoreStatus, Dashboard, ImportLink, KeyUsage, McpTargetView, PlanView, ScanReport } from "@/types"; +import type { ClientsResponse, ConfigWritten, CoreStatus, Dashboard, ImportLink, KeyUsage, McpTargetView, PlanView, ScanReport } from "@/types"; import { CORE, CHATGPT_WINDOWS } from "./core"; -import { LOCAL_GATEWAY, status } from "./config"; +import { LOCAL_GATEWAY, setUpstreamOrder, status } from "./config"; import { IN_FLIGHT, costBucketsBy, costBy, dashboard, upstreamLatency, upstreamTokenRate } from "./traffic"; import { clientsResponse, mcpTargets, plan, scanReport, setClientOrder } from "./clients"; import { NOTICES, APP_VERSION, SERVER, autostart, connView, langView, menubar, noticeMode, tested, themeView, updateView } from "./app"; @@ -58,6 +58,7 @@ interface Commands { // 概览与用量(Rust 侧从 core 取齐了一起给) dashboard: [Span, Dashboard]; upstream_stats: [Span & { egressSinceMs: [number, number, number] }, UpstreamStats]; + reorder_upstreams: [{ names: string[]; baseVersion: string }, ConfigWritten]; key_usage: [Span, KeyUsage]; // 提醒 notices_list: [void, Notice[]]; @@ -124,6 +125,10 @@ const COMMANDS: Table = { // 订阅额度是此刻的状态,和上游页同一份(dashboard.rs 同样问 `/quota`) return { ...dashboard(sinceMs, bucketMs), quotas: [{ provider: "chatgpt", windows: CHATGPT_WINDOWS() }] }; }, + reorder_upstreams: (a) => { + const req = need("reorder_upstreams", a, "names", "baseVersion"); + return setUpstreamOrder(req.names, req.baseVersion); + }, upstream_stats: (a) => { const { sinceMs, bucketMs, egressSinceMs } = need("upstream_stats", a, "sinceMs", "bucketMs", "egressSinceMs"); // 按出口分的流量,每个起点一份、整段一格(upstreams.rs 的 `WHOLE_MS`):直连是空串 diff --git a/scripts/shots/mock/config.ts b/scripts/shots/mock/config.ts index a809b935..2c155007 100644 --- a/scripts/shots/mock/config.ts +++ b/scripts/shots/mock/config.ts @@ -6,6 +6,7 @@ // 使用的时刻、价目表今天刷新过。 import type { ClientView, + ConfigWritten, DryRunRequest, DryRunResult, ModelRow, @@ -18,6 +19,7 @@ import type { SecurityDetail, Status, } from "@/types"; +import { sortUpstreams } from "@/upstreams/upstreamOrder"; import OV_EN from "../core/en/overview.json"; import KEYS_EN from "../core/en/keys.json"; import SEC_EN from "../core/en/security.json"; @@ -235,9 +237,12 @@ const BODY_BYTES = 412 * 1024 ** 2; export function overview(lastSeen: Map): Overview { const o = clone(FX.overview); + const order = upstreamOrder(); return { ...o, - providers: providers(), + config_version: order?.version ?? o.config_version, + providers: order ? sortUpstreams(providers(), order.names) : providers(), + groups: order ? o.groups.map((group) => group.builtin ? { ...group, providers: order.names } : group) : o.groups, clients: o.clients.map((c) => ({ ...c, last_seen_ms: lastSeen.get(c.name) ?? null })), retention: { ...o.retention, body_bytes_now: BODY_BYTES }, }; @@ -288,7 +293,22 @@ export function status(gatewayAddr: string, inFlight: number): Status { } /** 配置的版本号(core 算的内容哈希) */ -export const configVersion = () => FX.overview.config_version; +const UPSTREAM_ORDER_KEY = "shot-core-upstream-order"; +const upstreamOrder = (): { names: string[]; version: string } | null => + JSON.parse(localStorage.getItem(UPSTREAM_ORDER_KEY) ?? "null"); + +export const configVersion = () => upstreamOrder()?.version ?? FX.overview.config_version; + +export function setUpstreamOrder(names: string[], baseVersion: string): ConfigWritten { + if (baseVersion !== configVersion()) { + throw msg("control.config_stale", "The configuration has changed.", { + base: baseVersion, current: configVersion(), + }); + } + const version = `${baseVersion}-reordered`; + localStorage.setItem(UPSTREAM_ORDER_KEY, JSON.stringify({ names, version })); + return { version }; +} /** 配置文件原文。截图里不打开它,给一份读得通的 */ export const CONFIG_TEXT = "# ~/.thinkwatch/config.yaml\nversion: 1\n"; diff --git a/scripts/ui/upstreams.pw.ts b/scripts/ui/upstreams.pw.ts index 9c2e29e2..b29a05ae 100644 --- a/scripts/ui/upstreams.pw.ts +++ b/scripts/ui/upstreams.pw.ts @@ -1,7 +1,7 @@ import { expect, test } from "@playwright/test"; import type {} from "../shots/drive"; -test("an upstream row can be dropped below the table and the order survives reload", async ({ page }) => { +test("upstream drag changes the built-in group and the order survives reload", async ({ page }) => { await page.goto("/scripts/shots/index.html?scene=upstreams&lang=zh"); await page.waitForFunction(() => window.__shot?.state === "ready"); const rows = page.locator("tr[data-reorder-scope]"); @@ -38,4 +38,29 @@ test("an upstream row can be dropped below the table and the order survives relo await page.reload(); await page.waitForFunction(() => window.__shot?.state === "ready"); await expect.poll(names).toEqual(reordered); + + await page.getByRole("button", { name: "路由", exact: true }).click(); + await page.getByRole("tab", { name: "策略组" }).click(); + const builtIn = page.getByRole("row", { name: /^全部上游 / }); + await expect(builtIn.locator(".font-mono")).toHaveText(reordered.map((name) => name!)); +}); + +test("a rejected upstream reorder restores the order from Core", async ({ page }) => { + await page.goto("/scripts/shots/index.html?scene=upstreams&lang=zh"); + await page.waitForFunction(() => window.__shot?.state === "ready"); + await page.evaluate(() => { + const ctx = window as unknown as { + __TAURI_INTERNALS__: { invoke(cmd: string, args?: Record): Promise }; + }; + const invoke = ctx.__TAURI_INTERNALS__.invoke; + ctx.__TAURI_INTERNALS__.invoke = (cmd, args) => + invoke(cmd, cmd === "reorder_upstreams" ? { ...args, baseVersion: "outdated" } : args); + }); + const rows = page.locator("tr[data-reorder-scope]"); + const names = () => rows.evaluateAll((list) => list.map((row) => row.getAttribute("data-row"))); + await expect.poll(() => rows.count()).toBeGreaterThan(1); + const initial = await names(); + await rows.first().press("Alt+ArrowDown"); + await expect(page.getByText("无法保存列表顺序")).toBeVisible(); + await expect.poll(names).toEqual(initial); }); diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e9ee34fd..bb4e57aa 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4993,6 +4993,7 @@ dependencies = [ "semver", "serde", "serde_json", + "serde_yaml_ng", "tar", "tauri", "tauri-build", @@ -5017,6 +5018,7 @@ dependencies = [ "tw-link", "tw-scan", "tw-types", + "tw-yaml", "url", "windows 0.61.3", "windows-registry 0.6.1", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index fabbc3d9..9f39a4d2 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -67,6 +67,7 @@ tw-adopt = { path = "crates/tw-adopt" } tw-scan = { path = "crates/tw-scan" } tw-types = { workspace = true } tw-guard = { workspace = true } +tw-yaml = { workspace = true } # 控制面的握手与加密(Noise NNpsk0),和 core 用的是同一份实现。握手里交换的控制面 # 版本号来自 tw-api,所以两者必须钉在同一个 tag 上(见上面 `[workspace.dependencies]`) tw-link = { workspace = true } @@ -88,6 +89,7 @@ serde = { version = "1", features = ["derive"] } url = "2" ipnet = "2" serde_json = "1" +serde_yaml_ng = "0.10" thiserror = "2" tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "time", "sync", "process", "io-util"] } # 菜单栏的「今日」从这台机器的本地零点算起(`menubar::day_of`)。**时区只有桌面这边 diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c988f5ba..e2356743 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -237,6 +237,7 @@ pub fn run() { export::save_export, export::open_import, upstreams::upstream_stats, + upstreams::reorder_upstreams, aliases::alias_hints, notices::commands::notices_list, notices::commands::mark_notice_read, diff --git a/src-tauri/src/upstreams.rs b/src-tauri/src/upstreams.rs index 11d0123c..31163c14 100644 --- a/src-tauri/src/upstreams.rs +++ b/src-tauri/src/upstreams.rs @@ -2,11 +2,122 @@ //! //! 上游、代理、价目表的增删改与检测都是直接转发的端点,走 `crate::call`。 -use tw_api::ep; +use std::collections::HashMap; + +use serde_yaml_ng::Value; +use tw_api::{ConfigWrite, ConfigWritten, ep}; +use tw_yaml::{PatchError, Put, path}; use crate::AppState; +use crate::control::Pinned; use crate::dashboard::WHOLE_MS; -use crate::error::Out; +use crate::error::{CmdError, Out}; + +#[tauri::command] +pub async fn reorder_upstreams( + state: tauri::State<'_, AppState>, + names: Vec, + base_version: String, +) -> Out { + save_order(&state.control.pin()?, &names, &base_version).await +} + +/// Stay on one Core even if the active connection switches before the write. +pub async fn save_order(core: &Pinned, names: &[String], base_version: &str) -> Out { + let config = core.call::(&[], &()).await?; + if config.version != base_version { + return Err(tw_api::Msg { + code: "control.config_stale".into(), + args: [ + ("base".into(), base_version.into()), + ("current".into(), config.version.clone()), + ].into(), + text: format!( + "Version mismatch: this edit is based on {base_version}, and the current version is {}. Refresh and edit again.", + config.version, + ), + }.into()); + } + let text = + reordered_config(&config.text, names).map_err(|error| CmdError::from(error.msg()))?; + if text == config.text { + return Ok(ConfigWritten { + version: config.version, + }); + } + Ok(core + .call::( + &[], + &ConfigWrite { + base_version: config.version, + text, + }, + ) + .await?) +} + +fn reordered_config(text: &str, names: &[String]) -> Result { + #[derive(serde::Deserialize)] + struct UpstreamName { + name: String, + } + + #[derive(serde::Deserialize)] + struct Upstreams { + #[serde(default)] + providers: Vec, + } + + let config: Upstreams = + serde_yaml_ng::from_str(text).map_err(|error| PatchError::Parse(error.to_string()))?; + let bad_order = + || PatchError::SelfCheck("The order must list every upstream exactly once".into()); + if config.providers.len() != names.len() { + return Err(bad_order()); + } + let mut indices: HashMap<_, _> = config + .providers + .iter() + .enumerate() + .map(|(index, provider)| (provider.name.as_str(), index)) + .collect(); + let order = names + .iter() + .map(|name| indices.remove(name.as_str()).ok_or_else(bad_order)) + .collect::, _>>()?; + if order.iter().copied().eq(0..order.len()) { + return Ok(text.to_owned()); + } + + let providers = path!["providers"]; + if !tw_yaml::is_flow_at(text, &providers)? { + return tw_yaml::reorder(text, &providers, &order); + } + + // Flow-style YAML stores several providers on one line. Replace that sequence + // alone and check that the rest of the configuration still parses to the same values. + let mut expected: Value = + serde_yaml_ng::from_str(text).map_err(|error| PatchError::Parse(error.to_string()))?; + let items = expected + .get_mut("providers") + .and_then(Value::as_sequence_mut) + .ok_or_else(bad_order)?; + *items = order + .into_iter() + .map(|index| items[index].clone()) + .collect(); + let block = serde_yaml_ng::to_string(items) + .map_err(|error| PatchError::SelfCheck(error.to_string()))?; + let updated = tw_yaml::put(text, &providers, Put::Block(block.trim_end_matches('\n')))?; + let actual: Value = serde_yaml_ng::from_str(&updated) + .map_err(|error| PatchError::SelfCheck(error.to_string()))?; + if actual != expected { + return Err(PatchError::SelfCheck( + "Reordering changed other configuration values".into(), + )); + } + Ok(updated) +} /// 上游列表那几列统计:一段时间里的请求与费用、第一个 token 到的时刻、生成速度、订阅 /// 额度,同一段时间按上游分格的请求数(每一行的走势),以及代理表那一列流量。 @@ -99,3 +210,19 @@ fn since(from_ms: i64) -> tw_api::Window { to_ms: None, } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn reorders_flow_style_providers_and_preserves_the_rest() { + let original = "version: 1\nproviders: [{name: 2024, base_url: 'https://a.example'}, {name: b, extra_body: {enabled: false}}]\n# Keep this\nlogs: {}\n"; + let ordered = ["b".to_owned(), "2024".to_owned()]; + let reordered = reordered_config(original, &ordered).unwrap(); + assert!(reordered.contains("# Keep this\nlogs: {}\n")); + assert!(reordered.find("name: b").unwrap() < reordered.find("name: 2024").unwrap()); + assert!(reordered_config(original, &["b".into(), "b".into()]).is_err()); + assert!(reordered_config(original, &["b".into()]).is_err()); + } +} diff --git a/src-tauri/tests/control_plane.rs b/src-tauri/tests/control_plane.rs index f3f40ccd..10bcc7ec 100644 --- a/src-tauri/tests/control_plane.rs +++ b/src-tauri/tests/control_plane.rs @@ -644,6 +644,79 @@ async fn the_generic_call_speaks_every_shape() { assert!(w.is_ok(), "{:?}", w.err()); } +#[tokio::test] +async fn upstream_order_is_saved_to_core_and_used_for_failover() { + use thinkwatch_lite_lib::upstreams::save_order; + use tw_api::{ConfigWrite, DryRunRequest, ep}; + + let core = Core::start(); + core.wait_ready().await; + let c = core.ok().pin().unwrap(); + let config = c.call::(&[], &()).await.unwrap(); + let providers = r#"- name: first # comment travels with this upstream + base_url: http://127.0.0.1:1/v1 + protocol: openai-chat + models: [ordering-test] +- name: second + base_url: http://127.0.0.1:2/v1 + protocol: openai-chat + models: [ordering-test]"#; + let text = tw_yaml::put( + &config.text, + &tw_yaml::path!["providers"], + tw_yaml::Put::Block(providers), + ) + .unwrap(); + let written = c + .call::( + &[], + &ConfigWrite { + base_version: config.version, + text, + }, + ) + .await + .unwrap(); + let request: DryRunRequest = + serde_json::from_value(serde_json::json!({ "model": "ordering-test", "route": "default" })) + .unwrap(); + let before = c.call::(&[], &request).await.unwrap(); + assert_eq!(before.candidates, ["first", "second"]); + + let names = ["second".into(), "first".into()]; + let reordered = save_order(&c, &names, &written.version).await.unwrap(); + let overview = c.call::(&[], &()).await.unwrap(); + let group = overview.groups.iter().find(|group| group.builtin).unwrap(); + assert_eq!(group.providers, names); + assert_eq!( + overview + .providers + .iter() + .map(|provider| &provider.name) + .collect::>(), + names.iter().collect::>() + ); + let after = c.call::(&[], &request).await.unwrap(); + assert_eq!(after.candidates, names); + let saved = c.call::(&[], &()).await.unwrap(); + assert_eq!(saved.version, reordered.version); + assert!( + saved + .text + .contains("name: first # comment travels with this upstream") + ); + assert!(saved.text.find("name: second").unwrap() < saved.text.find("name: first").unwrap()); + + let stale = save_order(&c, &["first".into(), "second".into()], &written.version) + .await + .unwrap_err(); + assert_eq!(stale.into_msg().code, "control.config_stale"); + assert_eq!( + c.call::(&[], &()).await.unwrap().text, + saved.text + ); +} + /// Bedrock 上游照对话框交上去的样子存得进去:API 密钥、访问密钥、AWS profile 三种 /// 都行;密钥和 profile 混着写被拒并带码。标准地址认得出协议和区域 #[tokio::test] diff --git a/src/upstreams/UpstreamTable.tsx b/src/upstreams/UpstreamTable.tsx index bc2604ee..37af5349 100644 --- a/src/upstreams/UpstreamTable.tsx +++ b/src/upstreams/UpstreamTable.tsx @@ -73,7 +73,7 @@ export interface UpstreamActions { } /** - * 上游列表。拖动任一行调整显示顺序,单击打开编辑对话框。 + * 上游列表。拖动任一行调整上游顺序,单击打开编辑对话框。 * * 单击一行(或 Enter)打开它的编辑对话框;行尾按钮和右键打开的是同一份操作。 * diff --git a/src/upstreams/UpstreamsPage.tsx b/src/upstreams/UpstreamsPage.tsx index d40f2e48..def3a1f7 100644 --- a/src/upstreams/UpstreamsPage.tsx +++ b/src/upstreams/UpstreamsPage.tsx @@ -1,6 +1,6 @@ import { Label } from "@/ui/label"; import { useEffect, useMemo, useState, type ReactNode } from "react"; -import { ActivityIcon, RotateCcwIcon, NetworkIcon, PlusIcon, RefreshCwIcon, ServerIcon, ZapIcon } from "lucide-react"; +import { ActivityIcon, NetworkIcon, PlusIcon, RefreshCwIcon, ServerIcon, ZapIcon } from "lucide-react"; import { ExportDialog } from "@/backup/ExportDialog"; import { useImport } from "@/backup/useImport"; import { ShareDialog } from "./ShareDialog"; @@ -8,7 +8,6 @@ import type { ConfigFocus } from "@/configLocate"; import { invalidate, type Resource } from "@/lib/resource"; import { useWriteQueue } from "@/lib/writeQueue"; import { useNav, useNavParams } from "@/nav"; -import { useConnections } from "@/connection/ConnectionProvider"; import { Banner } from "@/ui/banner"; import { Button } from "@/ui/button"; import { Count } from "@/ui/count"; @@ -50,7 +49,7 @@ import { formFromView, sheetPrefill, toInput } from "./upstreamForm"; import { upstreamsPageText } from "./UpstreamsPage.i18n"; import { CostFigure } from "@/CostFigure"; import { UpstreamTable, problemsOf } from "./UpstreamTable"; -import { readUpstreamOrder, sortUpstreams } from "./upstreamOrder"; +import { sortUpstreams } from "./upstreamOrder"; import { upstreamOrderText } from "./upstreamOrder.i18n"; import { NextClientsHint } from "@/guide/PageHints"; import { SyncConflictBanner } from "@/sync/Notices"; @@ -94,7 +93,7 @@ type DialogState = * 上游、代理、价目表描述出站侧的三个方面 —— 请求发往哪个服务、经过哪条网络路径、 * 按什么价格结算 —— 而代理和价目表只被上游引用,所以放在同一页里,引用关系在 * 页内闭合。别名是同一个模型在各个上游的不同名称,也只和上游的模型清单打交道。 - * 新建与编辑在对话框里完成,列表可以拖动调整显示顺序。 + * 新建与编辑在对话框里完成,拖动列表会更新 Core 的上游顺序。 * 「这些上游实际表现如何」不另起一个标签:最近 7 天体检标出的偏差直接写在上游表那一行, * 判断一个上游去留的地方就看得到证据。 * @@ -115,27 +114,36 @@ export default function UpstreamsPage({ const c = useText(commonText); const at = useText(aliasesText); const nav = useNav(); - const { view: connection } = useConnections(); const orderText = useText(upstreamOrderText); - const orderKey = `upstreams.order.${connection?.data_dir ?? ""}.${connection?.current ?? "local"}`; - const [localOrder, setLocalOrder] = useState<{ key: string; names: string[] } | null>(null); - const storedOrder = useMemo(() => readUpstreamOrder(orderKey), [orderKey]); - const savedOrder = localOrder?.key === orderKey ? localOrder.names : storedOrder; - - function saveOrder(order: string[]) { - const known = new Set(ov.providers.map((provider) => provider.name)); - const names = order.filter((name) => known.has(name)); - try { - window.localStorage.setItem(orderKey, JSON.stringify(names)); - setLocalOrder({ key: orderKey, names }); - } catch { - notify.error(orderText.storageError); - } - } const configVersion = ov.config_version; - /** 这一页上的启停排成一队,见 `toggle` */ + /** 排序和启停共用写入队列。 */ const queue = useWriteQueue(configVersion); + const [pendingOrder, setPendingOrder] = useState<{ names: string[]; baseVersion: string; saving: boolean } | null>(null); + const visibleOrder = pendingOrder?.saving || pendingOrder?.baseVersion === configVersion ? pendingOrder : null; + useEffect(() => { + if (!visibleOrder && pendingOrder) setPendingOrder((order) => order === pendingOrder ? null : order); + }, [visibleOrder, pendingOrder]); + + async function saveOrder(names: string[]) { + const draft = { names, baseVersion: configVersion, saving: true }; + setPendingOrder(draft); + try { + const written = await queue(async (baseVersion) => ({ + ...await api.reorderProviders(names, baseVersion), + baseVersion, + })); + setPendingOrder((order) => { + if (order !== draft) return order; + return written.version === written.baseVersion ? null : { names, baseVersion: written.baseVersion, saving: false }; + }); + } catch (error) { + setPendingOrder((order) => order === draft ? null : order); + notify.error(error, orderText.storageError); + } finally { + onChanged(); + } + } const [tab, setTabState] = useState(lastTab); const setTab = (next: UpstreamTab) => { lastTab = next; @@ -178,18 +186,10 @@ export default function UpstreamsPage({ return next; }); }, [ov.providers, pendingDisabled]); - const orderedProviders = useMemo(() => sortUpstreams(providers, savedOrder), [providers, savedOrder]); - useEffect(() => { - const known = new Set(ov.providers.map((provider) => provider.name)); - const names = savedOrder.filter((name) => known.has(name)); - if (names.length === savedOrder.length) return; - try { - window.localStorage.setItem(orderKey, JSON.stringify(names)); - setLocalOrder({ key: orderKey, names }); - } catch { - // A read-only store still allows us to render the reordered list. - } - }, [ov.providers, orderKey, savedOrder]); + const orderedProviders = useMemo( + () => visibleOrder ? sortUpstreams(providers, visibleOrder.names) : providers, + [providers, visibleOrder], + ); /* 别的页和命令面板送来的(见 nav.tsx)。带着一个上游名打开:切到上游标签,那一行滚进 @@ -393,10 +393,6 @@ export default function UpstreamsPage({ /> )} - {savedOrder.length > 0 && ( - } label={orderText.reset} - onClick={() => saveOrder([])} /> - )} {picked.length > 0 && (