oficina / memoria Public

WIP memoria: the box in the middle; recent searches (this browser only) and recently updated under it

Paul, 2026-10-30: "vertically centered, and below it, maybe a short
history of the last few searches, and some suggestions based on real
data". Recent searches live in localStorage: a query is content and
memoria keeps none on the server. Recently updated is Store.Recent, one
query and five opens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 428cfbf852c1c9f2c844a68f0a619123c6d0107b parent 681c2c1
5 files changed, +174 −4
  • internal/memoria/handlers.go +17 −0
  • internal/memoria/static/memoria.css +46 −2
  • internal/memoria/static/search.js +55 −0
  • internal/memoria/store.go +33 −0
  • internal/memoria/templates/index.html +23 −2

CI failed — run details

diff --git a/internal/memoria/handlers.go b/internal/memoria/handlers.go
index b7535c3..0ed310e 100644
--- a/internal/memoria/handlers.go
+++ b/internal/memoria/handlers.go
@@ -168,6 +168,8 @@ type page struct {
FlashKind string
Results []Result
Documents []Summary
+ // Recent is the front page's "Recently updated" (RecentDocuments).
+ Recent []Summary
Drop dropZone
// Notices is §6.5's loud withholding: what this page could not show
@@ -595,6 +597,17 @@ func (a *app) index(w http.ResponseWriter, r *http.Request) {
p := a.pageFor(r, f)
p.Query, p.Searched = q, q != ""
a.runSearch(r, &p)
+ if !p.Searched {
+ // Under the box: what changed lately, from the documents
+ // themselves (Paul, 2026-10-30: "some suggestions based on real
+ // data"). A failure shows nothing here and says so in the log;
+ // the page is a search box either way.
+ recent, err := a.store.Recent(r.Context(), RecentDocuments)
+ if err != nil {
+ a.logger.Error("recent documents", "err", err)
+ }
+ p.Recent = recent
+ }
// "Thanks — saved" after a correction or a rating returns here.
if kind, msg, ok := indexNotice.take(w, r); ok {
p.Flash, p.FlashKind = msg, kind
@@ -602,6 +615,10 @@ func (a *app) index(w http.ResponseWriter, r *http.Request) {
render(w, "index", p)
}
+// RecentDocuments is how many recently updated documents the front page
+// lists under the box.
+const RecentDocuments = 5
+
// documents is GET /documents: everything stored, with Add content and
// each document's Delete. It was the bottom of the front page until Paul
// asked for a front page that is only a search box (2026-10-29).
diff --git a/internal/memoria/static/memoria.css b/internal/memoria/static/memoria.css
index 5cf9572..5728b27 100644
--- a/internal/memoria/static/memoria.css
+++ b/internal/memoria/static/memoria.css
@@ -94,10 +94,54 @@ html { scrollbar-gutter: stable; }
[rst-suggest-fact-label] { color: var(--rst-text-muted); font-size: 0.875rem; }
[rst-suggest-all] { color: var(--rst-text-muted); font-size: 0.875rem; justify-content: space-between; }
-[rst-home] { padding-top: 24vh; min-height: 55vh; }
+/* The box's middle on the screen's middle: the page's top padding is
+ half the screen less the bar, the main area's own padding and half the
+ box. The lists below it grow downwards and never move it. */
+[rst-home] { padding-top: max(1rem, calc(50svh - 9.5rem)); min-height: 70svh; }
+[rst-home-lists] {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
+ gap: 1.25rem 2.5rem;
+ margin-top: 1.75rem;
+}
+[rst-home-lists] [hidden] { display: none; }
+[rst-home-label] {
+ align-items: center;
+ color: var(--rst-text-muted);
+ display: flex;
+ font-size: 0.75rem;
+ font-weight: 600;
+ justify-content: space-between;
+ letter-spacing: 0.06em;
+ margin: 0 0 0.4rem;
+ text-transform: uppercase;
+}
+[rst-home-clear] {
+ background: none;
+ border: 0;
+ color: var(--rst-text-muted);
+ cursor: pointer;
+ font: inherit;
+ letter-spacing: normal;
+ padding: 0;
+ text-decoration: underline;
+ text-transform: none;
+}
+[rst-home-clear]:hover { color: var(--rst-text); }
+[rst-home-list] { list-style: none; margin: 0; padding: 0; }
+[rst-home-list] li {
+ border-bottom: 1px solid var(--rst-line);
+ font-size: 0.9375rem;
+ overflow: hidden;
+ padding: 0.45rem 0;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+[rst-home-list] a { color: var(--rst-text); text-decoration: none; }
+[rst-home-list] a:hover { text-decoration: underline; }
[rst-home] [rst-search] { margin-bottom: 0.75rem; }
@media (max-width: 640px) {
- [rst-home] { padding-top: 6vh; }
+ [rst-home] { padding-top: 18svh; }
}
[rst-section] { border-top: 1px solid var(--rst-line); margin-top: 2.5rem; padding-top: 1rem; }
diff --git a/internal/memoria/static/search.js b/internal/memoria/static/search.js
index 42eee95..19bc1cc 100644
--- a/internal/memoria/static/search.js
+++ b/internal/memoria/static/search.js
@@ -159,6 +159,61 @@
window.addEventListener("pageshow", function () { close(); });
})();
+/* Recent searches (Paul, 2026-10-30: "a short history of the last few
+ searches"). Kept in this browser's localStorage and nowhere else: a
+ query is content, and memoria keeps no query on the server, so the
+ list never leaves the device and Clear empties it. A results page
+ records its own query (whatever brought it there: Enter, a link, a
+ reload); the front page lists them, newest first, as links that
+ search again. Every string goes in as text, never as markup. */
+(function () {
+ "use strict";
+ var KEY = "memoria.recent-searches";
+ var MAX = 6;
+ var store;
+ try {
+ store = window.localStorage;
+ store.getItem(KEY);
+ } catch (e) {
+ return; // storage off: no history, and nothing else changes
+ }
+ function load() {
+ try {
+ var v = JSON.parse(store.getItem(KEY) || "[]");
+ return Array.isArray(v) ? v.filter(function (q) { return typeof q === "string" && q; }) : [];
+ } catch (e) {
+ return [];
+ }
+ }
+ var region = document.querySelector('[rst-refresh="results"]');
+ var q = region && region.getAttribute("rst-search-results-for");
+ if (q) {
+ var list = load().filter(function (x) { return x.toLowerCase() !== q.toLowerCase(); });
+ list.unshift(q);
+ store.setItem(KEY, JSON.stringify(list.slice(0, MAX)));
+ return;
+ }
+ var section = document.querySelector("[rst-home-history]");
+ if (!section) return;
+ var ul = section.querySelector("[rst-home-list]");
+ var past = load();
+ if (!past.length) return;
+ past.forEach(function (x) {
+ var li = document.createElement("li");
+ var a = document.createElement("a");
+ a.href = "/?q=" + encodeURIComponent(x);
+ a.textContent = x;
+ li.appendChild(a);
+ ul.appendChild(li);
+ });
+ section.hidden = false;
+ var clear = section.querySelector("[rst-home-clear]");
+ if (clear) clear.addEventListener("click", function () {
+ store.removeItem(KEY);
+ section.hidden = true;
+ });
+})();
+
/* The results page's AI answer (§8.11). The page never waits on the
model: a page with an answer slot asks GET /answer once it has loaded,
and the slot says the AI is being asked. GET /answer runs its own ruled
diff --git a/internal/memoria/store.go b/internal/memoria/store.go
index aeb74f5..883a726 100644
--- a/internal/memoria/store.go
+++ b/internal/memoria/store.go
@@ -972,6 +972,39 @@ func (s *Store) rule(ctx context.Context, asker suite.Subject, all []Result) Pag
return page
}
+// Recent lists the n most recently updated documents, titles and paths
+// opened, for the front page. One query and n opens, not Summaries' read
+// of everything with a passage count each: the front page loads on every
+// visit and must not cost what the list page does.
+func (s *Store) Recent(ctx context.Context, n int) ([]Summary, error) {
+ var docs []Document
+ if err := s.db.G.WithContext(ctx).Select("id", "source", "sealed_title", "sealed_path", "updated_at").
+ Order("updated_at desc").Limit(n).Find(&docs).Error; err != nil {
+ return nil, err
+ }
+ out := make([]Summary, 0, len(docs))
+ for _, d := range docs {
+ t, err := s.sealer.Open(seal.PurposeTitle, d.SealedTitle)
+ if err != nil {
+ return nil, fmt.Errorf("open title %d: %w", d.ID, err)
+ }
+ var path string
+ if len(d.SealedPath) > 0 {
+ p, err := s.sealer.Open(seal.PurposePath, d.SealedPath)
+ if err != nil {
+ return nil, fmt.Errorf("open path %d: %w", d.ID, err)
+ }
+ path = string(p)
+ }
+ out = append(out, Summary{
+ ID: d.ID, Source: d.Source, Title: string(t), Path: path,
+ UpdatedDay: d.UpdatedAt.UTC().Format("2 Jan 2006"),
+ UpdatedISO: d.UpdatedAt.UTC().Format(time.RFC3339),
+ })
+ }
+ return out, nil
+}
+
// Summaries lists every document, titles opened.
func (s *Store) Summaries(ctx context.Context) ([]Summary, error) {
var docs []Document
diff --git a/internal/memoria/templates/index.html b/internal/memoria/templates/index.html
index 5eb26cb..0370fa3 100644
--- a/internal/memoria/templates/index.html
+++ b/internal/memoria/templates/index.html
@@ -7,8 +7,9 @@
border the polish audit found. */}}
{{/* The front page is a search box and nothing else (Paul, 2026-10-29:
"a bit more like Google with a simple search box in the middle").
- With no query the box sits a third of the way down and nothing else
- is on the page (Paul, 2026-10-30: no logo, no "cruft"). A page
+ With no query the box sits in the middle of the screen (Paul,
+ 2026-10-30: no logo, no "cruft", "vertically centered"), with the
+ last few searches and recently updated documents under it. A page
loaded WITH a query — a link, a reload, a scriptless submit — is a
results page and starts at the top. The documents list is /documents. */}}
<div{{if not .Searched}} rst-home{{end}}>
@@ -23,6 +24,26 @@
</form>
<div rst-suggest-box hidden></div>
</div>
+{{if not .Searched}}
+{{/* Under the box (Paul, 2026-10-30): the last few searches and what
+ changed lately. Recent searches live in this browser only
+ (localStorage, search.js): a query is content, and memoria keeps no
+ query on the server. Without a script that list stays hidden. */}}
+<div rst-home-lists>
+ <section rst-home-history hidden>
+ <h2 rst-home-label>Recent searches <button type="button" rst-home-clear>Clear</button></h2>
+ <ul rst-home-list></ul>
+ </section>
+ {{with .Recent}}
+ <section>
+ <h2 rst-home-label>Recently updated</h2>
+ <ul rst-home-list>
+ {{range .}}<li><a href="/documents/{{.ID}}">{{.Title}}</a>{{if .Path}} <span rst-muted>· {{.Path}}</span>{{end}} <span rst-muted>· <time datetime="{{.UpdatedISO}}">{{.UpdatedDay}}</time></span></li>{{end}}
+ </ul>
+ </section>
+ {{end}}
+</div>
+{{end}}
{{/* The results region. search.js writes live results into it, and it
is here rather than around the {{if}} because an absent region has