From 66475f8f335eb53f739a4b78cc0dcd9e1ba7b363 Mon Sep 17 00:00:00 2001
From: Haren Daishika
Date: Tue, 24 Nov 2026 17:48:44 +0530
Subject: [PATCH 1/2] Desktop: Reader tabs, several papers open at once
The Reader keeps one tab per paper, after a Library tab that holds the side
menu and every other screen. Read opens a paper in a tab after the one in
front, or goes to its tab; a citation on the page opens beside the paper it
is cited in. Each tab keeps its page, zoom, side panel and find words. Tabs
close, reopen, reorder by dragging, close on a middle click, and have a
right-click menu and a list of them all. Only the four tabs seen last keep
their PDF open.
Next Tab, Previous Tab, Close Tab and Reopen Closed Tab are in the Go menu:
Ctrl+Tab on every system, as Cmd+Tab is the Mac's app switcher, Ctrl+W and
Ctrl+Shift+T. The Reader's Back button goes; the Library tab is the way back.
The tabs are kept in the library's meta table as JSON, with no schema
change, so a library opened again shows its own papers where they were
left. Reading them back leaves out papers deleted since or with no PDF.
The page saves a second after a change, and at once before the app closes
or the library changes, never after.
---
docs/STATUS.md | 2 +-
internal/library/tabs.go | 144 ++++++
internal/library/tabs_test.go | 92 ++++
internal/store/meta.go | 40 ++
internal/store/meta_test.go | 28 ++
internal/ui/assets/app.css | 28 +-
internal/ui/assets/app.js | 4 +-
internal/ui/assets/index.html | 3 +-
internal/ui/assets/organise.js | 2 +-
internal/ui/assets/reader.js | 97 +++--
internal/ui/assets/start.js | 1 +
internal/ui/assets/tabs.js | 411 ++++++++++++++++++
internal/ui/assets/titlebar.js | 32 +-
internal/ui/menus.go | 7 +
internal/ui/reader.go | 8 +-
internal/ui/tabs.go | 28 ++
internal/ui/tabs_test.go | 33 ++
internal/ui/ui.go | 2 +
site/assets/docs-index.json | 2 +-
site/docs/desktop-app/index.html | 4 +-
.../ai-assistant-research-library/index.html | 2 +-
.../citation-map-alternative/index.html | 2 +-
site/guides/zotero-citation-graph/index.html | 2 +-
site/sitemap.xml | 26 +-
site/tools/docs/desktop-app.html | 4 +-
25 files changed, 941 insertions(+), 63 deletions(-)
create mode 100644 internal/library/tabs.go
create mode 100644 internal/library/tabs_test.go
create mode 100644 internal/store/meta.go
create mode 100644 internal/store/meta_test.go
create mode 100644 internal/ui/assets/tabs.js
create mode 100644 internal/ui/tabs.go
create mode 100644 internal/ui/tabs_test.go
diff --git a/docs/STATUS.md b/docs/STATUS.md
index 23fb4da..b18927a 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) |
+| 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 |
| 6 | M6 — claim genealogy | Not started |
---
diff --git a/internal/library/tabs.go b/internal/library/tabs.go
new file mode 100644
index 0000000..c911ee7
--- /dev/null
+++ b/internal/library/tabs.go
@@ -0,0 +1,144 @@
+package library
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "path/filepath"
+ "strings"
+ "unicode/utf8"
+
+ "github.com/codevector-2003/filiation/internal/errs"
+ "github.com/codevector-2003/filiation/internal/identity"
+ "github.com/codevector-2003/filiation/internal/store"
+)
+
+// The desktop app keeps several papers open in the Reader at once, one tab
+// each, beside the Library tab that holds every other screen. The tabs are
+// kept in the library, so a library opened again shows its own papers where
+// they were left, and another library shows its own.
+
+// metaReaderTabs is the meta key the tabs are kept under, as JSON.
+const metaReaderTabs = "reader_tabs"
+
+// MaxReaderTabs is how many paper tabs are kept.
+const MaxReaderTabs = 50
+
+// ReaderTab is one paper open in the Reader, and where its reader was in it.
+type ReaderTab struct {
+ ID string `json:"id"` // the paper's fil ID
+ Page int `json:"page"` // from 1
+ Zoom float64 `json:"zoom,omitempty"` // the page's scale; 0 leaves the Reader's own
+ Side string `json:"side,omitempty"` // notes, cited or details
+ Find string `json:"find,omitempty"` // the words in Find in this paper
+}
+
+// ReaderTabs is every paper tab, in the order shown, and which tab was in
+// front: a paper's fil ID, or "" for the Library tab. Screen is the screen the
+// Library tab was showing.
+type ReaderTabs struct {
+ Tabs []ReaderTab `json:"tabs"`
+ Active string `json:"active"`
+ Screen string `json:"screen,omitempty"`
+}
+
+var readerSides = map[string]bool{"notes": true, "cited": true, "details": true}
+
+// ReaderTabs returns the tabs kept for this library, leaving out any whose
+// paper has gone or no longer has a PDF to show. Tabs that cannot be read
+// back are forgotten rather than refused: they are a convenience, and the
+// app must open without them.
+func (l *Library) ReaderTabs(ctx context.Context) (ReaderTabs, error) {
+ raw, err := l.db.Meta(ctx, metaReaderTabs)
+ if err != nil {
+ return ReaderTabs{Tabs: []ReaderTab{}}, err
+ }
+ var kept ReaderTabs
+ if raw == "" || json.Unmarshal([]byte(raw), &kept) != nil {
+ return ReaderTabs{Tabs: []ReaderTab{}}, nil
+ }
+ kept = tidyTabs(kept)
+ out := ReaderTabs{Tabs: []ReaderTab{}, Screen: kept.Screen}
+ for _, t := range kept.Tabs {
+ ok, err := l.HasPDF(ctx, t.ID)
+ if err != nil {
+ return ReaderTabs{Tabs: []ReaderTab{}}, err
+ }
+ if ok {
+ out.Tabs = append(out.Tabs, t)
+ if t.ID == kept.Active {
+ out.Active = t.ID
+ }
+ }
+ }
+ return out, nil
+}
+
+// SaveReaderTabs keeps the tabs for the next time this library is opened.
+func (l *Library) SaveReaderTabs(ctx context.Context, tabs ReaderTabs) error {
+ if len(tabs.Tabs) > MaxReaderTabs {
+ return fmt.Errorf("at most %d papers can be kept open: %w", MaxReaderTabs, errs.ErrInvalidInput)
+ }
+ for _, t := range tabs.Tabs {
+ if _, err := identity.NormaliseFilID(t.ID); err != nil {
+ return fmt.Errorf("%q is not a fil ID: %w", t.ID, errs.ErrInvalidInput)
+ }
+ }
+ raw, err := json.Marshal(tidyTabs(tabs))
+ if err != nil {
+ return err
+ }
+ return l.db.Tx(ctx, func(tx *store.Tx) error { return tx.SetMeta(ctx, metaReaderTabs, string(raw)) })
+}
+
+// tidyTabs puts the tabs in a shape the Reader can always open: one tab per
+// paper, a page it can turn to, a side panel it has.
+func tidyTabs(in ReaderTabs) ReaderTabs {
+ out := ReaderTabs{Tabs: []ReaderTab{}, Screen: shortText(in.Screen, 40)}
+ seen := map[string]bool{}
+ for _, t := range in.Tabs {
+ id, err := identity.NormaliseFilID(t.ID)
+ if err != nil || seen[id] || len(out.Tabs) == MaxReaderTabs {
+ continue
+ }
+ seen[id] = true
+ t.ID = id
+ t.Page = max(t.Page, 1)
+ if t.Zoom < 0.25 || t.Zoom > 5 {
+ t.Zoom = 0
+ }
+ if !readerSides[t.Side] {
+ t.Side = ""
+ }
+ t.Find = shortText(t.Find, 200)
+ out.Tabs = append(out.Tabs, t)
+ }
+ if active, err := identity.NormaliseFilID(in.Active); err == nil && seen[active] {
+ out.Active = active
+ }
+ return out
+}
+
+// HasPDF reports whether the library holds a PDF of the paper that is still
+// on disk, as far as it knows.
+func (l *Library) HasPDF(ctx context.Context, filID string) (bool, error) {
+ files, err := l.db.FilesOf(ctx, filID)
+ if err != nil {
+ return false, err
+ }
+ for _, f := range files {
+ if !f.Missing && strings.EqualFold(filepath.Ext(f.Path), ".pdf") {
+ return true, nil
+ }
+ }
+ return false, nil
+}
+
+// shortText trims s to at most n characters, never cutting one in half.
+func shortText(s string, n int) string {
+ s = strings.TrimSpace(s)
+ if utf8.RuneCountInString(s) <= n {
+ return s
+ }
+ return strings.TrimSpace(string([]rune(s)[:n]))
+}
diff --git a/internal/library/tabs_test.go b/internal/library/tabs_test.go
new file mode 100644
index 0000000..ff83a15
--- /dev/null
+++ b/internal/library/tabs_test.go
@@ -0,0 +1,92 @@
+package library
+
+import (
+ "errors"
+ "testing"
+
+ "github.com/codevector-2003/filiation/internal/errs"
+ "github.com/codevector-2003/filiation/internal/store"
+)
+
+func TestReaderTabs(t *testing.T) {
+ t.Parallel()
+ l, ids, _ := viewsTest(t)
+ ctx := t.Context()
+
+ none, err := l.ReaderTabs(ctx)
+ if err != nil || len(none.Tabs) != 0 || none.Active != "" || none.Tabs == nil {
+ t.Fatalf("before any were kept = %+v, %v; want no tabs, as an empty list", none, err)
+ }
+
+ // The seed has no PDF, so a tab on it has nothing to show.
+ seed, err := l.Add(ctx, "10.7717/peerj.4375", AddOptions{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = l.SaveReaderTabs(ctx, ReaderTabs{
+ Tabs: []ReaderTab{
+ {ID: ids[0], Page: 4, Zoom: 1.3, Side: "cited", Find: " hedgerow "},
+ {ID: ids[1], Page: 0, Zoom: 99, Side: "elsewhere"},
+ {ID: seed.Work.FilID, Page: 2},
+ {ID: ids[0], Page: 9}, // the same paper twice keeps the first
+ },
+ Active: ids[1],
+ Screen: "search",
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, err := l.ReaderTabs(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ want := []ReaderTab{
+ {ID: ids[0], Page: 4, Zoom: 1.3, Side: "cited", Find: "hedgerow"},
+ {ID: ids[1], Page: 1},
+ }
+ if len(got.Tabs) != len(want) || got.Tabs[0] != want[0] || got.Tabs[1] != want[1] {
+ t.Fatalf("tabs = %+v, want %+v", got.Tabs, want)
+ }
+ if got.Active != ids[1] || got.Screen != "search" {
+ t.Errorf("active %q on screen %q, want %q on search", got.Active, got.Screen, ids[1])
+ }
+
+ // A paper deleted since is left out, and the Library tab comes to the front.
+ if _, err := l.DeletePapers(ctx, []string{ids[1]}); err != nil {
+ t.Fatal(err)
+ }
+ got, err = l.ReaderTabs(ctx)
+ if err != nil || len(got.Tabs) != 1 || got.Tabs[0].ID != ids[0] || got.Active != "" {
+ t.Fatalf("after deleting the paper in front = %+v, %v", got, err)
+ }
+}
+
+func TestSaveReaderTabsRefuses(t *testing.T) {
+ t.Parallel()
+ l, ids, _ := viewsTest(t)
+ ctx := t.Context()
+
+ if err := l.SaveReaderTabs(ctx, ReaderTabs{Tabs: []ReaderTab{{ID: "../papers", Page: 1}}}); !errors.Is(err, errs.ErrInvalidInput) {
+ t.Errorf("a tab that names no paper: %v, want ErrInvalidInput", err)
+ }
+ many := make([]ReaderTab, MaxReaderTabs+1)
+ for i := range many {
+ many[i] = ReaderTab{ID: ids[0], Page: 1}
+ }
+ if err := l.SaveReaderTabs(ctx, ReaderTabs{Tabs: many}); !errors.Is(err, errs.ErrInvalidInput) {
+ t.Errorf("%d tabs: %v, want ErrInvalidInput", len(many), err)
+ }
+}
+
+func TestReaderTabsForgetWhatCannotBeRead(t *testing.T) {
+ t.Parallel()
+ l, _, _ := viewsTest(t)
+ ctx := t.Context()
+ if err := l.db.Tx(ctx, func(tx *store.Tx) error { return tx.SetMeta(ctx, metaReaderTabs, "{not json") }); err != nil {
+ t.Fatal(err)
+ }
+ got, err := l.ReaderTabs(ctx)
+ if err != nil || len(got.Tabs) != 0 {
+ t.Fatalf("tabs kept as broken JSON = %+v, %v; want none and no error", got, err)
+ }
+}
diff --git a/internal/store/meta.go b/internal/store/meta.go
new file mode 100644
index 0000000..7000a2b
--- /dev/null
+++ b/internal/store/meta.go
@@ -0,0 +1,40 @@
+package store
+
+import (
+ "context"
+ "database/sql"
+ "errors"
+ "fmt"
+)
+
+// The meta table keeps the library's bookkeeping, one value per key: the
+// schema version, and small things the screens remember, such as which papers
+// were open in the Reader. A value is the caller's to read; the store only
+// keeps it.
+
+// Meta reads the value kept under key, "" when there is none.
+func (db *DB) Meta(ctx context.Context, key string) (string, error) {
+ var v sql.NullString
+ err := db.read.QueryRowContext(ctx, `SELECT value FROM meta WHERE key = ?;`, key).Scan(&v)
+ if errors.Is(err, sql.ErrNoRows) {
+ return "", nil
+ }
+ if err != nil {
+ return "", fmt.Errorf("store: read %s: %w", key, err)
+ }
+ return v.String, nil
+}
+
+// SetMeta keeps value under key, replacing what was there. The schema version
+// is the migrations' alone to change.
+func (tx *Tx) SetMeta(ctx context.Context, key, value string) error {
+ if key == metaSchemaVersion {
+ return fmt.Errorf("store: %s is set by migration only", key)
+ }
+ if _, err := tx.tx.ExecContext(ctx,
+ `INSERT INTO meta(key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value;`,
+ key, value); err != nil {
+ return fmt.Errorf("store: write %s: %w", key, err)
+ }
+ return nil
+}
diff --git a/internal/store/meta_test.go b/internal/store/meta_test.go
new file mode 100644
index 0000000..27df35d
--- /dev/null
+++ b/internal/store/meta_test.go
@@ -0,0 +1,28 @@
+package store
+
+import "testing"
+
+func TestMeta(t *testing.T) {
+ db := migrated(t)
+ ctx := t.Context()
+
+ got, err := db.Meta(ctx, "reader_tabs")
+ if err != nil || got != "" {
+ t.Fatalf("Meta before any write = %q, %v; want \"\", nil", got, err)
+ }
+ for _, want := range []string{`{"a":1}`, `{"a":2}`} {
+ if err := db.Tx(ctx, func(tx *Tx) error { return tx.SetMeta(ctx, "reader_tabs", want) }); err != nil {
+ t.Fatal(err)
+ }
+ if got, err := db.Meta(ctx, "reader_tabs"); err != nil || got != want {
+ t.Errorf("Meta = %q, %v; want %q", got, err, want)
+ }
+ }
+
+ if err := db.Tx(ctx, func(tx *Tx) error { return tx.SetMeta(ctx, metaSchemaVersion, "1") }); err == nil {
+ t.Error("SetMeta changed the schema version")
+ }
+ if v, _ := db.Meta(ctx, metaSchemaVersion); v != "16" {
+ t.Errorf("schema version = %q after a refused write, want 16", v)
+ }
+}
diff --git a/internal/ui/assets/app.css b/internal/ui/assets/app.css
index 4cfb23f..758d163 100644
--- a/internal/ui/assets/app.css
+++ b/internal/ui/assets/app.css
@@ -558,8 +558,6 @@ dialog form { display: flex; flex-direction: column; gap: 10px; }
/* The Reader */
#screen-reader { flex-direction: column; }
.reader-bar { flex: none; min-height: 52px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
-.reader-back { height: 34px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; }
-.reader-back:hover { background: var(--quote); }
.reader-title { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.sep { width: 1px; height: 24px; background: var(--line); }
.tools { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--side); }
@@ -879,3 +877,29 @@ body[data-platform="darwin"] .tb-menus { display: none; }
.mf-group .key { flex: none; }
.mf-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-note { font-size: 12px; line-height: 1.45; }
+
+/* Reader tabs: the Library tab, then one tab for each paper open. */
+.tabstrip { flex: none; height: 34px; display: flex; align-items: flex-end; gap: 2px; padding: 0 8px; background: #E1DFD9; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
+.tabstrip::-webkit-scrollbar { display: none; }
+.tab { position: relative; flex: none; height: 29px; display: flex; align-items: center; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0; background: transparent; color: var(--ink-2); }
+.tab:hover:not(.on) { background: #D8D6CF; }
+.tab.on { height: 30px; margin-bottom: -1px; border-color: var(--line); background: var(--panel); color: var(--ink); font-weight: 600; }
+.tab.lib { gap: 8px; padding: 0 14px 0 11px; }
+.tab.lib.on { background: var(--side); }
+.tab.lib svg, .tab-go svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; }
+.tab.paper { flex: 0 1 200px; min-width: 96px; }
+.tab.paper.dragging { opacity: 0.6; }
+.tab-go { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 7px; padding: 0 0 0 11px; border: 0; background: transparent; color: inherit; font-weight: inherit; text-align: left; }
+.tab-go svg { color: var(--muted); }
+.tab.on .tab-go svg { color: var(--accent); }
+.tab-t { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
+.tab-pg { flex: none; font-size: 11px; font-weight: 400; color: var(--muted); }
+.tab-x { flex: none; width: 20px; height: 20px; margin: 0 5px 0 3px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--muted); display: grid; place-items: center; }
+.tab-x svg { width: 8px; height: 8px; stroke: currentColor; stroke-width: 1.6; }
+.tab-x:hover { background: var(--line-2); color: var(--ink); }
+.tab.paper:not(.on):not(:hover):not(:focus-within) .tab-x { visibility: hidden; }
+.tab-all { position: sticky; right: 0; margin-left: auto; align-self: center; flex: none; height: 26px; display: flex; align-items: center; gap: 6px; padding: 0 9px; border: 0; border-radius: 6px; background: #E1DFD9; color: var(--muted); font-size: 12px; }
+.tab-all:hover { background: #D8D6CF; color: var(--ink); }
+.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; }
diff --git a/internal/ui/assets/app.js b/internal/ui/assets/app.js
index 36ca50f..58cf320 100644
--- a/internal/ui/assets/app.js
+++ b/internal/ui/assets/app.js
@@ -57,6 +57,7 @@ function show(name, arg) {
document.querySelector('.side').hidden = name === 'reader'; // the page needs the room
if (screens[name]) screens[name](arg);
markPlace();
+ tabsShown(name);
}
async function loadLibrary() {
@@ -336,6 +337,7 @@ function chips(p) {
else if (p.seed) out.push(el('span', 'chip', 'Added by you'));
if (p.zotero === 'unmatched') out.push(el('span', 'chip warn', 'Not matched'));
if (p.pdf) out.push(el('span', 'chip pdf', 'PDF'));
+ if (tabOf(p.id)) out.push(el('span', 'chip open-tab', 'Open in a tab'));
if (p.mismatch) out.push(el('span', 'chip warn', 'Another edition?'));
if (p.text) out.push(el('span', p.searchable ? 'chip text' : 'chip', p.text));
if (p.sentences > 0) out.push(el('span', 'chip', p.sentences === 1 ? '1 sentence' : p.sentences + ' sentences'));
@@ -478,7 +480,7 @@ function renderPaper(p) {
}
});
const actions = el('div', 'actions');
- if (p.pdf) actions.append(button('Read', 'btn primary', () => openReader(p.id, 1, [])));
+ if (p.pdf) actions.append(tabOf(p.id) ? button('Go to tab', 'btn', () => openReader(p.id)) : button('Read', 'btn primary', () => openReader(p.id)));
if (p.pdf) actions.append(act('Open PDF', false, '/open'));
if (!p.pdf && !p.local) {
const get = button('Download PDF', p.downloadable ? 'btn primary' : 'btn', () => downloadPDFs([p.id]));
diff --git a/internal/ui/assets/index.html b/internal/ui/assets/index.html
index ef05b59..5e9d7cf 100644
--- a/internal/ui/assets/index.html
+++ b/internal/ui/assets/index.html
@@ -43,6 +43,7 @@
+
PapersYour library, one paper per row, with its PDF, labels and details beside it.
SearchKeywords across every PDF; the passage and its page, lit on the PDF.
Citation mapWhat a paper cites and what cites it, or the whole library at once.
-
ReaderRead, highlight and comment. Notes live in your library; the PDF stays as it was.
+
ReaderRead, highlight and comment, with several papers open in tabs. Notes live in your library; the PDF stays as it was.
GroupsTopics found from the citations alone, offered as collections.
Title bar searchFind a paper you have, or paste a DOI or title to add a new one.
@@ -18,6 +18,8 @@
Keys worth knowing
Ctrl+click
Select more than one paper.
Shift+click
Select a run of papers.
Ctrl+A
Select every paper in the list.
+
Ctrl+Tab
The next tab: the Library tab, then each paper open. With Shift, the one before.
+
Ctrl+W
Close the paper tab in front. Ctrl+Shift+T opens it again, at its page.
Delete
Delete the selected papers. Their folders go to the Recycle Bin.
Right-click
A paper's actions: favourite, add to a collection, label, show on the map, download its PDF, bring in papers around it, delete.
From 21e8762def8b032fdd64516f889fc7561631fe5e Mon Sep 17 00:00:00 2001
From: Haren Daishika
Date: Tue, 24 Nov 2026 17:55:11 +0530
Subject: [PATCH 2/2] Reader tabs: the Library tab reopens on the screen it was
left on
With no paper tab in front, the app opened on Papers while the Library tab
named the screen kept, Search say. Show that screen.
---
internal/ui/assets/tabs.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/internal/ui/assets/tabs.js b/internal/ui/assets/tabs.js
index 1893b5b..7f0dc0e 100644
--- a/internal/ui/assets/tabs.js
+++ b/internal/ui/assets/tabs.js
@@ -406,6 +406,9 @@ async function restoreTabs() {
renderTabs();
}).catch(() => {});
});
+ // The Library tab in front shows the screen it was left on, as its label
+ // says; the app opens on Papers.
const front = tabOf(kept.active);
if (front) activateTab(front, false);
+ else if (tabs.screen !== onScreen()) show(tabs.screen);
}