From fdc517dcee6776fb4adcb5bd4445d09aaecdcb1d Mon Sep 17 00:00:00 2001 From: Haren Daishika Date: Tue, 24 Nov 2026 19:23:10 +0530 Subject: [PATCH 1/2] Desktop: the app updates itself on Windows (D38) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Once a day, and from Help, Check for Updates…, the app asks GitHub for the latest release, naming itself and its version and sending nothing else. A newer version shows "Update to …" in the title bar, with what is new, Update and restart, Later, and Skip this version. Help, Check for Updates Automatically turns the daily check off; About says when it last ran. Update and restart, where Setup installed the app, downloads the release's installer, checks its SHA-256 against the release's checksums.txt and deletes it on a mismatch, saves the tabs, starts Setup silently with /relaunch=yes, and closes. Setup's new [Run] line opens the new version only when /relaunch=yes is passed, so Setup run by hand is unchanged. A copy not installed by Setup, and macOS and Linux, offer the download page. internal/sources/github is the one place the app talks to GitHub; internal/update compares versions, cleans the release notes, downloads, checks and starts Setup. The website's install page gains Updating the app, and the home page and README mention Reader tabs and updating. --- README.md | 2 +- desktop/installer/filiation.iss | 10 + desktop/main.go | 28 ++ docs/DECISIONS.md | 32 +++ docs/STATUS.md | 2 +- internal/sources/github/github.go | 215 +++++++++++++++ internal/sources/github/github_test.go | 100 +++++++ internal/ui/assets/app.css | 11 + internal/ui/assets/index.html | 2 + internal/ui/assets/start.js | 2 +- internal/ui/assets/titlebar.js | 8 +- internal/ui/assets/updates.js | 218 ++++++++++++++++ internal/ui/menus.go | 3 + internal/ui/ui.go | 10 + internal/ui/update.go | 75 ++++++ internal/ui/update_test.go | 82 ++++++ internal/update/update.go | 347 +++++++++++++++++++++++++ internal/update/update_test.go | 187 +++++++++++++ site/assets/docs-index.json | 2 +- site/assets/home.js | 4 +- site/docs/install/index.html | 4 + site/index.html | 4 +- site/tools/docs/install.html | 3 + 23 files changed, 1341 insertions(+), 10 deletions(-) create mode 100644 internal/sources/github/github.go create mode 100644 internal/sources/github/github_test.go create mode 100644 internal/ui/assets/updates.js create mode 100644 internal/ui/update.go create mode 100644 internal/ui/update_test.go create mode 100644 internal/update/update.go create mode 100644 internal/update/update_test.go diff --git a/README.md b/README.md index aaaf50b..f319756 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ ### Use the app -A desktop window for Windows, macOS and Linux, for people who would rather not use a terminal: your papers, search, the citation map, the Reader with highlights and notes, and connecting your AI assistant with one click. +A desktop window for Windows, macOS and Linux, for people who would rather not use a terminal: your papers, search, the citation map, the Reader with highlights, notes and several papers open in tabs, and connecting your AI assistant with one click. On Windows it keeps itself up to date. The app arrives in the next release. Until then it builds from source: see [the desktop app](desktop/README.md). diff --git a/desktop/installer/filiation.iss b/desktop/installer/filiation.iss index 891d5a0..31670f8 100644 --- a/desktop/installer/filiation.iss +++ b/desktop/installer/filiation.iss @@ -77,11 +77,21 @@ Name: "{autodesktop}\Filiation"; Filename: "{app}\Filiation.exe"; IconFilename: [Run] Filename: "{app}\Filiation.exe"; Description: "Open Filiation"; Flags: nowait postinstall skipifsilent +; The app updating itself runs Setup silently with /relaunch=yes, and the new +; version opens when it is done (D38). Run by hand, Setup is unchanged. +Filename: "{app}\Filiation.exe"; Flags: nowait; Check: Relaunch [Code] const EnvKey = 'Environment'; +// Relaunch says whether to open the new version when Setup is done: only +// when the app ran Setup silently to update itself. +function Relaunch: Boolean; +begin + Result := WizardSilent and (CompareText(ExpandConstant('{param:relaunch|no}'), 'yes') = 0); +end; + // onPath says whether dir is one of the entries of the user's PATH. function OnPath(Dir: string): Boolean; var diff --git a/desktop/main.go b/desktop/main.go index 741bdb2..12cfbbb 100644 --- a/desktop/main.go +++ b/desktop/main.go @@ -27,12 +27,33 @@ import ( "github.com/codevector-2003/filiation/internal/assistants" "github.com/codevector-2003/filiation/internal/config" "github.com/codevector-2003/filiation/internal/opener" + "github.com/codevector-2003/filiation/internal/sources/github" "github.com/codevector-2003/filiation/internal/ui" + "github.com/codevector-2003/filiation/internal/update" ) // version is set at release with -ldflags "-X main.version=…". var version = "dev" +// updateAPI is where releases are asked for: GitHub, or for a test build +// only, a stand-in set with -ldflags "-X main.updateAPI=…". +var updateAPI = github.DefaultBase + +// installedBySetup says whether this copy can update itself: on Windows, +// installed by Setup, whose uninstaller sits beside it. A copy built or +// unpacked by hand is offered the download page instead (D38). +func installedBySetup() bool { + if runtime.GOOS != "windows" { + return false + } + exe, err := os.Executable() + if err != nil { + return false + } + _, err = os.Stat(filepath.Join(filepath.Dir(exe), "unins000.exe")) + return err == nil +} + func main() { opts := ui.Options{OpenPath: opener.Open, Trash: opener.Trash, Version: version} if env, err := assistants.DefaultEnv(filCommand()); err == nil { @@ -40,6 +61,13 @@ func main() { } if dir, err := config.DefaultCacheDir(); err == nil { opts.CallLog = filepath.Join(dir, assistants.CallLogName) + opts.Updater = &update.Updater{ + Current: version, + Source: &github.Client{Base: updateAPI, UserAgent: "Filiation/" + version}, + Dir: filepath.Join(dir, "updates"), + CanInstall: installedBySetup(), + Arch: runtime.GOARCH, + } } var appCtx context.Context opts.PickFiles = func() ([]string, error) { diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 94f9a9a..ede4347 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -963,3 +963,35 @@ request's desktop build. shortcuts and the uninstall entry. The exe itself has no icon resource yet. - Windows first: a macOS `.dmg` and Linux AppImage and `.deb` follow, as does a first-run welcome in the app and a check for new versions. + +## D38 — The app updates itself on Windows, from GitHub releases + +Decided 24 Nov 2026, by the maintainer. Until now a new version meant downloading the installer +from the website and running it. The app now asks for the latest release once a day, and on +Windows installs it when asked. + +- **One request, to GitHub, and nothing in it.** `internal/sources/github` asks the releases API + for the latest release, with a `Filiation/` User-Agent and nothing else: no email, no + library, no papers. The answer is the version, its date, its notes and its files. +- **Once a day, and on request.** The page checks at start, and while it stays open once a day has + passed, and says nothing unless there is a newer version that was not skipped. Help, Check for + Updates… always answers. Help, Check for Updates Automatically turns the daily check off. About + says when it last ran and what it sends. +- **A note, never a pop-up.** A newer version shows "Update to 0.4.4" in the title bar, where jobs + show. Its panel gives what is new, from GoReleaser's changelog without the commit hashes, and + Update and restart, Later, or Skip this version. +- **Installed only when Setup installed the app.** `internal/update` downloads the release's + installer to `%LOCALAPPDATA%\filiation\updates`, checks its SHA-256 against the release's + `checksums.txt`, and deletes it rather than run it on a mismatch. The page saves its tabs, the + installer is started with `/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /CLOSEAPPLICATIONS + /relaunch=yes`, and the app quits. Setup replaces it, per user and with no administrator prompt + (D37), and its new `[Run]` line opens the new version only when `/relaunch=yes` was passed, so + Setup run by hand is unchanged. +- **Elsewhere, the download page.** A copy not installed by Setup (no `unins000.exe` beside it), + and the app on macOS and Linux, which have no installer yet, offer the release page instead. A + development build is never offered an update. +- **Trust rests on GitHub and the checksum.** The installer and its checksums come from the same + release, so the check catches a broken or partial download, not a compromised release; signing + the installer (D37) is what would add that. +- **Every version before this one updates by hand once.** The feature exists only from the version + that ships it. diff --git a/docs/STATUS.md b/docs/STATUS.md index b18927a..7e76527 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -33,7 +33,7 @@ protected for them. | 2 | M2 — MCP server | **Complete** — 25 Sept, released as v0.2 | | 3 | M3 — fil IDs, library folder, PDFs, text, citation context, FTS5 | **Complete** — 30 Oct, released as v0.3 ([`ARCHITECTURE_PHASE3.md`](ARCHITECTURE_PHASE3.md)) | | 4 | M4 — retrieval (was "retrieval and answers"; D35) | **Complete** — 18 Nov, checked across five fields and at 39,000 passages (`VALIDATION.md`). 15 Nov: a retrieval test set first (`eval/retrieval`, 20 working and 20 locked questions). Spike 14 measured meaning search inside fil (pure Go: 10 of 20, 44 min to embed) and through Ollama (15 of 20, a 3.2 GB install); neither is built. fil writes no answers either: the user's assistant does, over MCP (D35). Instead search leaves out filler words and ranks papers by their best passages fused with title and abstract (schema v15): 13 → 15 of 20 in the first three on the working set (MRR 0.60 → 0.73), 15 of 20 on the locked set (MRR 0.60 → 0.68). The AI assistants screen shows its call log again (#35) | -| 5 | M5 — the desktop app (was "web interface"; D24) | **In progress** — the shell is Wails v2, in the same process (spike 13, D25); the desktop app comes first and the browser version later (D26). 2 Nov: `desktop/` opens a real window with the Library, Search, Citation map, Inbox and AI assistants screens, and the Reader with notes. The Papers list reaches the whole library, with sorting and filters by year, author and venue. The Citation map shows the whole library on one screen as well as the map around a paper. 3 Nov: Favourites, collections inside collections, and coloured labels, with several papers picked at once, a right-click menu and dragging (schema v11, D28). Bringing in a Zotero library through its local API, read-only, from the Inbox or `fil zotero` (schema v12, D29), or from a Zotero RDF export (`fil zotero --from`). Your own documents can be matched to OpenAlex afterwards, by an identifier or by choosing from a title search (`fil match`). The window has no frame on Windows: the page draws a title bar with File, Edit, View, Library, Go, Paper and Help menus, keyboard shortcuts, and a library switcher, and libraries can be made, opened, switched, moved and closed while the app runs (D30). 4 Nov: a paper's PDF can be downloaded from its page, and the papers one citation step from it, what it cites and what cites it, brought in without growing the rest of the library (D31). The paper shows its abstract. The citation map sizes papers by citations here or worldwide and filters them by citations, year, PDF and your own papers, fading or hiding the rest; a paper with no legal copy takes a PDF you have (D32). 6 Nov: Search takes the Papers list's filters, applied before the best passages are chosen, and the list's filters can be saved as views in the sidebar that update themselves (schema v13, D33). 7 Nov: citation groups, the library's topics found from its citations alone by Louvain clustering, suggested in the sidebar, on the Papers list and on the citation map, and made into collections only when asked; `fil groups` and the `citation_groups` tool (schema v14, D34). 19 Nov: search moved into the title bar and the Papers list shows one row per paper; papers can be deleted, their folders to the system's bin, remembered so that expanding does not bring them back (schema v16, D36). 24 Nov: Reader tabs. Several papers stay open at once, one tab each, after a Library tab that holds the side menu and every other screen. Each tab keeps its page, zoom, side panel and find words; a citation on the page opens beside the paper it is cited in; Ctrl+Tab, Ctrl+W and Ctrl+Shift+T in the Go menu. The tabs are kept in the library's meta table, with no schema change, so a library opened again shows its own papers where they were left; only the four tabs seen last keep their PDF open | +| 5 | M5 — the desktop app (was "web interface"; D24) | **In progress** — the shell is Wails v2, in the same process (spike 13, D25); the desktop app comes first and the browser version later (D26). 2 Nov: `desktop/` opens a real window with the Library, Search, Citation map, Inbox and AI assistants screens, and the Reader with notes. The Papers list reaches the whole library, with sorting and filters by year, author and venue. The Citation map shows the whole library on one screen as well as the map around a paper. 3 Nov: Favourites, collections inside collections, and coloured labels, with several papers picked at once, a right-click menu and dragging (schema v11, D28). Bringing in a Zotero library through its local API, read-only, from the Inbox or `fil zotero` (schema v12, D29), or from a Zotero RDF export (`fil zotero --from`). Your own documents can be matched to OpenAlex afterwards, by an identifier or by choosing from a title search (`fil match`). The window has no frame on Windows: the page draws a title bar with File, Edit, View, Library, Go, Paper and Help menus, keyboard shortcuts, and a library switcher, and libraries can be made, opened, switched, moved and closed while the app runs (D30). 4 Nov: a paper's PDF can be downloaded from its page, and the papers one citation step from it, what it cites and what cites it, brought in without growing the rest of the library (D31). The paper shows its abstract. The citation map sizes papers by citations here or worldwide and filters them by citations, year, PDF and your own papers, fading or hiding the rest; a paper with no legal copy takes a PDF you have (D32). 6 Nov: Search takes the Papers list's filters, applied before the best passages are chosen, and the list's filters can be saved as views in the sidebar that update themselves (schema v13, D33). 7 Nov: citation groups, the library's topics found from its citations alone by Louvain clustering, suggested in the sidebar, on the Papers list and on the citation map, and made into collections only when asked; `fil groups` and the `citation_groups` tool (schema v14, D34). 19 Nov: search moved into the title bar and the Papers list shows one row per paper; papers can be deleted, their folders to the system's bin, remembered so that expanding does not bring them back (schema v16, D36). 24 Nov: Reader tabs. Several papers stay open at once, one tab each, after a Library tab that holds the side menu and every other screen. Each tab keeps its page, zoom, side panel and find words; a citation on the page opens beside the paper it is cited in; Ctrl+Tab, Ctrl+W and Ctrl+Shift+T in the Go menu. The tabs are kept in the library's meta table, with no schema change, so a library opened again shows its own papers where they were left; only the four tabs seen last keep their PDF open. The app updates itself on Windows: once a day it asks GitHub for the latest release, shows a note in the title bar, and Update and restart downloads the installer, checks its SHA-256 against the release's checksums, and lets Setup install it silently and reopen the app; elsewhere it offers the download page (D38) | | 6 | M6 — claim genealogy | Not started | --- diff --git a/internal/sources/github/github.go b/internal/sources/github/github.go new file mode 100644 index 0000000..777187c --- /dev/null +++ b/internal/sources/github/github.go @@ -0,0 +1,215 @@ +// Package github asks GitHub which release of Filiation is the latest, and +// downloads that release's files. It is the one place the app talks to +// GitHub (D38), so the rules live here: +// +// - a request names the app and its version in the User-Agent, and carries +// nothing else: no email, no library, nothing about the person; +// - asking for the latest release has a short timeout, so a slow network +// never holds up the window; +// - a file is streamed to the writer it is given, never held in memory, and +// refused past a size no release of ours comes near. +package github + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "strings" + "time" +) + +// DefaultBase is GitHub's API. +const DefaultBase = "https://api.github.com" + +// Repo is where Filiation's releases are published. +const Repo = "codevector-2003/filiation" + +const ( + askTimeout = 10 * time.Second + maxFile = 500 << 20 // the installer is about 60 MB + maxText = 1 << 20 // checksums.txt +) + +// ErrOffline is a request that never reached GitHub: no network, or a name +// that did not resolve. +var ErrOffline = errors.New("github: could not reach GitHub") + +// Release is one published release. +type Release struct { + Tag string // v0.4.4 + Version string // 0.4.4 + Published time.Time // when it was published + Notes string // its description, as written on GitHub + Page string // its page on github.com + Assets []Asset // the files attached to it +} + +// Asset is one file attached to a release. +type Asset struct { + Name string + URL string // where to download it + Size int64 +} + +// Asset returns the file of that name, if the release has one. +func (r Release) Asset(name string) (Asset, bool) { + for _, a := range r.Assets { + if a.Name == name { + return a, true + } + } + return Asset{}, false +} + +// Client talks to GitHub. +type Client struct { + Base string // the API; DefaultBase when empty + Repo string // owner/name; Repo when empty + UserAgent string // "Filiation/0.4.3" + HTTP *http.Client // http.DefaultClient when nil +} + +func (c *Client) http() *http.Client { + if c.HTTP != nil { + return c.HTTP + } + return http.DefaultClient +} + +func (c *Client) get(ctx context.Context, url, accept string) (*http.Response, error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + if err != nil { + return nil, err + } + ua := c.UserAgent + if ua == "" { + ua = "Filiation" + } + req.Header.Set("User-Agent", ua) + if accept != "" { + req.Header.Set("Accept", accept) + } + res, err := c.http().Do(req) + if err != nil { + if ctx.Err() != nil { + return nil, ctx.Err() + } + return nil, fmt.Errorf("%w: %v", ErrOffline, err) + } + if res.StatusCode != http.StatusOK { + res.Body.Close() + return nil, fmt.Errorf("github: %s answered %s", url, res.Status) + } + return res, nil +} + +// Latest returns the latest published release: not a draft, not a +// pre-release, as GitHub decides. +func (c *Client) Latest(ctx context.Context) (Release, error) { + ctx, cancel := context.WithTimeout(ctx, askTimeout) + defer cancel() + base, repo := c.Base, c.Repo + if base == "" { + base = DefaultBase + } + if repo == "" { + repo = Repo + } + res, err := c.get(ctx, strings.TrimRight(base, "/")+"/repos/"+repo+"/releases/latest", "application/vnd.github+json") + if err != nil { + return Release{}, err + } + defer res.Body.Close() + var raw struct { + Tag string `json:"tag_name"` + Body string `json:"body"` + Page string `json:"html_url"` + Published time.Time `json:"published_at"` + Assets []struct { + Name string `json:"name"` + URL string `json:"browser_download_url"` + Size int64 `json:"size"` + } `json:"assets"` + } + if err := json.NewDecoder(io.LimitReader(res.Body, maxText)).Decode(&raw); err != nil { + return Release{}, fmt.Errorf("github: read the latest release: %w", err) + } + if raw.Tag == "" { + return Release{}, errors.New("github: the latest release has no tag") + } + r := Release{Tag: raw.Tag, Version: strings.TrimPrefix(raw.Tag, "v"), Published: raw.Published, Notes: raw.Body, Page: raw.Page} + for _, a := range raw.Assets { + r.Assets = append(r.Assets, Asset{Name: a.Name, URL: a.URL, Size: a.Size}) + } + return r, nil +} + +// Text downloads a small text file, such as checksums.txt. +func (c *Client) Text(ctx context.Context, a Asset) (string, error) { + ctx, cancel := context.WithTimeout(ctx, askTimeout) + defer cancel() + res, err := c.get(ctx, a.URL, "") + if err != nil { + return "", err + } + defer res.Body.Close() + b, err := io.ReadAll(io.LimitReader(res.Body, maxText+1)) + if err != nil { + return "", fmt.Errorf("github: download %s: %w", a.Name, err) + } + if len(b) > maxText { + return "", fmt.Errorf("github: %s is far larger than expected", a.Name) + } + return string(b), nil +} + +// Download streams a file to w, telling progress how much has arrived of +// how much, as it goes. The release's own figure for the file's size is the +// one it must reach; the server's is used only when the release has none. +func (c *Client) Download(ctx context.Context, a Asset, w io.Writer, progress func(done, total int64)) error { + res, err := c.get(ctx, a.URL, "application/octet-stream") + if err != nil { + return err + } + defer res.Body.Close() + total := a.Size + if total <= 0 { + total = res.ContentLength + } + if total > maxFile { + return fmt.Errorf("github: %s is far larger than expected", a.Name) + } + var done int64 + buf := make([]byte, 64<<10) + for { + n, err := res.Body.Read(buf) + if n > 0 { + done += int64(n) + if done > maxFile { + return fmt.Errorf("github: %s is far larger than expected", a.Name) + } + if _, werr := w.Write(buf[:n]); werr != nil { + return werr + } + if progress != nil { + progress(done, total) + } + } + if errors.Is(err, io.EOF) { + break + } + if err != nil { + if ctx.Err() != nil { + return ctx.Err() + } + return fmt.Errorf("%w: the download stopped: %v", ErrOffline, err) + } + } + if total > 0 && done != total { + return fmt.Errorf("github: %s stopped at %d of %d bytes", a.Name, done, total) + } + return nil +} diff --git a/internal/sources/github/github_test.go b/internal/sources/github/github_test.go new file mode 100644 index 0000000..a573b49 --- /dev/null +++ b/internal/sources/github/github_test.go @@ -0,0 +1,100 @@ +package github + +import ( + "bytes" + "errors" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +const latestJSON = `{ + "tag_name": "v0.4.4", + "body": "notes", + "html_url": "https://github.com/codevector-2003/filiation/releases/tag/v0.4.4", + "published_at": "2026-12-02T10:00:00Z", + "assets": [ + {"name": "checksums.txt", "browser_download_url": "%s/files/checksums.txt", "size": 12}, + {"name": "Filiation-Setup-0.4.4-windows-amd64.exe", "browser_download_url": "%s/files/setup.exe", "size": 11} + ] +}` + +func fakeGitHub(t *testing.T) (*httptest.Server, *[]string) { + t.Helper() + var agents []string + var srv *httptest.Server + srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + agents = append(agents, r.Header.Get("User-Agent")) + switch r.URL.Path { + case "/repos/codevector-2003/filiation/releases/latest": + w.Write([]byte(strings.ReplaceAll(latestJSON, "%s", srv.URL))) + case "/files/checksums.txt": + w.Write([]byte("abc setup.exe\n")) + case "/files/setup.exe": + w.Write([]byte("hello setup")) + default: + http.NotFound(w, r) + } + })) + t.Cleanup(srv.Close) + return srv, &agents +} + +func TestLatestAndDownload(t *testing.T) { + srv, agents := fakeGitHub(t) + c := &Client{Base: srv.URL, UserAgent: "Filiation/0.4.3"} + ctx := t.Context() + + r, err := c.Latest(ctx) + if err != nil { + t.Fatal(err) + } + if r.Version != "0.4.4" || r.Tag != "v0.4.4" || r.Notes != "notes" || r.Published.Year() != 2026 || len(r.Assets) != 2 { + t.Fatalf("latest = %+v", r) + } + setup, ok := r.Asset("Filiation-Setup-0.4.4-windows-amd64.exe") + if !ok { + t.Fatal("no installer among the assets") + } + sums, _ := r.Asset("checksums.txt") + if text, err := c.Text(ctx, sums); err != nil || text != "abc setup.exe\n" { + t.Fatalf("checksums = %q, %v", text, err) + } + var got bytes.Buffer + var last [2]int64 + if err := c.Download(ctx, setup, &got, func(done, total int64) { last = [2]int64{done, total} }); err != nil { + t.Fatal(err) + } + if got.String() != "hello setup" || last != [2]int64{11, 11} { + t.Fatalf("downloaded %q, last progress %v", got.String(), last) + } + for _, ua := range *agents { + if ua != "Filiation/0.4.3" { + t.Errorf("a request sent User-Agent %q, want only the app and its version", ua) + } + } +} + +func TestDownloadRefusesAShortFile(t *testing.T) { + srv, _ := fakeGitHub(t) + c := &Client{Base: srv.URL} + // The release says 11 bytes; a server that sends no length and stops + // early must not pass for a finished download. + short := Asset{Name: "setup.exe", URL: srv.URL + "/files/checksums.txt", Size: 99} + var buf bytes.Buffer + if err := c.Download(t.Context(), short, &buf, nil); err == nil { + t.Fatal("a file shorter than it should be was taken as complete") + } +} + +func TestOffline(t *testing.T) { + c := &Client{Base: "http://127.0.0.1:1"} // nothing listens on port 1 + if _, err := c.Latest(t.Context()); !errors.Is(err, ErrOffline) { + t.Fatalf("no server: %v, want ErrOffline", err) + } + srv, _ := fakeGitHub(t) + if _, err := (&Client{Base: srv.URL, Repo: "someone/else"}).Latest(t.Context()); err == nil || errors.Is(err, ErrOffline) { + t.Fatalf("a 404: %v, want an error that is not ErrOffline", err) + } +} diff --git a/internal/ui/assets/app.css b/internal/ui/assets/app.css index 758d163..45ef1c9 100644 --- a/internal/ui/assets/app.css +++ b/internal/ui/assets/app.css @@ -903,3 +903,14 @@ body[data-platform="darwin"] .tb-menus { display: none; } .tab-all svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.4; } .chip.open-tab { background: var(--selected); color: var(--accent); } .pop-item.on { font-weight: 600; } + +/* Updating the app (D38): the title bar's note, and its panel. */ +.tb-update-chip { height: 24px; margin-right: 8px; display: flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--ground); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; } +.tb-update-chip:hover { border-color: var(--accent); background: var(--selected); } +.tb-update-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--accent); } +.pop.upd-pop { width: 372px; gap: 12px; padding: 18px; line-height: 1.5; } +.upd-title { margin: 0; font: 600 18px var(--serif); } +.upd-notes { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 8px; background: var(--quote); } +.upd-notes .link { align-self: flex-start; font-size: 12px; } +.upd-actions { display: flex; align-items: center; gap: 8px; } +.upd-actions .quiet { margin-left: auto; font-size: 12px; } diff --git a/internal/ui/assets/index.html b/internal/ui/assets/index.html index 5e9d7cf..9b29928 100644 --- a/internal/ui/assets/index.html +++ b/internal/ui/assets/index.html @@ -25,6 +25,7 @@
+ +

