LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
release: v0.4.1 — update banner UX + system browser opener
nash_su0fea87ad74af
diff --git a/package-lock.json b/package-lock.jsonindex 595dfc0c..9dd3c61a 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "llm-wiki",- "version": "0.3.10",+ "version": "0.4.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "llm-wiki",- "version": "0.3.10",+ "version": "0.4.0","dependencies": {"@base-ui/react": "^1.3.0","@fontsource-variable/geist": "^5.2.8",@@ -19,6 +19,7 @@"@tauri-apps/api": "^2.10.1","@tauri-apps/plugin-dialog": "^2.7.0","@tauri-apps/plugin-http": "^2.5.8",+ "@tauri-apps/plugin-opener": "^2.5.3","@tauri-apps/plugin-store": "^2.4.2","class-variance-authority": "^0.7.1","clsx": "^2.1.1",@@ -2896,6 +2897,15 @@"@tauri-apps/api": "^2.10.1"}},+ "node_modules/@tauri-apps/plugin-opener": {+ "version": "2.5.3",+ "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.5.3.tgz",+ "integrity": "sha512-CCcUltXMOfUEArbf3db3kCE7Ggy1ExBEBl51Ko2ODJ6GDYHRp1nSNlQm5uNCFY5k7/ufaK5Ib3Du/Zir19IYQQ==",+ "license": "MIT OR Apache-2.0",+ "dependencies": {+ "@tauri-apps/api": "^2.8.0"+ }+ },"node_modules/@tauri-apps/plugin-store": {"version": "2.4.2","resolved": "https://registry.npmjs.org/@tauri-apps/plugin-store/-/plugin-store-2.4.2.tgz",diff --git a/package.json b/package.jsonindex 50705267..5a41a44f 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "llm-wiki","private": true,- "version": "0.4.0",+ "version": "0.4.1","type": "module","scripts": {"dev": "vite",@@ -25,6 +25,7 @@"@tauri-apps/api": "^2.10.1","@tauri-apps/plugin-dialog": "^2.7.0","@tauri-apps/plugin-http": "^2.5.8",+ "@tauri-apps/plugin-opener": "^2.5.3","@tauri-apps/plugin-store": "^2.4.2","class-variance-authority": "^0.7.1","clsx": "^2.1.1",diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 676646c2..41b343f3 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -4420,7 +4420,7 @@ checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"[[package]]name = "llm-wiki"-version = "0.4.0"+version = "0.4.1"dependencies = ["arrow-array","arrow-schema",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 269c5025..99c520b2 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "llm-wiki"-version = "0.4.0"+version = "0.4.1"description = "LLM Wiki - A personal knowledge base for LLM concepts"authors = []edition = "2021"diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 7e08da1a..cdef35a8 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -1,7 +1,7 @@{"$schema": "https://schema.tauri.app/config/2","productName": "LLM Wiki",- "version": "0.4.0",+ "version": "0.4.1","identifier": "com.llmwiki.app","build": {"beforeDevCommand": "npm run dev",diff --git a/src/App.tsx b/src/App.tsxindex 82e9ba90..0339a7e8 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -29,10 +29,66 @@ function App() {startClipWatcher()}, [])+ // Dev-only helper for visually testing the update-banner UX.+ // Open dev tools and run:+ // __llmwiki_testUpdateBanner()+ // to inject a fake "available" result into the update store —+ // banner appears at the top + red dot lights up the gear icon.+ // Run again with arg `false` (or call setDismissed via the store)+ // to clear. Gated on `import.meta.env.DEV` so the helper never+ // ships in production builds.+ useEffect(() => {+ if (!import.meta.env.DEV) return+ ;(async () => {+ const storeMod = await import("@/stores/update-store")+ const { useUpdateStore } = storeMod+ // Expose the live store getter on window so you can inspect+ // state from devtools when debugging banner behavior.+ ;(window as unknown as { __llmwiki_updateStore?: typeof useUpdateStore }).__llmwiki_updateStore = useUpdateStore+ ;(window as unknown as { __llmwiki_testUpdateBanner?: (clear?: boolean) => void }).__llmwiki_testUpdateBanner = (clear = false) => {+ if (clear) {+ useUpdateStore.getState().setResult(+ { kind: "up-to-date", local: __APP_VERSION__, remote: __APP_VERSION__ },+ Date.now(),+ )+ useUpdateStore.getState().setDismissed(null)+ console.log("[test] update banner cleared")+ return+ }+ useUpdateStore.getState().setResult(+ {+ kind: "available",+ local: __APP_VERSION__,+ remote: "v999.0.0",+ release: {+ name: "v999.0.0 (test)",+ tag_name: "v999.0.0",+ body:+ "Test release for banner-UX verification.\n\n" ++ "- Bigger red dot on the Settings icon\n" ++ "- Top banner with one-click dismiss\n" ++ "- Once dismissed, won't reappear for this version",+ html_url: "https://github.com/nashsu/llm_wiki/releases",+ published_at: new Date().toISOString(),+ },+ },+ Date.now(),+ )+ useUpdateStore.getState().setDismissed(null)+ console.log(+ "[test] update banner injected. Run __llmwiki_testUpdateBanner(true) to clear.",+ )+ }+ })()+ }, [])+// Background update check — hydrate persisted user preferences, then- // hit GitHub at most once every UPDATE_CHECK_CACHE_MS. Runs 5 s after- // mount so it doesn't contend with startup work. Silent on failure;- // the UI in Settings → About surfaces the result.+ // hit GitHub at most once every UPDATE_CHECK_CACHE_MS. Runs 1.5 s+ // after mount so it doesn't contend with the heaviest startup work+ // (project load, file tree, vector store init) but still surfaces+ // a new release in time for the user to notice it during their+ // first interaction. Silent on failure; the UI in Settings → About+ // lets the user retry manually.useEffect(() => {let cancelled = falseconst timer = setTimeout(async () => {@@ -50,21 +106,57 @@ function App() {if (persisted) useUpdateStore.getState().hydrate(persisted)const state = useUpdateStore.getState()- if (!state.enabled) return+ if (!state.enabled) {+ console.log("[update-check] skipped: user disabled auto-check in settings")+ return+ }const now = Date.now()+ // Cache hit requires BOTH the timestamp AND the in-memory+ // result to be present. `lastCheckedAt` is persisted to+ // disk but `lastResult` deliberately is not — keeping the+ // GitHub payload out of the persisted store keeps disk+ // size + privacy footprint small. The downside: a fresh+ // cold start has `lastResult === null` even when+ // `lastCheckedAt` is recent, in which case we MUST refetch+ // — otherwise we'd skip the check AND have no result to+ // display, leaving the banner permanently stuck off.+ // (This was the user-reported bug: "kind=none, no banner".)const fresh =state.lastCheckedAt !== null &&+ state.lastResult !== null &&now - state.lastCheckedAt < UPDATE_CHECK_CACHE_MS- if (fresh) return+ if (fresh) {+ const ageMin = Math.round((now - (state.lastCheckedAt ?? 0)) / 60_000)+ console.log(+ `[update-check] skipped: cache hit (last check ${ageMin} min ago, ` ++ `cache window ${UPDATE_CHECK_CACHE_MS / 60_000} min). ` ++ `Last result: kind=${state.lastResult?.kind ?? "none"}`,+ )+ return+ }useUpdateStore.getState().setChecking(true)+ console.log(+ `[update-check] fetching GitHub releases (local=${__APP_VERSION__})`,+ )const result = await checkForUpdates({currentVersion: __APP_VERSION__,repo: "nashsu/llm_wiki",})if (cancelled) returnuseUpdateStore.getState().setResult(result, Date.now())+ if (result.kind === "available") {+ console.log(+ `[update-check] update available: local=${result.local} → remote=${result.remote}`,+ )+ } else if (result.kind === "up-to-date") {+ console.log(+ `[update-check] up to date: local=${result.local}, remote latest=${result.remote}`,+ )+ } else {+ console.log(`[update-check] error: ${result.message}`)+ }await saveUpdateCheckState({enabled: useUpdateStore.getState().enabled,lastCheckedAt: Date.now(),@@ -73,7 +165,7 @@ function App() {} catch {// Silent — Settings → About lets the user retry manually.}- }, 5000)+ }, 1500)return () => {cancelled = trueclearTimeout(timer)diff --git a/src/components/layout/app-layout.tsx b/src/components/layout/app-layout.tsxindex 4938b4e9..bcfe85ee 100644--- a/src/components/layout/app-layout.tsx+++ b/src/components/layout/app-layout.tsx@@ -3,6 +3,7 @@ import { useWikiStore } from "@/stores/wiki-store"import { listDirectory } from "@/commands/fs"import { normalizePath } from "@/lib/path-utils"import { IconSidebar } from "./icon-sidebar"+import { UpdateBanner } from "./update-banner"import { SidebarPanel } from "./sidebar-panel"import { ContentArea } from "./content-area"import { PreviewPanel } from "./preview-panel"@@ -90,9 +91,16 @@ export function AppLayout({ onSwitchProject }: AppLayoutProps) {const hasRightPanel = !isSettings && !!(selectedFile || researchPanelOpen)return (- <div className="flex h-screen bg-background text-foreground">- <IconSidebar onSwitchProject={onSwitchProject} />- <div ref={containerRef} className="flex min-w-0 flex-1 overflow-hidden">+ // Outer column layout: full-width update banner on top (when an+ // update is available AND not dismissed for this version), the+ // existing IconSidebar + content row below. Banner is shrink-0+ // so it doesn't compress the work area; main row is flex-1 so+ // it fills the rest of the viewport.+ <div className="flex h-screen flex-col bg-background text-foreground">+ <UpdateBanner />+ <div className="flex min-h-0 flex-1">+ <IconSidebar onSwitchProject={onSwitchProject} />+ <div ref={containerRef} className="flex min-w-0 flex-1 overflow-hidden">{!isSettings && (<>{/* Left: File tree + Activity */}@@ -147,6 +155,7 @@ export function AppLayout({ onSwitchProject }: AppLayoutProps) {</div></>)}+ </div></div></div>)diff --git a/src/components/layout/icon-sidebar.tsx b/src/components/layout/icon-sidebar.tsxindex 8b1e02b1..a95f7546 100644--- a/src/components/layout/icon-sidebar.tsx+++ b/src/components/layout/icon-sidebar.tsx@@ -6,7 +6,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/compimport { useWikiStore } from "@/stores/wiki-store"import { useReviewStore } from "@/stores/review-store"import { useResearchStore } from "@/stores/research-store"-import { useUpdateStore, shouldShowUpdateBanner } from "@/stores/update-store"+import { useUpdateStore, hasAvailableUpdate } from "@/stores/update-store"import { useTranslation } from "react-i18next"import logoImg from "@/assets/logo.jpg"import type { WikiState } from "@/stores/wiki-store"@@ -34,7 +34,14 @@ export function IconSidebar({ onSwitchProject }: IconSidebarProps) {const researchPanelOpen = useResearchStore((s) => s.panelOpen)const researchActiveCount = useResearchStore((s) => s.tasks.filter((t) => t.status !== "done" && t.status !== "error").length)const toggleResearchPanel = useResearchStore((s) => s.setPanelOpen)- const updateBannerVisible = useUpdateStore((s) => shouldShowUpdateBanner(s))+ // Use `hasAvailableUpdate` (ignores dismiss state) rather than+ // `shouldShowUpdateBanner`. The dot is a passive signpost — it+ // should keep marking the gear as long as the update exists, even+ // after the user closes the more aggressive top banner. Without+ // this split, dismissing the banner would silently lose the only+ // remaining indicator that an update is available, so the user+ // never finds their way back to it.+ const updateAvailable = useUpdateStore((s) => hasAvailableUpdate(s))// Daemon health checkconst [daemonStatus, setDaemonStatus] = useState<string>("starting")@@ -140,19 +147,25 @@ export function IconSidebar({ onSwitchProject }: IconSidebarProps) {}`}><Settings className="h-5 w-5" />- {updateBannerVisible && (- // Small dot at the top-right of the Settings icon when- // a new release is available; dismissed versions clear- // it automatically via shouldShowUpdateBanner.+ {updateAvailable && (+ // Update-available indicator on the Settings gear.+ // Smaller (8px / `h-2 w-2`) so it doesn't shout —+ // the top banner is already the loud surface; this+ // dot is just a quiet "where to go" signpost. Red+ // (vs. previous primary-blue) gives it enough+ // visual contrast that it's still noticeable+ // against the gear icon despite the small size.+ // Dismissed versions clear it automatically via+ // shouldShowUpdateBanner.<span- className="absolute right-1 top-1 h-2 w-2 rounded-full bg-primary ring-2 ring-muted/50"+ className="absolute right-1 top-1 h-2 w-2 rounded-full bg-red-500 ring-2 ring-muted/50"title={t("nav.updateAvailable")}/>)}</TooltipTrigger><TooltipContent side="right">{t("nav.settings")}- {updateBannerVisible ? t("nav.updateAvailableSuffix") : ""}+ {updateAvailable ? t("nav.updateAvailableSuffix") : ""}</TooltipContent></Tooltip><Tooltip>diff --git a/src/components/layout/update-banner.tsx b/src/components/layout/update-banner.tsxnew file mode 100644index 00000000..711ec9d8--- /dev/null+++ b/src/components/layout/update-banner.tsx@@ -0,0 +1,110 @@+import { useCallback } from "react"+import { Sparkles, X, Download } from "lucide-react"+import { useTranslation } from "react-i18next"+import { openUrl } from "@tauri-apps/plugin-opener"+import { useUpdateStore, shouldShowUpdateBanner } from "@/stores/update-store"+import { saveUpdateCheckState } from "@/lib/project-store"+import { toLatestReleaseUrl } from "@/lib/update-check"++/**+ * App-wide update-available banner.+ *+ * Sits above the main flex row (IconSidebar + content). Renders ONLY+ * when `shouldShowUpdateBanner(state)` returns true — that helper+ * already gates on:+ * - we have a successful "available" check result+ * - the user hasn't dismissed THIS exact remote version+ * so a closed banner stays closed for the dismissed version, and+ * automatically reappears the moment a NEWER release ships+ * (dismissedVersion no longer matches the new remote).+ *+ * Persistence: the X handler writes the dismissed version through+ * `saveUpdateCheckState` so the close decision survives a restart.+ *+ * Why not use the same component as the About-page banner: that one+ * is opt-in (user navigated to settings), so it shows full release+ * notes and a "Later" button. This one is uninvited and must stay+ * compact / single-line so it doesn't disrupt the working layout —+ * just version + one CTA + close.+ */+export function UpdateBanner() {+ const { t } = useTranslation()+ const visible = useUpdateStore((s) => shouldShowUpdateBanner(s))+ const result = useUpdateStore((s) => s.lastResult)++ const handleOpen = useCallback(async () => {+ if (!result || result.kind !== "available") return+ // Send the user to `/releases/latest`, NOT the tag-specific+ // page from `release.html_url`. /latest always follows GitHub's+ // redirect to whatever is currently the most recent release —+ // robust to (a) a newer release shipping between notification+ // and click, and (b) the bare `/releases` listing's default+ // sort not putting newest at the top.+ try {+ await openUrl(toLatestReleaseUrl(result.release.html_url))+ } catch (err) {+ console.error("[update-banner] openUrl failed:", err)+ }+ }, [result])++ const handleDismiss = useCallback(async () => {+ if (!result || result.kind !== "available") return+ // Mark THIS remote version as dismissed; helper hides banner.+ // Future newer releases re-pop because their version doesn't+ // match dismissedVersion anymore. Persist so the choice+ // survives a restart — without that, the banner re-appears+ // every cold start, which is the user complaint we're fixing.+ useUpdateStore.getState().setDismissed(result.remote)+ await saveUpdateCheckState({+ enabled: useUpdateStore.getState().enabled,+ lastCheckedAt: useUpdateStore.getState().lastCheckedAt ?? Date.now(),+ dismissedVersion: result.remote,+ })+ }, [result])++ if (!visible || !result || result.kind !== "available") return null++ return (+ // Visual style notes:+ // - subtle gradient (left primary tint → right transparent) so+ // the eye lands on the icon + text first+ // - thin 1px bottom border separates it from the chrome+ // without screaming at the user+ // - py-2 / px-4 gives a comfortable single-row height (~36px)+ // without dominating the viewport+ // - text-sm at medium weight reads cleanly without feeling+ // promotional+ // - the action button uses bg-primary fill so it's the+ // unambiguous CTA; close button stays ghost so it doesn't+ // compete+ <div className="flex shrink-0 items-center gap-3 border-b border-primary/20 bg-gradient-to-r from-primary/8 via-primary/4 to-transparent px-4 py-2 text-sm">+ <div className="flex min-w-0 flex-1 items-center gap-2.5">+ <div className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/15">+ <Sparkles className="h-3.5 w-3.5 text-primary" />+ </div>+ <span className="truncate font-medium text-foreground">+ {t("updateBanner.message", {+ version: result.remote.replace(/^v/, ""),+ defaultValue: `Version ${result.remote.replace(/^v/, "")} is available`,+ })}+ </span>+ </div>+ <button+ type="button"+ onClick={handleOpen}+ className="inline-flex shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90"+ >+ <Download className="h-3.5 w-3.5" />+ {t("updateBanner.openDownload", { defaultValue: "Open download page" })}+ </button>+ <button+ type="button"+ onClick={handleDismiss}+ aria-label={t("updateBanner.dismiss", { defaultValue: "Dismiss" })}+ className="shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"+ >+ <X className="h-4 w-4" />+ </button>+ </div>+ )+}diff --git a/src/components/settings/sections/about-section.tsx b/src/components/settings/sections/about-section.tsxindex 5622e7ac..bcebf3df 100644--- a/src/components/settings/sections/about-section.tsx+++ b/src/components/settings/sections/about-section.tsx@@ -1,10 +1,11 @@import { useEffect, useState, useCallback } from "react"import { Download, RefreshCw, CheckCircle2, Sparkles } from "lucide-react"import { useTranslation } from "react-i18next"+import { openUrl } from "@tauri-apps/plugin-opener"import { clipServerStatus } from "@/commands/fs"import { Button } from "@/components/ui/button"-import { useUpdateStore, shouldShowUpdateBanner } from "@/stores/update-store"-import { checkForUpdates } from "@/lib/update-check"+import { useUpdateStore, hasAvailableUpdate } from "@/stores/update-store"+import { checkForUpdates, toLatestReleaseUrl } from "@/lib/update-check"import { saveUpdateCheckState } from "@/lib/project-store"export function AboutSection() {@@ -71,7 +72,13 @@ export function AboutSection() {{ label: t("settings.sections.about.clipServer"), value: `${clipStatus} @ 127.0.0.1:19827`, mono: true },]- const showBanner = shouldShowUpdateBanner(updateStore)+ // About panel = user-initiated navigation. They came here on+ // purpose (often guided by the gear / About red dot) and expect+ // to see WHY the dot is there. So this surface ignores the+ // user's "dismiss" preference — that preference only suppresses+ // the unrequested TOP banner. Within Settings, an available+ // update is always shown in detail.+ const showAvailable = hasAvailableUpdate(updateStore)const lastCheckFailed = updateStore.lastResult?.kind === "error"const lastCheckedLabel = updateStore.lastCheckedAt? lastCheckFailed@@ -126,7 +133,7 @@ export function AboutSection() {</Button></div>- {showBanner && updateStore.lastResult?.kind === "available" && (+ {showAvailable && updateStore.lastResult?.kind === "available" && (<UpdateAvailableBannerremote={updateStore.lastResult.remote}releaseUrl={updateStore.lastResult.release.html_url}@@ -136,7 +143,7 @@ export function AboutSection() {/>)}- {!showBanner && updateStore.lastResult?.kind === "up-to-date" && (+ {!showAvailable && updateStore.lastResult?.kind === "up-to-date" && (<div className="flex items-center gap-2 rounded border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-400"><CheckCircle2 className="h-4 w-4 shrink-0" />{t("settings.sections.about.upToDate", { version: updateStore.lastResult.local })}@@ -165,11 +172,23 @@ export function AboutSection() {<p className="mt-1 text-xs text-muted-foreground">{t("settings.sections.about.appDescription")}{" "}+ {/*+ * Tauri 2's webview doesn't honor `target="_blank"` for+ * external URLs by default — clicking would either do+ * nothing or replace the in-app webview with the github+ * page (terrible UX). Route through the opener plugin+ * via onClick + preventDefault so it always lands in the+ * system browser.+ */}<a- className="underline underline-offset-2 hover:text-primary"+ className="cursor-pointer underline underline-offset-2 hover:text-primary"href="https://github.com/nashsu/llm_wiki"- target="_blank"- rel="noreferrer"+ onClick={(e) => {+ e.preventDefault()+ void openUrl("https://github.com/nashsu/llm_wiki").catch((err) => {+ console.error("[about] openUrl failed:", err)+ })+ }}>github.com/nashsu/llm_wiki</a>@@ -195,11 +214,35 @@ function UpdateAvailableBanner({onDismiss,}: UpdateAvailableBannerProps) {const { t } = useTranslation()- const handleOpen = () => {- // window.open with target=_blank delegates to the system browser- // in Tauri via the opener plugin registered in src-tauri/src/lib.rs.- // Works identically in a regular browser during dev mode.- window.open(releaseUrl, "_blank", "noopener,noreferrer")+ // Use `/releases/latest` (canonical GitHub redirect to the newest+ // release) rather than the tag-specific URL from the release+ // payload. Same rationale as in the top banner — see+ // `toLatestReleaseUrl` for details.+ const targetUrl = toLatestReleaseUrl(releaseUrl)+ const handleOpen = async () => {+ // Tauri 2's webview does NOT auto-delegate `window.open()` to the+ // system browser — `tauri-plugin-opener` is the official way to+ // launch the user's default browser. The Rust plugin is+ // registered in `src-tauri/src/lib.rs` and `opener:default`+ // permission is granted in capabilities/default.json.+ //+ // Fail-soft: if the plugin call rejects (e.g. URL blocked by a+ // future capability tightening), fall back to copying the URL+ // to the clipboard so the user can paste it into a browser+ // manually instead of seeing a silently broken button.+ try {+ await openUrl(targetUrl)+ } catch (err) {+ console.error("[update-banner] openUrl failed:", err)+ try {+ await navigator.clipboard.writeText(targetUrl)+ // eslint-disable-next-line no-alert+ alert(`Could not open browser. URL copied to clipboard:\n${targetUrl}`)+ } catch {+ // eslint-disable-next-line no-alert+ alert(`Could not open browser. Visit:\n${targetUrl}`)+ }+ }}const preview = releaseBody.slice(0, 400)diff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsxindex f28b708d..a4e0271c 100644--- a/src/components/settings/settings-view.tsx+++ b/src/components/settings/settings-view.tsx@@ -13,6 +13,7 @@ import i18n from "@/i18n"import { Button } from "@/components/ui/button"import { useWikiStore } from "@/stores/wiki-store"import { useChatStore } from "@/stores/chat-store"+import { useUpdateStore, hasAvailableUpdate } from "@/stores/update-store"import { saveLanguage } from "@/lib/project-store"import type { SettingsDraft, DraftSetter } from "./settings-types"import { LlmProviderSection } from "./sections/llm-provider-section"@@ -105,6 +106,15 @@ export function SettingsView() {const setOutputLanguage = useWikiStore((s) => s.setOutputLanguage)const maxHistoryMessages = useChatStore((s) => s.maxHistoryMessages)const setMaxHistoryMessages = useChatStore((s) => s.setMaxHistoryMessages)+ // Drives the red dot next to the "About" row in the settings+ // sidebar. Uses `hasAvailableUpdate` (NOT `shouldShowUpdateBanner`)+ // so the indicator remains even after the user dismisses the+ // top banner — the user explicitly asked for the gear/About dots+ // to keep showing as a signpost so they can find the update+ // again later. The top banner stays gated by the dismiss+ // preference so the more aggressive interruption only fires once+ // per version.+ const updateAvailable = useUpdateStore((s) => hasAvailableUpdate(s))const [active, setActive] = useState<CategoryId>("llm")const [saved, setSaved] = useState(false)@@ -254,6 +264,14 @@ export function SettingsView() {{CATEGORIES.map((c) => {const Icon = c.iconconst isActive = c.id === active+ // Mirror the gear-icon dot inside the settings sidebar+ // so the user can find which sub-section the update+ // notification is pointing at. Update info lives in+ // the About panel, so the dot follows the About row.+ // Same store, same gating — once dismissed, both+ // disappear together.+ const showUpdateDot =+ c.id === "about" && updateAvailablereturn (<buttonkey={c.id}@@ -272,6 +290,13 @@ export function SettingsView() {}`}/><span className="truncate">{t(c.labelKey)}</span>+ {showUpdateDot && (+ <span+ className="ml-auto h-2 w-2 shrink-0 rounded-full bg-red-500"+ aria-label={t("nav.updateAvailable")}+ title={t("nav.updateAvailable")}+ />+ )}</button>)})}diff --git a/src/i18n/en.json b/src/i18n/en.jsonindex 4e5b8ca4..4febb40e 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -15,6 +15,11 @@"updateAvailable": "Update available","updateAvailableSuffix": " · update"},+ "updateBanner": {+ "message": "Version {{version}} is available",+ "openDownload": "Open download page",+ "dismiss": "Dismiss"+ },"welcome": {"newProject": "New Project","openProject": "Open Project",diff --git a/src/i18n/zh.json b/src/i18n/zh.jsonindex 28815f10..2db739c4 100644--- a/src/i18n/zh.json+++ b/src/i18n/zh.json@@ -15,6 +15,11 @@"updateAvailable": "有可用更新","updateAvailableSuffix": " · 有更新"},+ "updateBanner": {+ "message": "新版本 {{version}} 已发布",+ "openDownload": "打开下载页",+ "dismiss": "关闭"+ },"welcome": {"newProject": "新建项目","openProject": "打开项目",diff --git a/src/lib/update-check.test.ts b/src/lib/update-check.test.tsindex 95f0b098..f37b677b 100644--- a/src/lib/update-check.test.ts+++ b/src/lib/update-check.test.ts@@ -4,7 +4,7 @@* fetch layer — we don't exercise it against real GitHub in CI.*/import { describe, it, expect } from "vitest"-import { isNewer } from "./update-check"+import { isNewer, toLatestReleaseUrl } from "./update-check"describe("isNewer — semver comparison", () => {it("remote > local on patch", () => {@@ -67,3 +67,56 @@ describe("isNewer — semver comparison", () => {expect(isNewer("0.3.9", "")).toBe(true)})})++describe("toLatestReleaseUrl — canonical /releases/latest mapping", () => {+ it("converts a tag-specific release URL to /releases/latest", () => {+ expect(+ toLatestReleaseUrl("https://github.com/nashsu/llm_wiki/releases/tag/v0.4.0"),+ ).toBe("https://github.com/nashsu/llm_wiki/releases/latest")+ })++ it("normalizes a bare /releases listing URL to /releases/latest", () => {+ expect(+ toLatestReleaseUrl("https://github.com/nashsu/llm_wiki/releases"),+ ).toBe("https://github.com/nashsu/llm_wiki/releases/latest")+ })++ it("is idempotent on an already-/latest URL", () => {+ expect(+ toLatestReleaseUrl("https://github.com/nashsu/llm_wiki/releases/latest"),+ ).toBe("https://github.com/nashsu/llm_wiki/releases/latest")+ })++ it("works for any owner/repo combination", () => {+ expect(+ toLatestReleaseUrl("https://github.com/octocat/Hello-World/releases/tag/v3.2.1"),+ ).toBe("https://github.com/octocat/Hello-World/releases/latest")+ })++ it("accepts http (not just https) and case-insensitive github.com", () => {+ // The regex is case-insensitive on the host part — paranoia for+ // capitalization mishaps in user-edited config. Body of the URL+ // (owner/repo) is preserved verbatim.+ expect(+ toLatestReleaseUrl("http://GitHub.com/foo/bar/releases/tag/v1.0"),+ ).toBe("http://GitHub.com/foo/bar/releases/latest")+ })++ it("falls through unchanged for non-GitHub URLs (don't break random links)", () => {+ expect(toLatestReleaseUrl("https://example.com/releases/tag/v1.0")).toBe(+ "https://example.com/releases/tag/v1.0",+ )+ expect(toLatestReleaseUrl("https://gitlab.com/foo/bar/-/releases")).toBe(+ "https://gitlab.com/foo/bar/-/releases",+ )+ })++ it("falls through unchanged for non-release github URLs", () => {+ expect(toLatestReleaseUrl("https://github.com/nashsu/llm_wiki/issues/42")).toBe(+ "https://github.com/nashsu/llm_wiki/issues/42",+ )+ expect(toLatestReleaseUrl("https://github.com/nashsu/llm_wiki")).toBe(+ "https://github.com/nashsu/llm_wiki",+ )+ })+})diff --git a/src/lib/update-check.ts b/src/lib/update-check.tsindex 7e65d51e..f0e8dff8 100644--- a/src/lib/update-check.ts+++ b/src/lib/update-check.ts@@ -17,6 +17,34 @@import { getHttpFetch, isFetchNetworkError } from "./tauri-fetch"/** The subset of the GitHub release API response we care about. */+/**+ * Map any GitHub release-related URL to that repo's+ * `/releases/latest` form. Two reasons we prefer the canonical+ * `/latest` URL over the API-returned `html_url`:+ *+ * - `html_url` for a release object is `/releases/tag/<tag>`+ * (tag-specific). If a newer release ships between when we+ * notified the user and when they click, sending them to the+ * tag page gives them a stale view; `/releases/latest` always+ * follows GitHub's redirect to whatever is genuinely latest.+ *+ * - The bare `/releases` listing URL (sometimes used as a stub)+ * shows a paginated list whose default sort isn't strictly+ * "newest first" once a repo has many releases — the user+ * might land on the page and not see the new version above+ * the fold.+ *+ * Idempotent: passing an already-`/latest` URL returns it+ * unchanged. Falls through with the original URL when the input+ * doesn't look like a github.com release link (don't break random+ * external URLs).+ */+export function toLatestReleaseUrl(htmlUrl: string): string {+ const m = htmlUrl.match(/^(https?:\/\/github\.com\/[^/]+\/[^/]+)\/releases(?:\/.*)?$/i)+ if (!m) return htmlUrl+ return `${m[1]}/releases/latest`+}+export interface GithubRelease {tag_name: string // e.g. "v0.3.10"name: string // display title@@ -139,4 +167,10 @@ export async function checkForUpdates(opts: {}/** Cache duration: don't re-hit the API if we checked more recently than this. */-export const UPDATE_CHECK_CACHE_MS = 6 * 60 * 60 * 1000 // 6 hours+// 1 hour cache between background checks. Originally 6h, shortened+// because users were going long stretches without learning about+// new releases. GitHub's anonymous /releases/latest endpoint allows+// 60 req/hour from the same IP, so even a user opening / closing+// the app dozens of times in an hour stays well under the limit+// (the cache itself prevents back-to-back hits within the window).+export const UPDATE_CHECK_CACHE_MS = 60 * 60 * 1000 // 1 hourdiff --git a/src/stores/update-store.ts b/src/stores/update-store.tsindex bc2627ca..00d4b244 100644--- a/src/stores/update-store.ts+++ b/src/stores/update-store.ts@@ -47,15 +47,40 @@ export const useUpdateStore = create<UpdateStoreState>((set) => ({}))/**- * Helper the UI uses to decide whether to show the "update available"- * surface. Suppresses the surface when the user has explicitly- * dismissed this exact version; reappears naturally when a newer one- * ships because `dismissedVersion` no longer matches `result.remote`.+ * Whether an update is available, IGNORING the user's dismiss+ * preference. Used by passive indicators (the red dot on the+ * Settings gear, the red dot next to the About row in Settings)+ * that should keep nudging the user toward the update — those+ * surfaces are the canonical "where do I find this" signposts,+ * not pressure to act NOW.+ *+ * Returns true iff the latest check finished with kind="available".*/-export function shouldShowUpdateBanner(state: UpdateStoreState): boolean {+export function hasAvailableUpdate(state: UpdateStoreState): boolean {if (!state.lastResult) return false- if (state.lastResult.kind !== "available") return false- if (state.dismissedVersion && state.dismissedVersion === state.lastResult.remote) {+ return state.lastResult.kind === "available"+}++/**+ * Whether the FULL banner (with download CTA + dismiss button) at+ * the top of the app should be shown. Stricter than+ * `hasAvailableUpdate`: ALSO suppresses when the user has+ * dismissed this exact version. Re-appears naturally when a newer+ * release ships because `dismissedVersion` no longer matches+ * `result.remote`.+ *+ * Banner = active interruption; dots = passive presence. Splitting+ * the gates lets dismissing the banner stop the interruption+ * without hiding the way to the update.+ */+export function shouldShowUpdateBanner(state: UpdateStoreState): boolean {+ if (!hasAvailableUpdate(state)) return false+ // `hasAvailableUpdate` already proved kind === "available", so we+ // can narrow safely here. Type-narrow inside the branch rather+ // than using `as` so a future refactor of UpdateStatus would+ // catch up the gating logic too.+ if (state.lastResult?.kind !== "available") return false+ if (state.dismissedVersion === state.lastResult.remote) {return false}return true