diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f11424e5..9302d5e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,7 +40,7 @@ jobs: # ad-hoc defaults (13.11). Diverges from ci.yml's test matrix by design. - os: macos arch: universal - runner: macos-14 + runner: macos-15 rust-target: aarch64-apple-darwin rust-extra: x86_64-apple-darwin napi-script: build:darwin-arm64 diff --git a/apps/books/src/app.test.tsx b/apps/books/src/app.test.tsx index 287318d8..1069b6f3 100644 --- a/apps/books/src/app.test.tsx +++ b/apps/books/src/app.test.tsx @@ -182,6 +182,23 @@ describe("BooksApp shelf", () => { expect(el.querySelector(".books__page")?.textContent).toContain("Anchor"); }); + // The inspector read the stored fraction as a bare number ("45") while the + // footer showed the live one ("23% read"); both now come from the reader. + it("shows the reader's live progress in the inspector, as a percentage", async () => { + const el = await renderApp(); + const footer = /(\d+)%/.exec(el.querySelector(".books__progress")?.textContent ?? "")?.[1]; + expect(footer).toBeDefined(); + expect(Number(footer)).toBeGreaterThan(0); + expect(el.querySelector(".bs-cell-progress-text")?.textContent).toBe(`${footer}%`); + }); + + it("carries no Pages row for a reflowable book — the footer owns the page count", async () => { + const el = await renderApp(); + const labels = [...el.querySelectorAll(".bs-props__row-label")].map((n) => n.textContent); + expect(labels).toContain("Progress"); + expect(labels).not.toContain("Pages"); + }); + // F-487 — the shared `.bs-props` inspector is `position: fixed`, so it // takes no layout space. Books centres a full-bleed reading measure under // it, so with the panel open every line ran on underneath: paragraphs read diff --git a/apps/books/src/app.tsx b/apps/books/src/app.tsx index da964549..d41b17f4 100644 --- a/apps/books/src/app.tsx +++ b/apps/books/src/app.tsx @@ -65,7 +65,7 @@ import { } from "./logic/book-open"; import { makePositionPersister, removeBookEntity, writeBookPatch } from "./logic/book-writes"; import { parseEpub } from "./logic/epub-parser"; -import { booksFromEntities } from "./logic/library"; +import { type LiveProgress, booksFromEntities, withLiveProgress } from "./logic/library"; import { type PdfInfo, pdfEnrichmentPatch } from "./logic/pdf-metadata"; import { SAMPLE_BOOK_CONTENT, sampleBook } from "./logic/sample-book"; import { type TocEntry, tocFromContent, tocFromPdfOutline } from "./logic/toc"; @@ -283,6 +283,7 @@ export function BooksApp(): ReactElement { const [openNonce, setOpenNonce] = useState(0); const [status, setStatus] = useState(ReaderStatus.Idle); const [toc, setToc] = useState([]); + const [liveProgress, setLiveProgress] = useState(null); const [showLibrary, setShowLibrary] = useState(true); const libraryAutoHide = useAutoHidePanel({ side: PanelSide.Left, collapsed: !showLibrary }); const [showInspector, setShowInspector] = useState(readInspectorPref); @@ -380,10 +381,13 @@ export function BooksApp(): ReactElement { ); const isSample = selectedId === SAMPLE_BOOK_ID; + const shelf = useMemo(() => withLiveProgress(books, liveProgress), [books, liveProgress]); const selectedBook = useMemo(() => { - if (isSample) return sample.current; - return selectedId ? (books.find((b) => b.id === selectedId) ?? null) : null; - }, [isSample, selectedId, books]); + if (isSample) { + return sample.current ? (withLiveProgress([sample.current], liveProgress)[0] ?? null) : null; + } + return selectedId ? (shelf.find((b) => b.id === selectedId) ?? null) : null; + }, [isSample, selectedId, shelf, liveProgress]); // PRES-3 — who's-here on the open book (vault rows only; not the sample). const bookPeers = usePresence( isSample ? null : (selectedBook?.id ?? null), @@ -461,6 +465,7 @@ export function BooksApp(): ReactElement { if (!stage || !controls) return undefined; setToc([]); + setLiveProgress(null); if (selectedId === null) { stage.replaceChildren(); @@ -468,9 +473,14 @@ export function BooksApp(): ReactElement { return undefined; } + const reportProgress = (progress: number): void => { + if (seq === openSeqRef.current) setLiveProgress({ bookId: selectedId, progress }); + }; + if (selectedId === SAMPLE_BOOK_ID) { const handle = mountReader(stage, controls, SAMPLE_BOOK_CONTENT, { bookId: SAMPLE_BOOK_ID, + onProgressChange: reportProgress, }); readerRef.current = { dispose: handle.dispose, goTo: handle.goTo }; setToc(tocFromContent(SAMPLE_BOOK_CONTENT)); @@ -522,6 +532,7 @@ export function BooksApp(): ReactElement { bookId: book.id, initialPosition: book.reading.position, onPositionChange: persist, + onProgressChange: reportProgress, }); readerRef.current = { dispose: handle.dispose, goTo: handle.goTo }; setToc(tocFromContent(content)); @@ -543,6 +554,7 @@ export function BooksApp(): ReactElement { const handle = mountPdfReader(stage, controls, title, port, { initialPosition: book.reading.position, onPositionChange: persist, + onProgressChange: reportProgress, onOpenLink: (url) => { // Route page links through the `open` intent so web URLs land // in the browser app (the registered `https` opener) — Books @@ -880,7 +892,7 @@ export function BooksApp(): ReactElement { data-inspector-open={selectedBook && subject && showInspector ? "true" : "false"} > { - it("maps author / format label / pages / 0-100 progress", () => { + it("maps author / format label / pages / whole-percent progress fraction", () => { const values = bookToValues(fixtureBook()); expect(values[BOOK_PROP_KEY.author]).toBe("Cal Newport"); expect(values[BOOK_PROP_KEY.format]).toBe("PDF"); expect(values[BOOK_PROP_KEY.pages]).toBe(12); - expect(values[BOOK_PROP_KEY.progress]).toBe(42); + expect(values[BOOK_PROP_KEY.progress]).toBe(0.42); }); it("hides the page count for a book without a measured spine", () => { @@ -56,8 +57,23 @@ describe("applyBookPropertyValue", () => { }); describe("bookPropertyDefs", () => { + // The bare-number cell rendered "45" beside a footer reading "45% read". + it("formats progress as a percentage over a 0..1 range", () => { + const def = bookPropertyDefs(BookFormat.Pdf).find((d) => d.key === BOOK_PROP_KEY.progress); + expect(def?.format).toBe(PropertyFormat.Percent); + expect(def?.range).toEqual({ min: 0, max: 1 }); + }); + + // An EPUB's spine length is its chapter-file count; the reflow reader + // paginates to the viewport, so "Pages 1" sat beside "Page 2 of 8". + it("omits the page count for a reflowable EPUB", () => { + const keys = bookPropertyDefs(BookFormat.Epub).map((d) => d.key); + expect(keys).not.toContain(BOOK_PROP_KEY.pages); + expect(keys).toContain(BOOK_PROP_KEY.progress); + }); + it("declares every value-map key exactly once", () => { - const keys = bookPropertyDefs().map((d) => d.key); + const keys = bookPropertyDefs(BookFormat.Pdf).map((d) => d.key); expect([...keys].sort()).toEqual(Object.values(BOOK_PROP_KEY).sort()); const values = bookToValues(fixtureBook()); for (const key of keys) expect(key in values).toBe(true); diff --git a/apps/books/src/logic/book-properties.ts b/apps/books/src/logic/book-properties.ts index 84d447f8..fdb48c5f 100644 --- a/apps/books/src/logic/book-properties.ts +++ b/apps/books/src/logic/book-properties.ts @@ -7,7 +7,12 @@ * position-persistence path, never edited by hand). */ -import { type PropertyDef, PropertyView, ValueType } from "@brainstorm-os/sdk-types"; +import { + type PropertyDef, + PropertyFormat, + PropertyView, + ValueType, +} from "@brainstorm-os/sdk-types"; import { t } from "../i18n"; import { type Book, BookFormat } from "../types/book"; @@ -18,19 +23,32 @@ export const BOOK_PROP_KEY = { progress: "progress", } as const; -export function bookPropertyDefs(): readonly PropertyDef[] { - return [ +/** The rows for a book of `format`. A reflowable EPUB has no page count of + * its own — its `spineLength` counts chapter files and the reader paginates + * to the viewport — so only a fixed-layout PDF carries the Pages row. */ +export function bookPropertyDefs(format: BookFormat): readonly PropertyDef[] { + const defs: PropertyDef[] = [ { key: BOOK_PROP_KEY.author, name: t("prop.author"), icon: null, valueType: ValueType.Text }, { key: BOOK_PROP_KEY.format, name: t("prop.format"), icon: null, valueType: ValueType.Text }, - { key: BOOK_PROP_KEY.pages, name: t("prop.pages"), icon: null, valueType: ValueType.Number }, - { - key: BOOK_PROP_KEY.progress, - name: t("prop.progress"), + ]; + if (format === BookFormat.Pdf) { + defs.push({ + key: BOOK_PROP_KEY.pages, + name: t("prop.pages"), icon: null, valueType: ValueType.Number, - display: { view: PropertyView.ProgressBar }, - }, - ]; + }); + } + defs.push({ + key: BOOK_PROP_KEY.progress, + name: t("prop.progress"), + icon: null, + valueType: ValueType.Number, + format: PropertyFormat.Percent, + range: { min: 0, max: 1 }, + display: { view: PropertyView.ProgressBar }, + }); + return defs; } export const READONLY_BOOK_PROP_KEYS: ReadonlySet = new Set([ @@ -44,14 +62,14 @@ const FORMAT_LABEL_KEYS = { [BookFormat.Epub]: "prop.format.epub", } as const; -/** Cell values for a book. Progress is 0..100 (the ProgressBar cell's - * default range). */ +/** Cell values for a book. Progress is the 0..1 fraction snapped to a whole + * percent, so the cell reads the same number as the shelf row and footer. */ export function bookToValues(book: Book): Record { return { [BOOK_PROP_KEY.author]: book.author, [BOOK_PROP_KEY.format]: t(FORMAT_LABEL_KEYS[book.format]), [BOOK_PROP_KEY.pages]: book.spineLength > 0 ? book.spineLength : null, - [BOOK_PROP_KEY.progress]: Math.round(book.reading.progress * 100), + [BOOK_PROP_KEY.progress]: Math.round(book.reading.progress * 100) / 100, }; } diff --git a/apps/books/src/logic/library.test.ts b/apps/books/src/logic/library.test.ts index 59cfb67d..b6a5e5e4 100644 --- a/apps/books/src/logic/library.test.ts +++ b/apps/books/src/logic/library.test.ts @@ -11,6 +11,7 @@ import { filterLibrary, isInProgress, sortLibrary, + withLiveProgress, } from "./library"; const SECTION_LABELS: LibrarySectionLabels = { @@ -185,3 +186,22 @@ describe("booksFromEntities", () => { expect(books[0]?.format).toBe(BookFormat.Pdf); }); }); + +// The footer measures progress against the LIVE pagination; the stored +// fraction was measured against whatever viewport last turned a page. Shown +// side by side they disagreed ("45%" in the row, "23% read" in the footer). +describe("withLiveProgress", () => { + const shelf = [reading("a", "A", 0.45, 10), reading("b", "B", 0.8, 20)]; + + it("shows the open book at the reader's live progress", () => { + const out = withLiveProgress(shelf, { bookId: "a", progress: 0.23 }); + expect(out.map((b) => b.reading.progress)).toEqual([0.23, 0.8]); + expect(out[0]?.reading.lastReadAt).toBe(10); + }); + + it("returns the same list when nothing is live or nothing differs", () => { + expect(withLiveProgress(shelf, null)).toBe(shelf); + expect(withLiveProgress(shelf, { bookId: "a", progress: 0.45 })).toBe(shelf); + expect(withLiveProgress(shelf, { bookId: "zzz", progress: 0.1 })).toBe(shelf); + }); +}); diff --git a/apps/books/src/logic/library.ts b/apps/books/src/logic/library.ts index 03c539ad..43a51370 100644 --- a/apps/books/src/logic/library.ts +++ b/apps/books/src/logic/library.ts @@ -146,6 +146,27 @@ export function continueReading(books: readonly Book[]): Book[] { return sortLibrary(books.filter(isInProgress), LibrarySort.Recent); } +/** The open book's progress as its mounted reader currently measures it. */ +export type LiveProgress = { bookId: string; progress: number }; + +/** Overlay the open reader's live progress onto the shelf. Progress is + * measured to the END of the visible page, so it depends on the pagination + * (viewport × typography) — the stored fraction is only true for the layout + * that last turned a page. Every surface that shows the open book's progress + * reads through this, so they cannot disagree with the reader footer. */ +export function withLiveProgress( + books: readonly Book[], + live: LiveProgress | null, +): readonly Book[] { + if (live === null) return books; + const index = books.findIndex((b) => b.id === live.bookId); + const book = books[index]; + if (!book || book.reading.progress === live.progress) return books; + const next = [...books]; + next[index] = { ...book, reading: { ...book.reading, progress: live.progress } }; + return next; +} + /** The persistence seam for per-book reading state. The reader calls * `saveReadingPosition` whenever the parked locator changes; the preview * drop leaves it unset (in-memory only), and 9.21.2 wires it to a diff --git a/apps/books/src/render/pdf-reader.ts b/apps/books/src/render/pdf-reader.ts index 2bbb7a83..70961b2e 100644 --- a/apps/books/src/render/pdf-reader.ts +++ b/apps/books/src/render/pdf-reader.ts @@ -75,6 +75,9 @@ export type PdfReaderOptions = { * with the stable locator + progress (0..1), mirroring the reflow * reader's contract so the host persists both modes identically. */ onPositionChange?: (locator: Locator, progress: number) => void; + /** Fired with the progress the footer shows whenever it changes, + * including on mount — mirrors the reflow reader. Display-only. */ + onProgressChange?: (progress: number) => void; /** Fired when a link in the page is clicked — the host opens it (web links * go to the browser via the `open` intent). Absent = links render but do * nothing on click. */ @@ -215,6 +218,8 @@ export function mountPdfReader( return isSpread() ? 2 : 1; } + let reportedProgress: number | null = null; + function paint(): void { if (disposed) return; applyView(); @@ -231,9 +236,14 @@ export function mountPdfReader( : t("reader.pageStatus", { page: String(state.pageIndex + 1), total }); status.textContent = pageStatus; leftCanvas.setAttribute("aria-label", `${title} — ${pageStatus}`); + const fraction = pdfProgress(state); progress.textContent = t("reader.progress", { - percent: String(Math.round(pdfProgress(state) * 100)), + percent: String(Math.round(fraction * 100)), }); + if (fraction !== reportedProgress) { + reportedProgress = fraction; + options.onProgressChange?.(fraction); + } prev.disabled = !canGoPrevPdf(state); next.disabled = !canGoNextPdf(state); if (state.pageCount <= 0) return; diff --git a/apps/books/src/render/reader.test.ts b/apps/books/src/render/reader.test.ts index e71ec2f3..d6732d33 100644 --- a/apps/books/src/render/reader.test.ts +++ b/apps/books/src/render/reader.test.ts @@ -104,6 +104,35 @@ describe("reader render with a measured page box", () => { }); }); +describe("reader live progress", () => { + const footerPercent = (root: HTMLElement): number => + Number(/(\d+)%/.exec(root.querySelector(".books__progress")?.textContent ?? "")?.[1]); + + // The footer was the only surface that knew the live number; the shelf row + // and the inspector showed the stored one until the next page turn. + it("reports the footer's progress on mount, before any page turn", () => { + const { root, right } = scaffold(); + const seen: number[] = []; + handle = mountReader(root, right, SAMPLE_BOOK_CONTENT, { + onProgressChange: (p) => seen.push(p), + }); + expect(seen).toHaveLength(1); + expect(Math.round((seen[0] ?? -1) * 100)).toBe(footerPercent(root)); + }); + + it("reports again when a page turn moves it, and stays in step with the footer", () => { + const { root, right } = scaffold(); + const seen: number[] = []; + handle = mountReader(root, right, SAMPLE_BOOK_CONTENT, { + onProgressChange: (p) => seen.push(p), + }); + root.querySelector(".books__nav-btn:last-of-type")?.click(); + expect(seen).toHaveLength(2); + expect(seen[1]).toBeGreaterThan(seen[0] ?? 1); + expect(Math.round((seen[1] ?? -1) * 100)).toBe(footerPercent(root)); + }); +}); + describe("reader render", () => { it("paints the typography controls + the first page content + page status", () => { const { root, right } = scaffold(); diff --git a/apps/books/src/render/reader.ts b/apps/books/src/render/reader.ts index 2f4bf761..0a140218 100644 --- a/apps/books/src/render/reader.ts +++ b/apps/books/src/render/reader.ts @@ -126,6 +126,11 @@ export type ReaderOptions = { * it. The preview drop leaves it unset (in-memory only). Mirrors * `onTypographyChange`. */ onPositionChange?: (locator: Locator, progress: number) => void; + /** Fired with the progress the footer shows whenever it changes — + * including on mount and on a re-pagination that moves no locator + * (progress is measured to the end of the visible page, so a resize + * changes it). Display-only: nothing is persisted off this. */ + onProgressChange?: (progress: number) => void; /** The book whose highlights these are — the `Highlight/v1.bookId`. */ bookId?: string; /** The highlight persistence seam. 9.21.6 wires these to `Highlight/v1` @@ -231,6 +236,8 @@ export function mountReader( } } + let reportedProgress: number | null = null; + function paint(): void { applyTypographyVars(); const current = currentPage(state); @@ -255,9 +262,14 @@ export function mountReader( page: String(state.pageIndex + 1), total: String(total), }); + const fraction = readingProgress(state); progress.textContent = t("reader.progress", { - percent: String(Math.round(readingProgress(state) * 100)), + percent: String(Math.round(fraction * 100)), }); + if (fraction !== reportedProgress) { + reportedProgress = fraction; + options.onProgressChange?.(fraction); + } prev.disabled = !canGoPrev(state); next.disabled = !canGoNext(state); } diff --git a/apps/books/src/styles.css b/apps/books/src/styles.css index 3b19375e..97d22b42 100644 --- a/apps/books/src/styles.css +++ b/apps/books/src/styles.css @@ -84,14 +84,19 @@ body { * open each line ran on underneath it: every paragraph appeared hard-cut * mid-word at the panel edge, and the glass blur turned the occluded tail of * each line into a grey bar inside the panel that read as a stuck loading - * skeleton beside "Author — Empty". Reserving the panel's width on the stage - * fixes both: the column recentres in the width that is actually visible. */ + * skeleton beside "Author — Empty". Reserving the panel's width fixes both: + * the column recentres in the width that is actually visible. + * + * The reservation sits on the reader ROOT, not the stage: the footer is the + * stage's sibling, so a stage-only inset left it full-bleed and its + * next-page button (the trailing end of a space-between row) under the panel. + * Padding keeps the page background running beneath the glass. */ .books__layout { --books-inspector-width: 320px; } -.books__layout[data-inspector-open="true"] .books__stage { - padding-inline-end: calc(var(--space-4) + var(--books-inspector-width)); +.books__layout[data-inspector-open="true"] .books { + padding-inline-end: var(--books-inspector-width); } .books__content { @@ -387,6 +392,15 @@ body { padding-top: 0; } +/* The shared progress cell is `width: 100%` plus a -4px inline margin (a + * hover bleed for its editable face). As a growing flex item that makes it + * 8px wider than the value column, so its trailing number ran past the + * panel padding. Books' progress is read-only — no hover face to bleed. */ +:root .books__props .bs-cell-progress { + margin-inline: 0; + padding-inline: 0; +} + /* Separate the table of contents from the property rows with the same 1px divider the meta footer uses, so CONTENTS reads as its own section. */ .books__toc { @@ -451,6 +465,9 @@ body { flex-direction: column; flex: 1 1 auto; min-height: 0; + /* Matches the inspector's own slide transition so the column glides to + * its new centre instead of jumping. */ + transition: padding-inline-end var(--motion-duration-normal, 180ms) ease; background: var(--reader-bg, var(--bg)); color: var(--reader-text, var(--text)); --reader-font-family: var(--text-family-body, var(--text-family-ui)); @@ -547,9 +564,6 @@ body { display: flex; justify-content: center; padding: var(--space-6) var(--space-4); - /* Matches the inspector's own slide transition so the column glides to - * its new centre instead of jumping. */ - transition: padding-inline-end var(--motion-duration-normal, 180ms) ease; } .books__page { diff --git a/apps/books/src/ui/inspector.tsx b/apps/books/src/ui/inspector.tsx index 1642412c..2b5434ed 100644 --- a/apps/books/src/ui/inspector.tsx +++ b/apps/books/src/ui/inspector.tsx @@ -56,7 +56,7 @@ export function BookInspector({ onClose, }: BookInspectorProps): ReactElement { const values = bookToValues(book); - const rows: PropertiesPanelRow[] = bookPropertyDefs().map((def) => { + const rows: PropertiesPanelRow[] = bookPropertyDefs(book.format).map((def) => { const locked = readOnly || READONLY_BOOK_PROP_KEYS.has(def.key); const row: PropertiesPanelRow = { def, value: values[def.key], readOnly: locked }; if (!locked) { diff --git a/apps/browser/src/app-features.test.tsx b/apps/browser/src/app-features.test.tsx index 853a7243..0a53028c 100644 --- a/apps/browser/src/app-features.test.tsx +++ b/apps/browser/src/app-features.test.tsx @@ -22,7 +22,7 @@ import { BrowserApp } from "./app"; import { type HistoryVisit, historyRecordToProperties } from "./logic/history"; import { PERSIST_DEBOUNCE_MS, sessionRecordToProperties } from "./logic/persistence"; import type { EntityRecord } from "./runtime"; -import type { BrowsingSessionRecord } from "./types/browsing-session"; +import { type BrowsingSessionRecord, NEW_TAB_URL } from "./types/browsing-session"; const popupStateListeners = vi.hoisted(() => [] as Array<(open: boolean) => void>); vi.mock("@brainstorm-os/sdk/menus", async (importOriginal) => ({ @@ -326,6 +326,38 @@ describe("BrowsingSession/v1 restore", () => { expect(webView.bounds.some((b) => b.tabId === restoredOpen?.tabId)).toBe(true); }); + it("shows the start page when the restored ACTIVE tab is a blank new tab", async () => { + const stored = storedRecord(); + const record: BrowsingSessionRecord = { + ...stored, + tabs: [ + ...stored.tabs, + { + id: "old-3", + url: NEW_TAB_URL, + title: "", + faviconUrl: null, + pinned: false, + history: [], + historyIndex: -1, + }, + ], + activeTabId: "old-3", + }; + install([{ ...sessionRow(), properties: sessionRecordToProperties(record) }]); + await render(); + await act(async () => {}); + + expect(tabTitles()).toEqual(["Tab A", "Tab B", "New tab"]); + expect(container.querySelector(".browser-start")).not.toBeNull(); + const restoredOpen = webView.opened.at(-1); + expect(restoredOpen?.url).toBe(NEW_TAB_URL); + // The native view composites above the chrome, so it must be parked or + // it covers the start page. + const lastBounds = webView.bounds.filter((b) => b.tabId === restoredOpen?.tabId).at(-1); + expect(lastBounds?.rect).toEqual({ x: 0, y: 0, width: 0, height: 0 }); + }); + it("keeps a fresh session when nothing was stored", async () => { await render(); await act(async () => {}); diff --git a/apps/browser/src/logic/persistence.test.ts b/apps/browser/src/logic/persistence.test.ts index 6aa0dd7d..a29e4cab 100644 Binary files a/apps/browser/src/logic/persistence.test.ts and b/apps/browser/src/logic/persistence.test.ts differ diff --git a/apps/browser/src/logic/persistence.ts b/apps/browser/src/logic/persistence.ts index fb48a250..eda4efaf 100644 --- a/apps/browser/src/logic/persistence.ts +++ b/apps/browser/src/logic/persistence.ts @@ -16,7 +16,7 @@ import { sanitizeInlineText } from "@brainstorm-os/sdk/sanitize-text"; import type { BrowsingSessionRecord, TabSnapshot } from "../types/browsing-session"; -import { MAX_RECENTLY_CLOSED } from "../types/browsing-session"; +import { MAX_RECENTLY_CLOSED, NEW_TAB_URL } from "../types/browsing-session"; import { isWebUrl } from "./external-open"; /** Per-tab history bound in the persisted record — a long-lived tab's @@ -86,7 +86,11 @@ function parseTab(input: unknown): TabSnapshot | null { : currentEntry !== undefined && isWebUrl(currentEntry) ? Math.max(history.indexOf(currentEntry), 0) : history.length - 1; - const url = isWebUrl(raw.url) ? raw.url : (history[historyIndex] ?? ""); + // A tab with nothing web to restore IS a blank new tab: the chrome keys the + // start page (and parking the native view under it) on `NEW_TAB_URL`, so an + // empty string here restored a tab that showed neither a page nor the start + // page. + const url = isWebUrl(raw.url) ? raw.url : (history[historyIndex] ?? NEW_TAB_URL); return { id: raw.id, url, diff --git a/apps/browser/src/styles.css b/apps/browser/src/styles.css index cbe101a6..ba3d16aa 100644 --- a/apps/browser/src/styles.css +++ b/apps/browser/src/styles.css @@ -63,7 +63,10 @@ body { align-items: center; gap: var(--space-1, var(--space-1)); height: 30px; - min-width: 96px; + /* Floor sized for the chrome (12 + 14 favicon + 8 + 4 + 18 close + 4) plus a + * short title: at 96px only ~36px was left and "New tab" ellipsised to + * "Ne…" beside 190px neighbours. The strip scrolls, so a floor is safe. */ + min-width: 128px; max-width: 220px; padding: 0 var(--space-1, var(--space-1)) 0 var(--space-3, var(--space-3)); border-radius: var(--radius-md); diff --git a/apps/chat/src/app.tsx b/apps/chat/src/app.tsx index 06e71134..711d0e60 100644 --- a/apps/chat/src/app.tsx +++ b/apps/chat/src/app.tsx @@ -865,7 +865,9 @@ export function ChatApp(): ReactElement { aria-haspopup="menu" onClick={openMore} > - + + + @@ -932,8 +934,8 @@ export function ChatApp(): ReactElement {
- + + + ) : null} {m.richBody ? ( diff --git a/apps/chat/src/format.test.ts b/apps/chat/src/format.test.ts index a4f0ead9..422bee9b 100644 --- a/apps/chat/src/format.test.ts +++ b/apps/chat/src/format.test.ts @@ -1,8 +1,9 @@ -import { describe, expect, it } from "vitest"; +import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { formatDay, formatStamp, formatTime } from "./format"; +import { dayKey } from "./logic/chat"; describe("chat time formatting (Chats-3)", () => { - const now = new Date("2026-06-20T15:00:00.000Z"); + const now = new Date(2026, 5, 20, 15, 0, 0); it("labels today / yesterday by default", () => { expect(formatDay("2026-06-20", false, now)).toBe("Today"); @@ -27,3 +28,37 @@ describe("chat time formatting (Chats-3)", () => { expect(formatDay("nope", true)).toBe("nope"); }); }); + +describe("day divider agrees with the displayed time", () => { + const savedTz = process.env.TZ; + afterAll(() => { + if (savedTz === undefined) Reflect.deleteProperty(process.env, "TZ"); + else process.env.TZ = savedTz; + }); + + describe.each(["Europe/Berlin", "America/Los_Angeles", "Pacific/Auckland"])("in %s", (tz) => { + beforeAll(() => { + process.env.TZ = tz; + }); + + it("labels the divider with the same local date the timestamp shows", () => { + for (const iso of ["2026-08-01T22:53:00.000Z", "2026-08-02T06:30:00.000Z"]) { + const local = new Date(iso); + const expected = local.toLocaleDateString("en", { + weekday: "long", + year: "numeric", + month: "short", + day: "numeric", + }); + expect(formatDay(dayKey(iso), true, local)).toBe(expected); + } + }); + + it("calls a message sent just after local midnight Today, not Yesterday", () => { + const iso = "2026-08-01T22:53:00.000Z"; + const now = new Date(Date.parse(iso) + 60_000); + expect(formatDay(dayKey(iso), false, now)).toBe("Today"); + expect(formatDay(dayKey("2026-07-31T22:53:00.000Z"), false, now)).toBe("Yesterday"); + }); + }); +}); diff --git a/apps/chat/src/format.ts b/apps/chat/src/format.ts index 22d16dea..c6b4e791 100644 --- a/apps/chat/src/format.ts +++ b/apps/chat/src/format.ts @@ -32,10 +32,11 @@ export function formatStamp(iso: string): string { /** A day-divider label: Today / Yesterday / a localized date. With `absolute` * (Chats-3) the relative labels give way to the full date. */ export function formatDay(dayKey: string, absolute = false, now: Date = new Date()): string { - const ms = Date.parse(dayKey); - if (!Number.isFinite(ms)) return dayKey; - const that = new Date(ms); - const startOf = (d: Date) => Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()); + const parts = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dayKey); + if (!parts) return dayKey; + // A bare `YYYY-MM-DD` parses as UTC midnight; the key is a LOCAL day. + const that = new Date(Number(parts[1]), Number(parts[2]) - 1, Number(parts[3])); + const startOf = (d: Date) => Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()); const diffDays = Math.round((startOf(now) - startOf(that)) / 86_400_000); if (!absolute) { if (diffDays === 0) return t("day.today"); diff --git a/apps/chat/src/i18n/de.json b/apps/chat/src/i18n/de.json index 040ef866..bda0e7b0 100644 --- a/apps/chat/src/i18n/de.json +++ b/apps/chat/src/i18n/de.json @@ -14,6 +14,8 @@ "channel.empty.blurb": "Sag Hallo, um das Gespräch in #{name} zu beginnen.", "channel.none.title": "Wähle einen Kanal", "channel.none.blurb": "Wähle links einen Kanal oder erstelle einen, um zu chatten.", + "channel.first.title": "Erstelle deinen ersten Kanal", + "channel.first.blurb": "Ein Kanal hält ein Gespräch an einem Ort. Erstelle einen, um zu chatten.", "composer.placeholder": "Nachricht an #{name}…", "composer.send": "Senden", "composer.attach.button": "Kontext hinzufügen", diff --git a/apps/chat/src/i18n/en.json b/apps/chat/src/i18n/en.json index 733c3e14..886b08cb 100644 --- a/apps/chat/src/i18n/en.json +++ b/apps/chat/src/i18n/en.json @@ -14,6 +14,8 @@ "channel.empty.blurb": "Say hello to start the conversation in #{name}.", "channel.none.title": "Pick a channel", "channel.none.blurb": "Choose a channel on the left, or create one to start chatting.", + "channel.first.title": "Start your first channel", + "channel.first.blurb": "A channel keeps one conversation in one place. Create one to start chatting.", "composer.placeholder": "Message #{name}…", "composer.send": "Send", "composer.attach.button": "Add context", diff --git a/apps/chat/src/i18n/es.json b/apps/chat/src/i18n/es.json index 0a8370e1..a348d078 100644 --- a/apps/chat/src/i18n/es.json +++ b/apps/chat/src/i18n/es.json @@ -14,6 +14,8 @@ "channel.empty.blurb": "Saluda para iniciar la conversación en #{name}.", "channel.none.title": "Elige un canal", "channel.none.blurb": "Elige un canal a la izquierda o crea uno para empezar a chatear.", + "channel.first.title": "Crea tu primer canal", + "channel.first.blurb": "Un canal mantiene una conversación en un solo lugar. Crea uno para empezar a chatear.", "composer.placeholder": "Mensaje en #{name}…", "composer.send": "Enviar", "composer.attach.button": "Añadir contexto", diff --git a/apps/chat/src/i18n/fr.json b/apps/chat/src/i18n/fr.json index 1d24c7a9..21c60836 100644 --- a/apps/chat/src/i18n/fr.json +++ b/apps/chat/src/i18n/fr.json @@ -14,6 +14,8 @@ "channel.empty.blurb": "Dites bonjour pour lancer la conversation dans #{name}.", "channel.none.title": "Choisissez un canal", "channel.none.blurb": "Choisissez un canal à gauche, ou créez-en un pour commencer à discuter.", + "channel.first.title": "Créez votre premier canal", + "channel.first.blurb": "Un canal garde une conversation au même endroit. Créez-en un pour commencer à discuter.", "composer.placeholder": "Message à #{name}…", "composer.send": "Envoyer", "composer.attach.button": "Ajouter du contexte", diff --git a/apps/chat/src/i18n/it.json b/apps/chat/src/i18n/it.json index 8e6e63a8..6a2bfd34 100644 --- a/apps/chat/src/i18n/it.json +++ b/apps/chat/src/i18n/it.json @@ -14,6 +14,8 @@ "channel.empty.blurb": "Saluta per iniziare la conversazione in #{name}.", "channel.none.title": "Scegli un canale", "channel.none.blurb": "Scegli un canale a sinistra, o creane uno per iniziare a chattare.", + "channel.first.title": "Crea il tuo primo canale", + "channel.first.blurb": "Un canale tiene una conversazione in un unico posto. Creane uno per iniziare a chattare.", "composer.placeholder": "Messaggio a #{name}…", "composer.send": "Invia", "composer.attach.button": "Aggiungi contesto", diff --git a/apps/chat/src/i18n/pt.json b/apps/chat/src/i18n/pt.json index f958e1cb..0a12b9e3 100644 --- a/apps/chat/src/i18n/pt.json +++ b/apps/chat/src/i18n/pt.json @@ -14,6 +14,8 @@ "channel.empty.blurb": "Diga olá para começar a conversa em #{name}.", "channel.none.title": "Escolha um canal", "channel.none.blurb": "Escolha um canal à esquerda, ou crie um para começar a conversar.", + "channel.first.title": "Crie o seu primeiro canal", + "channel.first.blurb": "Um canal mantém uma conversa num só lugar. Crie um para começar a conversar.", "composer.placeholder": "Mensagem para #{name}…", "composer.send": "Enviar", "composer.attach.button": "Adicionar contexto", diff --git a/apps/chat/src/logic/chat.test.ts b/apps/chat/src/logic/chat.test.ts index 62fb9e3e..c623d301 100644 --- a/apps/chat/src/logic/chat.test.ts +++ b/apps/chat/src/logic/chat.test.ts @@ -6,7 +6,7 @@ import { RosterRole, SenderKind, } from "@brainstorm-os/sdk-types"; -import { describe, expect, it } from "vitest"; +import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { AUTHOR_COLORS, CHANNEL_TYPE, @@ -187,14 +187,14 @@ describe("groupMessages", () => { ref: "p1", name: "Mira", body: "a", - createdAt: "2026-06-20T23:59:00Z", + createdAt: new Date(2026, 5, 20, 23, 59, 0).toISOString(), seq: 0, }), message("m2", "c", { ref: "p1", name: "Mira", body: "b", - createdAt: "2026-06-21T00:00:30Z", + createdAt: new Date(2026, 5, 21, 0, 0, 30).toISOString(), seq: 1, }), ], @@ -207,6 +207,54 @@ describe("groupMessages", () => { }); }); +describe("day grouping follows the local calendar day", () => { + const color = (ref: string) => `color-${ref}`; + const savedTz = process.env.TZ; + beforeAll(() => { + process.env.TZ = "Europe/Berlin"; + }); + afterAll(() => { + if (savedTz === undefined) Reflect.deleteProperty(process.env, "TZ"); + else process.env.TZ = savedTz; + }); + + it("keys a just-after-local-midnight message to the new day", () => { + expect(new Date("2026-08-01T22:53:00.000Z").getHours()).toBe(0); + expect(dayKey("2026-08-01T20:11:00.000Z")).toBe("2026-08-01"); + expect(dayKey("2026-08-01T22:53:00.000Z")).toBe("2026-08-02"); + }); + + it("splits a group at local midnight even inside one UTC day", () => { + const rows = channelMessages( + [ + message("m1", "c", { + ref: "p1", + name: "Mira", + body: "late", + createdAt: "2026-08-01T21:58:00.000Z", + seq: 0, + }), + message("m2", "c", { + ref: "p1", + name: "Mira", + body: "after midnight", + createdAt: "2026-08-01T22:01:00.000Z", + seq: 1, + }), + ], + "c", + ); + expect(groupMessages(rows, color).map((g) => g.dayKey)).toEqual(["2026-08-01", "2026-08-02"]); + }); + + it("keeps one local day together across a UTC date change", () => { + process.env.TZ = "America/Los_Angeles"; + expect(dayKey("2026-08-01T23:30:00.000Z")).toBe("2026-08-01"); + expect(dayKey("2026-08-02T00:30:00.000Z")).toBe("2026-08-01"); + process.env.TZ = "Europe/Berlin"; + }); +}); + describe("membersFromMessages", () => { it("lists distinct authors in first-seen order", () => { const rows = channelMessages( @@ -316,8 +364,8 @@ describe("initials", () => { }); describe("dayKey", () => { - it("returns the UTC date portion of an ISO stamp", () => { - expect(dayKey("2026-06-20T10:00:00.000Z")).toBe("2026-06-20"); + it("returns the local calendar date of an ISO stamp", () => { + expect(dayKey(new Date(2026, 5, 20, 10, 0, 0).toISOString())).toBe("2026-06-20"); expect(dayKey("nope")).toBe("nope"); }); }); diff --git a/apps/chat/src/logic/chat.ts b/apps/chat/src/logic/chat.ts index a358f495..dd40ae25 100644 --- a/apps/chat/src/logic/chat.ts +++ b/apps/chat/src/logic/chat.ts @@ -240,10 +240,16 @@ export function nextSeq(messages: readonly ChatMessage[]): number { // ─────────────────────────────── grouping ─────────────────────────────── -/** `YYYY-MM-DD` (UTC) of an ISO timestamp; "" when unparseable. */ +/** `YYYY-MM-DD` of an ISO timestamp in the viewer's LOCAL calendar — the same + * zone the message time renders in, so a divider can never disagree with the + * stamps beneath it. An unparseable stamp is returned as-is. */ export function dayKey(iso: string): string { - const idx = iso.indexOf("T"); - return idx > 0 ? iso.slice(0, idx) : iso; + const ms = Date.parse(iso); + if (!Number.isFinite(ms)) return iso; + const d = new Date(ms); + const month = String(d.getMonth() + 1).padStart(2, "0"); + const day = String(d.getDate()).padStart(2, "0"); + return `${d.getFullYear()}-${month}-${day}`; } /** Messages within this many ms by the same author collapse into one group. */ diff --git a/apps/chat/src/styles.css b/apps/chat/src/styles.css index a80ee941..4637f4a1 100644 --- a/apps/chat/src/styles.css +++ b/apps/chat/src/styles.css @@ -119,7 +119,7 @@ body { flex-direction: column; min-height: 0; border-right: 1px solid var(--border-subtle); - background: var(--bg-subtle); + background: var(--bg); z-index: 2; transition: transform var(--motion-duration-normal, 180ms) ease, @@ -834,7 +834,9 @@ body { height: 24px; opacity: 0; background: var(--bg-elev); - border: 1px solid var(--border-subtle); + border: 1px solid var(--border-strong); + color: var(--text); + gap: var(--space-0_5); } .chat__line-wrap:hover .chat__line-more, diff --git a/apps/database/src/i18n/de.json b/apps/database/src/i18n/de.json index e2ae4e66..c63c4efa 100644 --- a/apps/database/src/i18n/de.json +++ b/apps/database/src/i18n/de.json @@ -13,7 +13,7 @@ "brainstorm.database.menu.moveToColumn": "In Spalte verschieben…", "brainstorm.database.menu.moveToColumn.none": "Kein Wert", "brainstorm.database.view.new": "Neue Ansicht", - "brainstorm.database.view.empty": "Keine Entitäten entsprechen dieser Ansicht.", + "brainstorm.database.view.empty": "Keine Objekte entsprechen dieser Ansicht.", "brainstorm.database.board.empty": "Karten hier ablegen", "brainstorm.database.view.menu.rename": "Umbenennen", "brainstorm.database.view.menu.duplicate": "Duplizieren", @@ -43,7 +43,6 @@ "brainstorm.database.timeline.emptyNoDateProperty": "Diese Sammlung hat keine Datumseigenschaft zum Anordnen. Fügen Sie eine Datumsspalte hinzu und verknüpfen Sie sie unter Ansichtseinstellungen → Daten.", "brainstorm.database.vault.allItems": "Alle Vault-Elemente", "brainstorm.database.vault.allItems.description": "{items} in {types}", - "brainstorm.database.vault.typeList.description": "{items} · {type}", "brainstorm.database.vault.items.one": "{count} Element", "brainstorm.database.vault.items.other": "{count} Elemente", "brainstorm.database.vault.types.one": "{count} Typ", @@ -86,7 +85,7 @@ "brainstorm.database.stage.descriptionPlaceholder": "Beschreibung hinzufügen…", "brainstorm.database.stage.descriptionAria": "Beschreibung der Sammlung", "brainstorm.database.empty.vault.title": "Noch nichts hier", - "brainstorm.database.empty.vault.body": "Dieser Vault enthält keine Entitäten. Erstellen Sie Notizen, Aufgaben oder andere Elemente in ihren Apps — sie erscheinen hier automatisch.", + "brainstorm.database.empty.vault.body": "Dieser Vault ist leer. Erstellen Sie Notizen, Aufgaben oder andere Elemente in ihren Apps — sie erscheinen hier automatisch.", "brainstorm.database.empty.noView.title": "Keine Ansicht ausgewählt", "brainstorm.database.empty.noView.body": "Wählen Sie in der Seitenleiste eine Liste aus, um zu beginnen.", "brainstorm.database.empty.noDate.title": "Kein Datum zum Einplanen", diff --git a/apps/database/src/i18n/en.json b/apps/database/src/i18n/en.json index 7446b21f..57278dd6 100644 --- a/apps/database/src/i18n/en.json +++ b/apps/database/src/i18n/en.json @@ -13,7 +13,7 @@ "brainstorm.database.menu.moveToColumn": "Move to column…", "brainstorm.database.menu.moveToColumn.none": "No value", "brainstorm.database.view.new": "New view", - "brainstorm.database.view.empty": "No entities match this view.", + "brainstorm.database.view.empty": "Nothing matches this view.", "brainstorm.database.board.empty": "Drop cards here", "brainstorm.database.view.menu.rename": "Rename", "brainstorm.database.view.menu.duplicate": "Duplicate", @@ -43,7 +43,6 @@ "brainstorm.database.timeline.emptyNoDateProperty": "This collection has no date property to lay out. Add a date column, then bind it under View settings → Dates.", "brainstorm.database.vault.allItems": "All vault items", "brainstorm.database.vault.allItems.description": "{items} across {types}", - "brainstorm.database.vault.typeList.description": "{items} · {type}", "brainstorm.database.vault.items.one": "{count} item", "brainstorm.database.vault.items.other": "{count} items", "brainstorm.database.vault.types.one": "{count} type", @@ -86,7 +85,7 @@ "brainstorm.database.stage.descriptionPlaceholder": "Add a description…", "brainstorm.database.stage.descriptionAria": "Collection description", "brainstorm.database.empty.vault.title": "Nothing here yet", - "brainstorm.database.empty.vault.body": "This vault has no entities. Create notes, tasks, or other items in their apps and they'll show up here automatically.", + "brainstorm.database.empty.vault.body": "This vault is empty. Create notes, tasks, or other items in their apps and they'll show up here automatically.", "brainstorm.database.empty.noView.title": "No view selected", "brainstorm.database.empty.noView.body": "Pick a list from the sidebar to get started.", "brainstorm.database.empty.noDate.title": "No date to schedule by", diff --git a/apps/database/src/i18n/es.json b/apps/database/src/i18n/es.json index a931b344..61366b6b 100644 --- a/apps/database/src/i18n/es.json +++ b/apps/database/src/i18n/es.json @@ -13,7 +13,7 @@ "brainstorm.database.menu.moveToColumn": "Mover a una columna…", "brainstorm.database.menu.moveToColumn.none": "Sin valor", "brainstorm.database.view.new": "Nueva vista", - "brainstorm.database.view.empty": "Ninguna entidad coincide con esta vista.", + "brainstorm.database.view.empty": "Ningún objeto coincide con esta vista.", "brainstorm.database.board.empty": "Suelte tarjetas aquí", "brainstorm.database.view.menu.rename": "Renombrar", "brainstorm.database.view.menu.duplicate": "Duplicar", @@ -43,7 +43,6 @@ "brainstorm.database.timeline.emptyNoDateProperty": "Esta colección no tiene ninguna propiedad de fecha que mostrar. Añada una columna de fecha y vincúlela en Ajustes de vista → Fechas.", "brainstorm.database.vault.allItems": "Todos los elementos de la bóveda", "brainstorm.database.vault.allItems.description": "{items} en {types}", - "brainstorm.database.vault.typeList.description": "{items} · {type}", "brainstorm.database.vault.items.one": "{count} elemento", "brainstorm.database.vault.items.other": "{count} elementos", "brainstorm.database.vault.types.one": "{count} tipo", @@ -86,7 +85,7 @@ "brainstorm.database.stage.descriptionPlaceholder": "Añadir una descripción…", "brainstorm.database.stage.descriptionAria": "Descripción de la colección", "brainstorm.database.empty.vault.title": "Aún no hay nada aquí", - "brainstorm.database.empty.vault.body": "Esta bóveda no tiene entidades. Cree notas, tareas u otros elementos en sus aplicaciones y aparecerán aquí automáticamente.", + "brainstorm.database.empty.vault.body": "Esta bóveda está vacía. Cree notas, tareas u otros elementos en sus aplicaciones y aparecerán aquí automáticamente.", "brainstorm.database.empty.noView.title": "Ninguna vista seleccionada", "brainstorm.database.empty.noView.body": "Elija una lista en la barra lateral para empezar.", "brainstorm.database.empty.noDate.title": "Sin fecha para planificar", diff --git a/apps/database/src/i18n/fr.json b/apps/database/src/i18n/fr.json index 084f8088..82822fe8 100644 --- a/apps/database/src/i18n/fr.json +++ b/apps/database/src/i18n/fr.json @@ -13,7 +13,7 @@ "brainstorm.database.menu.moveToColumn": "Déplacer vers une colonne…", "brainstorm.database.menu.moveToColumn.none": "Aucune valeur", "brainstorm.database.view.new": "Nouvelle vue", - "brainstorm.database.view.empty": "Aucune entité ne correspond à cette vue.", + "brainstorm.database.view.empty": "Aucun objet ne correspond à cette vue.", "brainstorm.database.board.empty": "Déposez des cartes ici", "brainstorm.database.view.menu.rename": "Renommer", "brainstorm.database.view.menu.duplicate": "Dupliquer", @@ -43,7 +43,6 @@ "brainstorm.database.timeline.emptyNoDateProperty": "Cette collection n'a aucune propriété de date à afficher. Ajoutez une colonne de date, puis liez-la dans Réglages de la vue → Dates.", "brainstorm.database.vault.allItems": "Tous les éléments du coffre", "brainstorm.database.vault.allItems.description": "{items} répartis sur {types}", - "brainstorm.database.vault.typeList.description": "{items} · {type}", "brainstorm.database.vault.items.one": "{count} élément", "brainstorm.database.vault.items.other": "{count} éléments", "brainstorm.database.vault.types.one": "{count} type", @@ -86,7 +85,7 @@ "brainstorm.database.stage.descriptionPlaceholder": "Ajouter une description…", "brainstorm.database.stage.descriptionAria": "Description de la collection", "brainstorm.database.empty.vault.title": "Rien ici pour l'instant", - "brainstorm.database.empty.vault.body": "Ce coffre ne contient aucune entité. Créez des notes, des tâches ou d'autres éléments dans leurs applications et ils apparaîtront ici automatiquement.", + "brainstorm.database.empty.vault.body": "Ce coffre est vide. Créez des notes, des tâches ou d'autres éléments dans leurs applications et ils apparaîtront ici automatiquement.", "brainstorm.database.empty.noView.title": "Aucune vue sélectionnée", "brainstorm.database.empty.noView.body": "Choisissez une liste dans la barre latérale pour commencer.", "brainstorm.database.empty.noDate.title": "Aucune date pour planifier", diff --git a/apps/database/src/i18n/it.json b/apps/database/src/i18n/it.json index a4e3e98c..a4de7b36 100644 --- a/apps/database/src/i18n/it.json +++ b/apps/database/src/i18n/it.json @@ -13,7 +13,7 @@ "brainstorm.database.menu.moveToColumn": "Sposta in una colonna…", "brainstorm.database.menu.moveToColumn.none": "Nessun valore", "brainstorm.database.view.new": "Nuova vista", - "brainstorm.database.view.empty": "Nessuna entità corrisponde a questa vista.", + "brainstorm.database.view.empty": "Nessun oggetto corrisponde a questa vista.", "brainstorm.database.board.empty": "Rilascia qui le schede", "brainstorm.database.view.menu.rename": "Rinomina", "brainstorm.database.view.menu.duplicate": "Duplica", @@ -43,7 +43,6 @@ "brainstorm.database.timeline.emptyNoDateProperty": "Questa raccolta non ha proprietà data da disporre. Aggiungi una colonna data e collegala in Impostazioni vista → Date.", "brainstorm.database.vault.allItems": "Tutti gli elementi del vault", "brainstorm.database.vault.allItems.description": "{items} in {types}", - "brainstorm.database.vault.typeList.description": "{items} · {type}", "brainstorm.database.vault.items.one": "{count} elemento", "brainstorm.database.vault.items.other": "{count} elementi", "brainstorm.database.vault.types.one": "{count} tipo", @@ -86,7 +85,7 @@ "brainstorm.database.stage.descriptionPlaceholder": "Aggiungi una descrizione…", "brainstorm.database.stage.descriptionAria": "Descrizione della raccolta", "brainstorm.database.empty.vault.title": "Ancora niente qui", - "brainstorm.database.empty.vault.body": "Questo vault non contiene entità. Crea note, attività o altri elementi nelle rispettive app e appariranno qui automaticamente.", + "brainstorm.database.empty.vault.body": "Questo vault è vuoto. Crea note, attività o altri elementi nelle rispettive app e appariranno qui automaticamente.", "brainstorm.database.empty.noView.title": "Nessuna vista selezionata", "brainstorm.database.empty.noView.body": "Scegli un elenco nella barra laterale per iniziare.", "brainstorm.database.empty.noDate.title": "Nessuna data per pianificare", diff --git a/apps/database/src/i18n/pt.json b/apps/database/src/i18n/pt.json index f770d02b..e9c0d49a 100644 --- a/apps/database/src/i18n/pt.json +++ b/apps/database/src/i18n/pt.json @@ -13,7 +13,7 @@ "brainstorm.database.menu.moveToColumn": "Mover para uma coluna…", "brainstorm.database.menu.moveToColumn.none": "Sem valor", "brainstorm.database.view.new": "Nova visualização", - "brainstorm.database.view.empty": "Nenhuma entidade corresponde a esta visualização.", + "brainstorm.database.view.empty": "Nenhum objeto corresponde a esta visualização.", "brainstorm.database.board.empty": "Solte cartões aqui", "brainstorm.database.view.menu.rename": "Renomear", "brainstorm.database.view.menu.duplicate": "Duplicar", @@ -43,7 +43,6 @@ "brainstorm.database.timeline.emptyNoDateProperty": "Esta coleção não tem nenhuma propriedade de data para exibir. Adicione uma coluna de data e vincule-a em Configurações da visualização → Datas.", "brainstorm.database.vault.allItems": "Todos os itens do vault", "brainstorm.database.vault.allItems.description": "{items} em {types}", - "brainstorm.database.vault.typeList.description": "{items} · {type}", "brainstorm.database.vault.items.one": "{count} item", "brainstorm.database.vault.items.other": "{count} itens", "brainstorm.database.vault.types.one": "{count} tipo", @@ -86,7 +85,7 @@ "brainstorm.database.stage.descriptionPlaceholder": "Adicionar uma descrição…", "brainstorm.database.stage.descriptionAria": "Descrição da coleção", "brainstorm.database.empty.vault.title": "Ainda não há nada aqui", - "brainstorm.database.empty.vault.body": "Este vault não tem entidades. Crie notas, tarefas ou outros itens em seus aplicativos e eles aparecerão aqui automaticamente.", + "brainstorm.database.empty.vault.body": "Este vault está vazio. Crie notas, tarefas ou outros itens em seus aplicativos e eles aparecerão aqui automaticamente.", "brainstorm.database.empty.noView.title": "Nenhuma visualização selecionada", "brainstorm.database.empty.noView.body": "Escolha uma lista na barra lateral para começar.", "brainstorm.database.empty.noDate.title": "Sem data para agendar", diff --git a/apps/database/src/logic/vault-lists.test.ts b/apps/database/src/logic/vault-lists.test.ts index e2b5a024..5c51fee7 100644 --- a/apps/database/src/logic/vault-lists.test.ts +++ b/apps/database/src/logic/vault-lists.test.ts @@ -272,7 +272,7 @@ describe("buildVaultLists", () => { links: [], }; const { lists } = buildVaultLists(one, NOW); - expect(lists[0]?.description).toBe("1 item · brainstorm/Doc/v1"); + expect(lists[0]?.description).toBe("1 item"); }); }); @@ -374,7 +374,7 @@ describe("curated People list (9.12.13(b))", () => { (l) => l.source?.kind === ListSourceKind.ByType && l.source.types[0] === "brainstorm/Person/v1", ); expect(people?.name).toBe("People"); - expect(people?.description).toBe("2 contacts · brainstorm/Person/v1"); + expect(people?.description).toBe("2 contacts"); expect(people?.views).toHaveLength(3); expect(people?.defaultViewId).toBe(people?.views[0]); @@ -439,7 +439,7 @@ describe("curated Tasks list (9.14.4)", () => { (l) => l.source?.kind === ListSourceKind.ByType && l.source.types[0] === "brainstorm/Task/v1", ); expect(tasks?.name).toBe("Tasks"); - expect(tasks?.description).toBe("2 tasks · brainstorm/Task/v1"); + expect(tasks?.description).toBe("2 tasks"); expect(tasks?.views).toHaveLength(3); expect(tasks?.defaultViewId).toBe(tasks?.views[0]); @@ -499,6 +499,6 @@ describe("curated Tasks list (9.14.4)", () => { links: [], }; const tasks = buildVaultLists(one, NOW).lists[0]; - expect(tasks?.description).toBe("1 task · brainstorm/Task/v1"); + expect(tasks?.description).toBe("1 task"); }); }); diff --git a/apps/database/src/logic/vault-lists.ts b/apps/database/src/logic/vault-lists.ts index c85caf14..2a2931be 100644 --- a/apps/database/src/logic/vault-lists.ts +++ b/apps/database/src/logic/vault-lists.ts @@ -142,10 +142,10 @@ export function buildVaultLists( id: listId, name: friendlyTypeName(type), icon: null, - description: t("brainstorm.database.vault.typeList.description", { - items: itemCountLabel(rows.length), - type, - }), + // The count alone: the raw type id (`brainstorm/Agent/v1`) used to + // trail it, and it was the first line of text under the first list + // a new user opened. + description: itemCountLabel(rows.length), source: { kind: ListSourceKind.ByType, types: [type] }, members: { include: [], exclude: [] }, views: [viewId], @@ -381,7 +381,7 @@ const CURATED_TYPE_LISTS: Record = { // Columns mirror the `brainstorm/Task/v1` shape (apps/tasks task.ts). "brainstorm/Task/v1": { name: "Tasks", - description: (n) => `${n} ${n === 1 ? "task" : "tasks"} · brainstorm/Task/v1`, + description: (n) => `${n} ${n === 1 ? "task" : "tasks"}`, columns: ["name", "statusKey", "priority", "scheduledAt", "dueAt"], views: [ { @@ -423,7 +423,7 @@ const CURATED_TYPE_LISTS: Record = { }, "brainstorm/Person/v1": { name: "People", - description: (n) => `${n} ${n === 1 ? "contact" : "contacts"} · brainstorm/Person/v1`, + description: (n) => `${n} ${n === 1 ? "contact" : "contacts"}`, columns: ["name", "email", "phone", "company", "role"], views: [ { diff --git a/apps/database/src/styles.css b/apps/database/src/styles.css index 153b75ed..29278f15 100644 --- a/apps/database/src/styles.css +++ b/apps/database/src/styles.css @@ -1054,6 +1054,10 @@ body.is-resizing .db-inspector__resize { align-items: baseline; gap: var(--space-2); max-width: 100%; + /* The hover face bleeds into the cell padding so the label itself ends on + * the cell's content edge — the edge the header label and the numeric + * values above it share. */ + margin-inline: calc(-1 * var(--space-1)); padding: 0 var(--space-1); border: 0; background: transparent; @@ -1170,6 +1174,17 @@ body.is-resizing .db-inspector__resize { text-align: end; } +/* The shared faces bleed 6px (pill) / 4px (plain) past the cell padding and + * inset their text 2px, which lands a right-aligned value 4px / 2px outside + * the cell's content edge. Trailing bleed = the face's own inset, so the + * numerals end exactly on the edge the header label and footer use. */ +.dbv-grid__cell--numeric > .bs-cell-pill, +.dbv-grid__cell--numeric > .bs-cell-plain, +.dbv-grid__cell--numeric .bs-cell-plain-input, +.dbv-grid__cell--numeric .bs-cell-input { + margin-inline-end: calc(-1 * var(--space-0_5)); +} + .dbv-grid__cell--numeric .bs-cell-plain-input, .dbv-grid__cell--numeric .bs-cell-input { text-align: end; @@ -1382,7 +1397,9 @@ body.is-resizing .db-inspector__resize { background: var(--bg); } -.dbv-grid[data-pinned="true"] .dbv-grid__row:not(.dbv-grid__row--head):hover .dbv-grid__cell[data-col="title"] { +.dbv-grid[data-pinned="true"] + .dbv-grid__row:not(.dbv-grid__row--head):not(.dbv-grid__row--foot):hover + .dbv-grid__cell[data-col="title"] { background: linear-gradient(var(--hover), var(--hover)), var(--bg); } @@ -1395,6 +1412,12 @@ body.is-resizing .db-inspector__resize { background: var(--bg-elev); } +/* The footer band is `--bg-elev` like the header; left on the pinned cell's + * page colour, the title cell read as a grey block set 12px into a white band. */ +.dbv-grid[data-pinned="true"] .dbv-grid__row--foot .dbv-grid__cell[data-col="title"] { + background: var(--bg-elev); +} + /* ── List view ────────────────────────────────────────────────────────── */ .dbv-list { diff --git a/apps/files/src/app.tsx b/apps/files/src/app.tsx index bf82fc0c..9da96926 100644 --- a/apps/files/src/app.tsx +++ b/apps/files/src/app.tsx @@ -59,7 +59,7 @@ import { hasActiveFilters } from "./logic/filters"; import { buildPreviewSiblings } from "./logic/preview-siblings"; import { ScopeFlipAction, SearchScope, flipScope } from "./logic/search"; import type { SmartFolder } from "./logic/smart-folders"; -import { SortDirection, SortKey } from "./logic/sort"; +import { SortKey } from "./logic/sort"; import { ActionId, chordFor } from "./shortcuts"; import { type FilesStore, useFilesStore } from "./store/use-files-store"; import { type Entity, FILE_TYPE, FOLDER_TYPE, readName } from "./types/entity"; @@ -765,11 +765,7 @@ export function FilesApp() { {t("brainstorm.files.sort.label")}: {sortLabel(store.sortKey)} - + className="view-switch" diff --git a/apps/files/src/i18n/en.json b/apps/files/src/i18n/en.json index 6748b342..94659d62 100644 --- a/apps/files/src/i18n/en.json +++ b/apps/files/src/i18n/en.json @@ -132,7 +132,7 @@ "brainstorm.files.empty.body": "Drag files in, or create a folder to get started.", "brainstorm.files.empty.newFolder": "New folder", "brainstorm.files.empty.searchTitle": "No matches", - "brainstorm.files.empty.searchBody": "No entities in this scope match {query}.", + "brainstorm.files.empty.searchBody": "Nothing in this scope matches {query}.", "brainstorm.files.inspector.tabsRegion": "Inspector tabs", "brainstorm.files.inspector.tabPreview": "Preview", "brainstorm.files.inspector.tabProperties": "Properties", diff --git a/apps/files/src/i18n/es.json b/apps/files/src/i18n/es.json index 94d8e6ce..8889fafc 100644 --- a/apps/files/src/i18n/es.json +++ b/apps/files/src/i18n/es.json @@ -132,7 +132,7 @@ "brainstorm.files.empty.body": "Arrastre archivos aquí o cree una carpeta para empezar.", "brainstorm.files.empty.newFolder": "Nueva carpeta", "brainstorm.files.empty.searchTitle": "Sin coincidencias", - "brainstorm.files.empty.searchBody": "Ninguna entidad en este ámbito coincide con {query}.", + "brainstorm.files.empty.searchBody": "Ningún objeto en este ámbito coincide con {query}.", "brainstorm.files.inspector.tabsRegion": "Pestañas del inspector", "brainstorm.files.inspector.tabPreview": "Vista previa", "brainstorm.files.inspector.tabProperties": "Propiedades", diff --git a/apps/files/src/styles-toolbar-row.test.ts b/apps/files/src/styles-toolbar-row.test.ts index 01a312b9..78ab70b1 100644 --- a/apps/files/src/styles-toolbar-row.test.ts +++ b/apps/files/src/styles-toolbar-row.test.ts @@ -116,3 +116,52 @@ describe("files toolbar is one control row", () => { ).not.toMatch(/bs-(select|input|btn)--sm/); }); }); + +describe("files toolbar end group is one face", () => { + const css = readFileSync(CSS_PATH, "utf8"); + const tsx = readFileSync(APP_PATH, "utf8"); + const filterTsx = readFileSync(join(SRC_DIR, "ui", "filter-bar.tsx"), "utf8"); + + it("the Filter toggle wears the same field face as Sort-by and the view picker", () => { + const className = /className="([^"]*\btoolbar__filter\b[^"]*)"/.exec(filterTsx)?.[1] ?? ""; + expect(className.split(" "), "Filter must wear the shared .bs-select face").toContain( + "bs-select", + ); + expect( + className, + "a transparent .bs-btn--secondary beside two white fields reads as a disabled control", + ).not.toMatch(/bs-btn/); + }); + + it("the Sort-by trigger shows the dropdown caret, never the sort direction", () => { + const trigger = /data-testid="toolbar-sort"[\s\S]*?<\/button>/.exec(tsx)?.[0]; + expect(trigger, "could not locate the sort trigger JSX").toBeDefined(); + expect(trigger).toContain("IconName.CaretDown"); + expect(trigger, "an up caret on a closed menu reads as an open one").not.toContain("CaretUp"); + }); + + it("the view-options menu is not held to the small panel's 480px cap and shows scroll shadows", () => { + const panel = onlyBody(css, ".bs-popover__panel:has(.sort-menu__items)"); + expect(panel).toMatch(/max-height:\s*80vh/); + const body = onlyBody(css, ".bs-popover__body:has(> .sort-menu__items)"); + expect(body, "the covers must scroll with the content").toMatch(/\blocal\b/); + expect(body, "the edge shadows must stay pinned to the scrollport").toMatch(/\bscroll\b/); + }); +}); + +describe("files bulk-action bar does not sit on the content", () => { + const css = readFileSync(CSS_PATH, "utf8"); + + it("the bar is an opaque surface", () => { + const body = onlyBody(css, ".files-bulkbar"); + expect(body).toMatch(/background:\s*var\(--color-background-elevated\)/); + expect(body, "glass lets the tiles underneath read through the labels").not.toMatch( + /glass-background|backdrop-filter/, + ); + }); + + it("the list reserves the bar's footprint while the bar is shown", () => { + const body = onlyBody(css, ".content-list:has(~ .files-bulkbar)"); + expect(body).toMatch(/padding-bottom:/); + }); +}); diff --git a/apps/files/src/styles.css b/apps/files/src/styles.css index 9d753059..b18ef247 100644 --- a/apps/files/src/styles.css +++ b/apps/files/src/styles.css @@ -499,9 +499,17 @@ body[data-nav-open="false"] .sidebar:not([data-bs-autohide]) { padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); border: var(--border-width) solid var(--color-glass-border, var(--border)); border-radius: var(--radius-full); - background: var(--color-glass-background-strong); + /* Opaque, like the shared popover panel: the bar floats over tiles with no + * scrim, and the glass fill let their titles read through its labels. */ + background: var(--color-background-elevated); box-shadow: var(--shadow-xl); - backdrop-filter: blur(12px); +} + +/* The bar overlays the list's last visible row; while it is up the scroller + * gains the bar's footprint (bottom offset + 46px pill + breathing room) so + * the final row can scroll clear of it. */ +.content-list:has(~ .files-bulkbar) { + padding-bottom: calc(var(--space-4) * 2 + 46px); } .files-bulkbar__count { @@ -615,9 +623,16 @@ body[data-nav-open="false"] .sidebar:not([data-bs-autohide]) { color: var(--accent); } +/* The Filter toggle wears the `.bs-select` field face, like Sort-by and the + * view picker beside it: as a transparent `.bs-btn--secondary` with dim ink it + * read as a disabled control next to two white fields. Pressed (filter row + * open) borrows the face's own open-state edge. */ .toolbar__filter { flex-shrink: 0; - gap: var(--space-1); +} + +.toolbar__filter[aria-pressed="true"] { + border-color: var(--color-accent-default); } /* Property-filter row + the Duplicates summary (9.8.16) — a second band @@ -1678,8 +1693,9 @@ body:not([data-inspector="open"]) .inspector { * picker are the SAME `.bs-select` face (one boxed trigger face per * toolbar; chrome from `@brainstorm-os/sdk/select-menu.css`). The sort button * keeps its own popover (direction + group-by + layout controls, not a plain - * option list) — only its face is the shared one; its caret shows the current - * sort direction instead of the dropdown caret. */ + * option list) — only its face is the shared one, dropdown caret included + * (a direction caret pointed UP on a closed menu beside the view picker's + * down caret; the direction is drawn on the menu's own direction row). */ .toolbar__sort-label { max-width: 220px; @@ -1691,6 +1707,28 @@ body:not([data-inspector="open"]) .inspector { gap: var(--space-0_5); } +/* The view-options menu is longer than the shared small panel's 480px cap + * (sort + direction + group + tile size + columns), so it always scrolls — + * and macOS overlay scrollbars hide the only cue, leaving a row sliced by the + * panel edge. Let the panel use the height the window has, and paint scroll + * shadows: the opaque covers ride the content (`local`) and slide off the + * edge shadows (`scroll`) whenever more rows lie beyond that edge. */ +.bs-popover__panel:has(.sort-menu__items) { + max-height: 80vh; +} + +.bs-popover__body:has(> .sort-menu__items) { + background: + linear-gradient(var(--color-background-elevated) 40%, transparent) top / 100% var(--space-6) + no-repeat local, + linear-gradient(transparent, var(--color-background-elevated) 60%) bottom / 100% var(--space-6) + no-repeat local, + linear-gradient(var(--color-border-strong), transparent) top / 100% var(--space-2) no-repeat + scroll, + linear-gradient(transparent, var(--color-border-strong)) bottom / 100% var(--space-2) no-repeat + scroll; +} + .sort-menu__item { display: flex; align-items: center; diff --git a/apps/files/src/ui/dialogs.tsx b/apps/files/src/ui/dialogs.tsx index 3cb317dc..e8a658da 100644 --- a/apps/files/src/ui/dialogs.tsx +++ b/apps/files/src/ui/dialogs.tsx @@ -170,8 +170,8 @@ export type SortMenuProps = { onClose: () => void; }; -/** The direction row's state glyph: the same caret the toolbar trigger shows, - * so "which way is it sorting" reads identically in both places. */ +/** The direction row's state glyph — the one place the sort direction is + * drawn. The toolbar trigger's caret is the dropdown affordance, not this. */ export function directionIcon(direction: SortDirection): IconName { return direction === SortDirection.Asc ? IconName.CaretUp : IconName.CaretDown; } diff --git a/apps/files/src/ui/filter-bar.tsx b/apps/files/src/ui/filter-bar.tsx index 35669ffa..18bec413 100644 --- a/apps/files/src/ui/filter-bar.tsx +++ b/apps/files/src/ui/filter-bar.tsx @@ -61,7 +61,7 @@ export function FilterToggleButton({ return (