Updating the app

+

On Windows the app keeps itself up to date. Once a day it asks GitHub for the latest version; when there is a newer one, Update to … appears in the title bar. Choose Update and restart: it downloads the installer, checks it against the release's checksums, and reopens on the new version with your library, settings and open tabs as they were. Help, Check for Updates… checks at once, and Check for Updates Automatically turns the daily check off. The check sends nothing about you or your library.

+

Versions 0.4.3 and earlier cannot update themselves: install the newest version over them once, from the download above. On macOS and Linux, download the new version from the latest release.

The command line

One file, nothing else to install. Download it from the latest release, unpack it, and run it.

Expand-Archive fil_{v}_windows_amd64.zip fil @@ -102,6 +105,7 @@

The command line

diff --git a/site/index.html b/site/index.html index 6edf451..1f4da55 100644 --- a/site/index.html +++ b/site/index.html @@ -106,7 +106,7 @@

Your research library, built from citations.

The Papers list -

Install

One installer for Windows, no admin rights. Filiation asks where your library should live, and that is all the setup there is.

+

Install

One installer for Windows, no admin rights. Filiation asks where your library should live, and that is all the setup there is. After that it keeps itself up to date.

@@ -278,7 +278,7 @@

Filiation: which text was copied from which.

The app For everyone. Your papers, search, the map and the Reader in one window. -
Windows installer
+
Windows installerUpdates itself
macOS and Linux: installers are coming; the app builds from source today. Download for Windows
diff --git a/site/tools/docs/install.html b/site/tools/docs/install.html index 1a4449b..119d585 100644 --- a/site/tools/docs/install.html +++ b/site/tools/docs/install.html @@ -16,6 +16,9 @@

The app

+

Updating the app

+

On Windows the app keeps itself up to date. Once a day it asks GitHub for the latest version; when there is a newer one, Update to … appears in the title bar. Choose Update and restart: it downloads the installer, checks it against the release's checksums, and reopens on the new version with your library, settings and open tabs as they were. Help, Check for Updates… checks at once, and Check for Updates Automatically turns the daily check off. The check sends nothing about you or your library.

+

Versions 0.4.3 and earlier cannot update themselves: install the newest version over them once, from the download above. On macOS and Linux, download the new version from the latest release.

The command line

One file, nothing else to install. Download it from the latest release, unpack it, and run it.

Expand-Archive fil_{v}_windows_amd64.zip fil From 0bd81bf15674f781442860efb18982c3b22b2b9b Mon Sep 17 00:00:00 2001 From: Haren Daishika Date: Tue, 24 Nov 2026 19:27:42 +0530 Subject: [PATCH 2/2] Updates: list the installer in the release's checksums GoReleaser writes checksums.txt in the release job, before the Windows installer is built and attached, so v0.4.3's checksums do not list it and every update would have failed its check. The release workflow now adds the installer's SHA-256 to checksums.txt and uploads it again, replacing any line from an earlier run. The app reads the checksums when it checks, and offers a release that does not list its installer as a download instead. --- .github/workflows/release.yml | 11 +++++++++++ docs/DECISIONS.md | 4 ++++ internal/update/update.go | 15 +++++++++++---- internal/update/update_test.go | 25 +++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ed75b5..bec23ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,3 +56,14 @@ jobs: $tag = "${{ github.ref_name }}" $setup = pwsh desktop/installer/build.ps1 -Version $tag.TrimStart('v') | Select-Object -Last 1 gh release upload $tag $setup --clobber + # GoReleaser wrote checksums.txt before the installer existed. The + # app checks the installer against it before running it (D38), so + # its line is added, replacing any from an earlier run of this job. + $name = Split-Path $setup -Leaf + $hash = (Get-FileHash $setup -Algorithm SHA256).Hash.ToLower() + New-Item -ItemType Directory -Force sums | Out-Null + gh release download $tag -p checksums.txt -D sums --clobber + $lines = @(Get-Content sums/checksums.txt | Where-Object { $_ -and -not $_.EndsWith(" $name") }) + $lines += "$hash $name" + [IO.File]::WriteAllText("$PWD/sums/checksums.txt", ($lines -join "`n") + "`n") + gh release upload $tag sums/checksums.txt --clobber diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index ede4347..181f3f4 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -990,6 +990,10 @@ Windows installs it when asked. - **Elsewhere, the download page.** A copy not installed by Setup (no `unins000.exe` beside it), and the app on macOS and Linux, which have no installer yet, offer the release page instead. A development build is never offered an update. +- **The installer is in the checksums.** GoReleaser writes `checksums.txt` before the installer + is built, so the release workflow adds the installer's line afterwards and uploads the file again. + A release whose checksums do not list its installer, as before v0.4.4, is offered as a download, + never as an update that would fail its check. - **Trust rests on GitHub and the checksum.** The installer and its checksums come from the same release, so the check catches a broken or partial download, not a compromised release; signing the installer (D37) is what would add that. diff --git a/internal/update/update.go b/internal/update/update.go index 4c55e4c..781afb3 100644 --- a/internal/update/update.go +++ b/internal/update/update.go @@ -106,10 +106,17 @@ func (u *Updater) Check(ctx context.Context) (Info, error) { Notes: notes(r.Notes), Page: r.Page, } - if a, ok := r.Asset(u.installerName(r.Version)); ok && u.CanInstall { - if _, ok := r.Asset("checksums.txt"); ok { - info.CanInstall = true - info.Size = a.Size + // Offered only when the installer can be checked: a release whose + // checksums do not list it, as before v0.4.4, gets the download page + // rather than an update that is bound to fail. + if a, ok := r.Asset(u.installerName(r.Version)); ok && u.CanInstall && info.Newer { + if sums, ok := r.Asset("checksums.txt"); ok { + if list, err := u.Source.Text(ctx, sums); err == nil { + if _, listed := checksum(list, a.Name); listed { + info.CanInstall = true + info.Size = a.Size + } + } } } return info, nil diff --git a/internal/update/update_test.go b/internal/update/update_test.go index 8e4f5a5..4bf161e 100644 --- a/internal/update/update_test.go +++ b/internal/update/update_test.go @@ -168,6 +168,31 @@ func TestADownloadThatDoesNotMatchIsNeverRun(t *testing.T) { } } +// Before v0.4.4 the installer was attached after GoReleaser wrote +// checksums.txt, so the checksums did not list it. Such a release is offered +// as a download, never as an update that would fail its check. +func TestAReleaseWhoseChecksumsOmitTheInstaller(t *testing.T) { + var srv *httptest.Server + srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/repos/codevector-2003/filiation/releases/latest": + fmt.Fprintf(w, `{"tag_name":"v0.4.4","assets":[{"name":"checksums.txt","browser_download_url":"%[1]s/sums","size":1}, +{"name":"Filiation-Setup-0.4.4-windows-amd64.exe","browser_download_url":"%[1]s/setup","size":5}]}`, srv.URL) + case "/sums": + fmt.Fprintf(w, "%s fil_0.4.4_windows_amd64.zip\n", strings.Repeat("a", 64)) + } + })) + t.Cleanup(srv.Close) + u := &Updater{Current: "0.4.3", Source: &github.Client{Base: srv.URL}, Dir: t.TempDir(), CanInstall: true} + info, err := u.Check(t.Context()) + if err != nil { + t.Fatal(err) + } + if !info.Newer || info.CanInstall { + t.Fatalf("checksums without the installer: %+v; want newer, offered as a download", info) + } +} + func TestOnlyASetupInstallUpdatesItself(t *testing.T) { u := &Updater{Current: "0.4.3", Source: release(t, []byte("x"), strings.Repeat("0", 64)), Dir: t.TempDir()} info, err := u.Check(t.Context())