8 Commits
Author SHA1 Message Date
bvandeusenandClaude Opus 5.5 f2b48069e3 The AppImage tree is readable by everyone before it is repackaged
CI & Build / Build now, or wait for Android? (push) Successful in 2s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 3s
CI & Build / Web typecheck and unit tests (push) Successful in 10s
CI & Build / Python lint (push) Successful in 1s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Android / Core and FFI clippy and tests (push) Skipped
Android / Kotlin + Rust (APK) (push) Skipped
Android / Build the server image (push) Skipped
CI & Build / Python tests (push) Successful in 13s
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 1m45s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 1m56s
Desktop (Tauri) / Update manifest (push) Successful in 4s
CI & Build / integration (push) Successful in 1m31s
CI & Build / Build & push image (push) Successful in 14s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 2m59s
appimagetool's continuous build from 2026-10-29 rejects a tree that not every
user can read and run, which failed the desktop Linux lane. Extraction keeps the
build's restrictive modes (0700 directories, a 0770 AppRun.wrapped), and an
AppImage runs as whichever user launches it, so the modes are corrected rather
than the check skipped.

Issue #6712.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 10:09:58 -04:00
bvandeusenandClaude Opus 5.5 0f787c6363 The board places each card in the shortest column, instead of leaving it to CSS columns
Android / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 2s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 8s
CI & Build / integration (push) Successful in 1m37s
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 1m58s
CI & Build / Python tests (push) Successful in 13s
Android / Core and FFI clippy and tests (push) Successful in 40s
CI & Build / Build & push image (push) Skipped
Android / Kotlin + Rust (APK) (push) Successful in 7m38s
Android / Build the server image (push) Successful in 1s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 2m47s
Desktop (Tauri) / Tauri desktop (Linux) (push) Failing after 3m43s
Desktop (Tauri) / Update manifest (push) Skipped
CSS multi-column decides placement by balancing column heights, so the same
notes could land differently at the same width: an edit left two cards alone in
the fourth column with the middle two empty, and a refresh left the fourth empty
beside a stack of three in the first.

Cards now go, in board order, into the shortest column, leftmost on a tie, so the
same notes at the same width always land the same way and every column fills
before any stacks. This changes the reading order to match Android: the second
note sits top-right rather than under the first.

useMasonry measures the cards and watches them for height changes. Placement is a
pure function, tested in notes/masonry.test.ts. Cards are absolutely placed, so
TransitionGroup's move animation carries on working unchanged.

Issue #6709.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 09:56:58 -04:00
bvandeusenandClaude Opus 5.5 7fca1f6c7f A forwarding header shorter than the hop count is read from its leftmost entry
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 3s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Android / Core and FFI clippy and tests (push) Skipped
Android / Kotlin + Rust (APK) (push) Skipped
Android / Build the server image (push) Skipped
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Skipped
Desktop (Tauri) / Tauri desktop (Linux) (push) Skipped
Desktop (Tauri) / Windows installer (cross-compiled) (push) Skipped
Desktop (Tauri) / Update manifest (push) Skipped
CI & Build / Web typecheck and unit tests (push) Successful in 9s
CI & Build / Python tests (push) Successful in 17s
CI & Build / integration (push) Successful in 1m30s
CI & Build / Build & push image (push) Successful in 45s
At Trusted proxy hops 2 (Cloudflare → Traefik → app), a LAN request reaching
Traefik directly carries one X-Forwarded-For entry. trusted_entry returned None
for it, so every LAN visitor was filed under Traefik's overlay address in the
throttles and the audit log. Cloudflare's single X-Forwarded-Proto: https read
as plain HTTP, so the public road lost the Secure cookie and HSTS.

A short header now clamps to its leftmost entry, the one the first proxy wrote,
as family canon #5004 does in Minstrel, Librarian and Forge. A caller's own
entries can only make the header longer, so this trusts nothing more than before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 08:37:14 -04:00
bvandeusenandClaude Opus 5.5 b74dc7c1fe One app fixture for the tests, and ViewModels built where they are used
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 2s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Skipped
Desktop (Tauri) / Tauri desktop (Linux) (push) Skipped
Desktop (Tauri) / Windows installer (cross-compiled) (push) Skipped
Desktop (Tauri) / Update manifest (push) Skipped
CI & Build / Web typecheck and unit tests (push) Successful in 8s
CI & Build / Python tests (push) Successful in 13s
Android / Core and FFI clippy and tests (push) Successful in 25s
CI & Build / integration (push) Successful in 1m31s
CI & Build / Build & push image (push) Skipped
Android / Kotlin + Rust (APK) (push) Successful in 6m41s
Android / Build the server image (push) Successful in 1s
The tests' `app` fixture, the same two lines in eleven files, now lives once in
tests/conftest.py.

On Android each ViewModel carried a companion `factory` that only wrapped its
constructor in viewModelFactory { initializer { … } }. MainActivity now builds
each one with Compose's viewModel { … } builder, so the five factories and their
imports are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 21:25:05 -04:00
bvandeusenandClaude Opus 5.5 463b22bbe4 A push that loses a create race applies its change instead of failing
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 3s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Android / Core and FFI clippy and tests (push) Skipped
Android / Kotlin + Rust (APK) (push) Skipped
Android / Build the server image (push) Skipped
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 3s
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Skipped
Desktop (Tauri) / Tauri desktop (Linux) (push) Skipped
Desktop (Tauri) / Windows installer (cross-compiled) (push) Skipped
Desktop (Tauri) / Update manifest (push) Skipped
CI & Build / Web typecheck and unit tests (push) Successful in 9s
CI & Build / Python tests (push) Successful in 12s
CI & Build / integration (push) Successful in 1m31s
CI & Build / Build & push image (push) Successful in 34s
Two devices pushing the same new note or tag at the same moment both found
no row and both inserted it; the slower insert hit the primary key and the
whole push answered 500. Each pushed note or label change now runs in a
savepoint. If its insert loses the race, only that change is rolled back,
and it is applied again against the row the other push committed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 20:34:04 -04:00
bvandeusenandClaude Opus 5.5 c6f10f157d Timeline shows archived notes too, each one labelled Archived
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 3s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Android / Core and FFI clippy and tests (push) Skipped
Android / Kotlin + Rust (APK) (push) Skipped
Android / Build the server image (push) Skipped
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 3s
CI & Build / Web typecheck and unit tests (push) Successful in 9s
CI & Build / Python tests (push) Successful in 13s
CI & Build / integration (push) Successful in 1m34s
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 1m48s
CI & Build / Build & push image (push) Successful in 30s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 2m2s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 3m10s
Desktop (Tauri) / Update manifest (push) Successful in 3s
Timeline lists everything not in Trash. The card's Archived label is now
hidden only on the Archive page, read off the route: Timeline keeps its
own list and never sets the board's view, so arriving from the Archive
used to leave the store saying "archived".

Task #6318.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 17:29:40 -04:00
bvandeusenandClaude Opus 5.5 66fd5707b7 tagQueryAt decides in one check, within detekt's return limit
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 2s
Android / Build, or is the channel already serving this? (push) Successful in 3s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Skipped
Desktop (Tauri) / Tauri desktop (Linux) (push) Skipped
Desktop (Tauri) / Windows installer (cross-compiled) (push) Skipped
Desktop (Tauri) / Update manifest (push) Skipped
CI & Build / Web typecheck and unit tests (push) Successful in 9s
CI & Build / Python tests (push) Successful in 12s
Android / Core and FFI clippy and tests (push) Successful in 25s
CI & Build / integration (push) Successful in 1m29s
CI & Build / Build & push image (push) Skipped
Android / Kotlin + Rust (APK) (push) Successful in 6m56s
Android / Build the server image (push) Successful in 1s
Task #6316.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 16:38:36 -04:00
bvandeusenandClaude Opus 5.5 7e96683f01 The archive-search tests sign in and keep the listed notes alive
CI & Build / Python lint (push) Successful in 2s
CI & Build / Build now, or wait for Android? (push) Successful in 2s
Android / Build, or is the channel already serving this? (push) Successful in 2s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 8s
CI & Build / Python tests (push) Successful in 14s
Android / Core and FFI clippy and tests (push) Successful in 31s
CI & Build / integration (push) Successful in 1m38s
CI & Build / Build & push image (push) Skipped
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 1m52s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 3m5s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 3m44s
Android / Kotlin + Rust (APK) (push) Failing after 5m10s
Android / Build the server image (push) Skipped
Desktop (Tauri) / Update manifest (push) Successful in 4s
The integration test registers the owner before writing notes, and the
core test binds the "all" listing before borrowing ids from it.

Task #6315.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 16:28:01 -04:00
35 changed files with 318 additions and 178 deletions
@@ -219,15 +219,16 @@ private fun App(
) {
val context = LocalContext.current
val board: BoardViewModel =
viewModel(
factory =
BoardViewModel.factory(core, readFile = files::read) {
// Any store write can have moved the next reminder. Called on
// the IO dispatcher by the view model, which is where it has to
// be — this reads every note carrying a reminder.
Reminders.refresh(context, core)
},
)
viewModel {
BoardViewModel(
core,
// Any store write can have moved the next reminder. Called on the IO
// dispatcher by the view model, which is where it has to be — this
// reads every note carrying a reminder.
onRemindersChanged = { Reminders.refresh(context, core) },
readFile = files::read,
)
}
// Consumed, not just read: without clearing it, every later recomposition
// would reopen the same note and make the editor impossible to leave.
@@ -251,7 +252,7 @@ private fun App(
// A pull can rewrite every note the board is holding, so a sync that changed
// anything tells it to reload. Wired here, at the one place that owns both.
val sync: SyncViewModel =
viewModel(factory = SyncViewModel.factory(core, onStoreChanged = board::refresh))
viewModel { SyncViewModel(core, onStoreChanged = board::refresh) }
// Screen visibility is view STATE, not view-model state: it is about what is on
// the display, and nothing in the store cares. Saveable so a rotation does not
@@ -266,14 +267,14 @@ private fun App(
// board may be LOOKING at one that a delete or a merge just removed. Both are
// `refreshLabels`, which also leaves a lens whose tag stopped existing.
val tags: TagsViewModel =
viewModel(factory = TagsViewModel.factory(core, onStoreChanged = board::refreshLabels))
viewModel { TagsViewModel(core, onStoreChanged = board::refreshLabels) }
// A share landing changes the note's `shared` flag, which the board's card chip
// reads, so the board reloads after one.
val share: ShareViewModel =
viewModel(factory = ShareViewModel.factory(core, onStoreChanged = board::refresh))
viewModel { ShareViewModel(core, onStoreChanged = board::refresh) }
val update: UpdateViewModel = viewModel(factory = UpdateViewModel.factory(core, context))
val update: UpdateViewModel = viewModel { UpdateViewModel(core, context.applicationContext) }
val settings = remember(context) { SyncSettings(context) }
var automatic by remember { mutableStateOf(settings.automatic) }
@@ -530,7 +530,7 @@ private fun DrawerRow(
* Staggered rather than a uniform grid because notes are wildly different heights
* — a one-line thought beside a twelve-item checklist — and forcing them to a
* common height either clips the long ones or strands whitespace under the short
* ones. This is the Compose equivalent of the CSS multi-column `NoteGrid.vue` uses.
* ones. `NoteGrid.vue` places cards the same way, each into the shortest column.
*/
@Composable
private fun NoteBoard(
@@ -5,10 +5,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import com.fabledsword.inkwell.core.Inkwell
import com.fabledsword.inkwell.core.Label
import com.fabledsword.inkwell.core.Note
@@ -660,13 +657,6 @@ class BoardViewModel(
/** The board and the Archive together — everything not in Trash. */
private const val VIEW_ALL = "all"
fun factory(
core: Inkwell,
readFile: (Uri) -> PickedFile,
onRemindersChanged: () -> Unit,
): ViewModelProvider.Factory =
viewModelFactory { initializer { BoardViewModel(core, onRemindersChanged, readFile) } }
}
}
@@ -4,10 +4,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import com.fabledsword.inkwell.core.CoreException
import com.fabledsword.inkwell.core.Inkwell
import com.fabledsword.inkwell.core.Member
@@ -132,11 +129,4 @@ class ShareViewModel(
}
}
}
companion object {
fun factory(
core: Inkwell,
onStoreChanged: () -> Unit,
): ViewModelProvider.Factory = viewModelFactory { initializer { ShareViewModel(core, onStoreChanged) } }
}
}
@@ -4,10 +4,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import com.fabledsword.inkwell.core.Compatibility
import com.fabledsword.inkwell.core.Inkwell
import com.fabledsword.inkwell.core.ProbeResult
@@ -315,13 +312,6 @@ class SyncViewModel(
fun dismissSyncError() {
state = state.copy(syncError = null)
}
companion object {
fun factory(
core: Inkwell,
onStoreChanged: () -> Unit,
): ViewModelProvider.Factory = viewModelFactory { initializer { SyncViewModel(core, onStoreChanged) } }
}
}
/**
@@ -37,14 +37,16 @@ fun tagQueryAt(
text: String,
caret: Int,
): TagQuery? {
if (caret < 0 || caret > text.length) return null
var i = caret
while (i > 0 && text[i - 1].isTagChar()) i--
if (i == 0 || text[i - 1] != '#') return null
val hash = i - 1
if (hash > 0 && !text[hash - 1].isWhitespace()) return null
val query = text.substring(i, caret)
if (query.isNotEmpty() && !Character.isAlphabetic(query[0].code)) return null
val inTag =
hash >= 0 &&
text[hash] == '#' &&
(hash == 0 || text[hash - 1].isWhitespace()) &&
(query.isEmpty() || Character.isAlphabetic(query[0].code))
if (!inTag) return null
var end = caret
while (end < text.length && text[end].isTagChar()) end++
return TagQuery(start = hash, end = end, query = query)
@@ -4,10 +4,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import com.fabledsword.inkwell.core.Inkwell
import com.fabledsword.inkwell.core.Label
import kotlinx.coroutines.Dispatchers
@@ -163,11 +160,4 @@ class TagsViewModel(
onStoreChanged()
}
}
companion object {
fun factory(
core: Inkwell,
onStoreChanged: () -> Unit,
): ViewModelProvider.Factory = viewModelFactory { initializer { TagsViewModel(core, onStoreChanged) } }
}
}
@@ -5,10 +5,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import com.fabledsword.inkwell.AppUpdate
import com.fabledsword.inkwell.UpdateOutcome
import com.fabledsword.inkwell.core.ClientUpdate
@@ -214,14 +211,6 @@ class UpdateViewModel(
fun dismissError() {
state = state.copy(error = null)
}
companion object {
fun factory(
core: Inkwell,
context: Context,
): ViewModelProvider.Factory =
viewModelFactory { initializer { UpdateViewModel(core, context.applicationContext) } }
}
}
private const val FALLBACK = "The update couldn't be checked."
+2 -1
View File
@@ -1498,7 +1498,8 @@ mod tests {
ids(&list(&conn, json!({"view": "trash"}))),
vec![trashed.id.as_str()]
);
let mut all = ids(&list(&conn, json!({"view": "all"})));
let everything = list(&conn, json!({"view": "all"}));
let mut all = ids(&everything);
all.sort();
let mut expected = vec![kept.id.as_str(), archived.id.as_str()];
expected.sort();
@@ -109,6 +109,11 @@ chmod +x "$APPIMAGETOOL"
echo "==> Repackaging AppImage (overwriting original)"
rm -f "$APPIMAGE"
# appimagetool refuses a tree it can't be sure everyone can read and run: the
# AppImage runs as whichever user launches it, and extraction keeps the build's
# restrictive modes.
chmod -R a+rX "$WORK/squashfs-root"
chmod a+rx "$WORK/squashfs-root/AppRun"
# APPIMAGE_EXTRACT_AND_RUN lets appimagetool (itself an AppImage) run without
# FUSE in the CI container; ARCH is required by the embedded runtime.
export APPIMAGE_EXTRACT_AND_RUN=1
+4 -1
View File
@@ -60,7 +60,10 @@ traverses, so the rightmost entries are the ones your own infrastructure wrote a
anything a caller forged sits to the left of them. Counting in from the right by the
number of proxies you actually run means a forged prefix can never be selected. Set it
too HIGH and it starts trusting entries no proxy of yours wrote; too low and several
callers share one rate-limit bucket, which is merely inconvenient.
callers share one rate-limit bucket, which is merely inconvenient. A request that
passed fewer proxies than the count — a LAN visitor reaching your proxy directly while
it is set to `2` for the CDN — is read from the header's leftmost entry, which your
first proxy wrote.
**4. Stop reaching the app except through the proxy.** The default compose binds
`0.0.0.0:5000` so LAN clients can reach it directly — which is right for a LAN install
+7 -4
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { useNotesStore } from "../stores/notes";
import { NOTE_CARD_SURFACE, labelChipClasses } from "../notes/colors";
import { rendersInline } from "../notes/attachments";
@@ -52,9 +53,11 @@ const sharedLine = computed(() => {
return props.note.shared ? "Shared" : "";
});
// A search or a tag reaches into the Archive, so an archived card met anywhere but
// the Archive itself says so: put away, not current.
const showArchived = computed(() => props.note.archived && !props.note.trashed && notes.view !== "archived");
// A search, a tag or the Timeline reaches into the Archive, so an archived card met
// anywhere but the Archive itself says so: put away, not current. Read off the route,
// since a page with its own list (Timeline) never sets the notes store's view.
const route = useRoute();
const showArchived = computed(() => props.note.archived && !props.note.trashed && route.name !== "archive");
// --- Retention countdown, so someone browsing Trash can restore a note in time.
// Null when not trashed or retention is off. ---
@@ -203,7 +206,7 @@ const tagColors = computed<Record<string, string>>(() => {
<template>
<div
ref="root"
class="group relative mb-2 break-inside-avoid sm:mb-4 rounded-xl border border-[#b8b8b8] p-3 shadow-sm transition hover:shadow-md dark:border-[#404040]"
class="group relative rounded-xl border border-[#b8b8b8] p-3 shadow-sm transition hover:shadow-md dark:border-[#404040]"
:class="[
NOTE_CARD_SURFACE,
dragging ? 'opacity-40' : '',
+9 -3
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import NoteCard from "./NoteCard.vue";
import { useMasonry } from "../composables/useMasonry";
import type { Note } from "../stores/notes";
/**
@@ -9,7 +10,7 @@ import type { Note } from "../stores/notes";
* `activeId` rather than an index, because the board splits its notes across two
* grids.
*/
defineProps<{
const props = defineProps<{
notes: Note[];
/** The keyboard-focused note, if any. */
activeId?: string | null;
@@ -24,22 +25,27 @@ defineEmits<{
(e: "drop", targetId: string): void;
(e: "reminder-changed"): void;
}>();
const { grid, gridStyle, cardStyle } = useMasonry(() => props.notes.map((n) => n.id));
</script>
<template>
<!-- `board` is the transition name defined in style.css; `appear` covers first
paint so a lens arrives eased rather than snapping in.
Two columns even on a phone, as on Android, with a tighter gap there.
NoteCard's bottom margin is the vertical half of this gap. -->
useMasonry reads the column count and the gap back from these classes. -->
<TransitionGroup
ref="grid"
tag="div"
name="board"
appear
class="columns-2 gap-2 sm:gap-4 lg:columns-3 xl:columns-4"
class="relative [--board-columns:2] [--board-gap:0.5rem] [column-gap:var(--board-gap)] sm:[--board-gap:1rem] lg:[--board-columns:3] xl:[--board-columns:4]"
:style="gridStyle"
>
<NoteCard
v-for="n in notes"
:key="n.id"
:style="cardStyle(n.id)"
:note="n"
:active="activeId === n.id"
:reorderable="reorderable"
+2 -2
View File
@@ -25,8 +25,8 @@ export function endCardDrag(): void {
/**
* The id of the card under this point, ignoring `self`.
*
* Reads the DOM rather than tracking geometry: in a CSS masonry (`columns-*`) the
* visual order isn't derivable from the model order.
* Reads the DOM rather than tracking geometry: in a masonry the visual order isn't
* derivable from the model order.
*/
export function cardIdAt(x: number, y: number, self: string): string | null {
const el = document.elementFromPoint(x, y)?.closest<HTMLElement>("[data-note-id]");
+91
View File
@@ -0,0 +1,91 @@
import { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from "vue";
import type { ComponentPublicInstance } from "vue";
import { placeCards } from "../notes/masonry";
import type { CardSlot } from "../notes/masonry";
/** A slot as inline style. The column count and gap stay in CSS, on the grid's own
* classes, so a card has the right width before anything has been measured. */
function slotStyle(slot: CardSlot | undefined): Record<string, string> {
return {
position: "absolute",
top: `${slot?.top ?? 0}px`,
left: `calc(${slot?.column ?? 0} * (100% + var(--board-gap)) / var(--board-columns))`,
width: "calc((100% - (var(--board-columns) - 1) * var(--board-gap)) / var(--board-columns))",
};
}
/**
* Lays out a NoteGrid: measures its cards and places each one with `placeCards`.
*
* `grid` is the template ref for the TransitionGroup. Its cards are found by
* `data-note-id`, which NoteCard sets on its root.
*/
export function useMasonry(ids: () => string[]) {
const grid = ref<ComponentPublicInstance | null>(null);
const heights = shallowRef<ReadonlyMap<string, number>>(new Map());
const columns = ref(1);
const gap = ref(0);
const layout = computed(() => placeCards(ids(), heights.value, columns.value, gap.value));
const gridStyle = computed(() => ({ height: `${layout.value.height}px` }));
const cardStyle = (id: string) => slotStyle(layout.value.slots.get(id));
const gridEl = () => (grid.value?.$el ?? null) as HTMLElement | null;
const cardEls = () => [...(gridEl()?.querySelectorAll<HTMLElement>(":scope > [data-note-id]") ?? [])];
function readTracks(): void {
const el = gridEl();
if (!el) return;
const style = getComputedStyle(el);
columns.value = parseInt(style.getPropertyValue("--board-columns"), 10) || 1;
gap.value = parseFloat(style.columnGap) || 0;
}
function measure(): void {
const cards = cardEls();
const wanted = new Set(ids());
const next = new Map<string, number>();
for (const card of cards) {
const id = card.dataset.noteId as string;
// A card on its way out is still in the DOM, and no longer takes up room.
if (wanted.has(id)) next.set(id, card.offsetHeight);
}
const same = next.size === heights.value.size && [...next].every(([id, h]) => heights.value.get(id) === h);
if (same) return;
// A card seen for the first time goes straight to its place. Left to the next
// render, TransitionGroup would see it move there from the top of the board and
// fly it across.
const { slots } = placeCards(ids(), next, columns.value, gap.value);
for (const card of cards) {
const id = card.dataset.noteId as string;
if (wanted.has(id) && !heights.value.has(id)) Object.assign(card.style, slotStyle(slots.get(id)));
}
heights.value = next;
}
// Height follows content that has no event of its own: an edit, an image loading,
// a width change rewrapping the text.
const cardObserver = new ResizeObserver(measure);
const gridObserver = new ResizeObserver(readTracks);
function observeCards(): void {
cardObserver.disconnect();
for (const card of cardEls()) cardObserver.observe(card);
measure();
}
onMounted(() => {
const el = gridEl();
if (el) gridObserver.observe(el);
readTracks();
observeCards();
});
watch(() => ids().join("\n"), observeCards, { flush: "post" });
onBeforeUnmount(() => {
cardObserver.disconnect();
gridObserver.disconnect();
});
return { grid, gridStyle, cardStyle };
}
+38
View File
@@ -0,0 +1,38 @@
import { describe, expect, it } from "vitest";
import { placeCards } from "./masonry";
const heights = (entries: Record<string, number>) => new Map(Object.entries(entries));
describe("placing cards on the board", () => {
it("uses every column before stacking", () => {
const { slots } = placeCards(["a", "b", "c", "d"], heights({ a: 100, b: 100, c: 100, d: 100 }), 4, 16);
expect([...slots.values()].map((s) => s.column)).toEqual([0, 1, 2, 3]);
});
it("puts the next card under the shortest column, with the gap above it", () => {
const { slots } = placeCards(["a", "b", "c"], heights({ a: 300, b: 50, c: 80 }), 2, 16);
expect(slots.get("c")).toEqual({ column: 1, top: 66 });
});
it("takes the leftmost column on a tie", () => {
const { slots } = placeCards(["a", "b", "c"], heights({ a: 100, b: 100, c: 10 }), 2, 16);
expect(slots.get("c")).toEqual({ column: 0, top: 116 });
});
it("reports the tallest column as the board's height", () => {
const { height } = placeCards(["a", "b", "c"], heights({ a: 300, b: 50, c: 80 }), 2, 16);
expect(height).toBe(316);
});
it("counts an unmeasured card as zero tall", () => {
const { slots } = placeCards(["a", "b"], heights({ b: 100 }), 1, 16);
expect(slots.get("b")).toEqual({ column: 0, top: 16 });
});
it("is an empty board with no cards", () => {
const { slots, height } = placeCards([], new Map(), 4, 16);
expect(slots.size).toBe(0);
expect(height).toBe(0);
});
});
+33
View File
@@ -0,0 +1,33 @@
/** Where one card sits on the board. */
export interface CardSlot {
column: number;
top: number;
}
export interface BoardLayout {
slots: Map<string, CardSlot>;
/** The tallest column, so the board can reserve its own height. */
height: number;
}
/**
* Places cards in board order, each into the column that is currently shortest and
* the leftmost of any tie. The same notes at the same width always land the same way.
*
* A card with no measured height yet counts as zero.
*/
export function placeCards(
ids: string[],
heights: ReadonlyMap<string, number>,
columns: number,
gap: number,
): BoardLayout {
const bottoms = new Array<number>(Math.max(columns, 1)).fill(0);
const slots = new Map<string, CardSlot>();
for (const id of ids) {
const column = bottoms.indexOf(Math.min(...bottoms));
slots.set(id, { column, top: bottoms[column] });
bottoms[column] += (heights.get(id) ?? 0) + gap;
}
return { slots, height: Math.max(...bottoms) };
}
+2 -4
View File
@@ -131,10 +131,8 @@ body {
* Vue's TransitionGroup does the FLIP itself; this supplies only the curve, fast and
* small, so a card reads as having MOVED rather than performed.
*
* Leavers are NOT taken out of flow with `position: absolute`, the usual trick: this
* masonry is CSS multi-column, and an absolutely positioned child escapes its column
* to the container's origin. Staying in flow costs a small settle on removal, so the
* leave is the shortest of the three.
* Cards are absolutely placed (useMasonry), so a leaver fades where it stands while
* the others move up. The leave is the shortest of the three.
*
* Reduced motion needs no case here: the global guard above collapses every duration. */
.board-move {
+3 -2
View File
@@ -13,7 +13,8 @@ import NoteEditor from "../components/NoteEditor.vue";
// The "find by WHEN" recall lens: your notes grouped by when you captured them,
// newest first, with an optional date range. A distinct recall axis from search /
// labels — memory is often temporal even when the content is fuzzy.
// labels — memory is often temporal even when the content is fuzzy. Archived notes
// are included (each card says so), since finished work is what gets looked back on.
// Optional local date-range filter (YYYY-MM-DD from <input type="date">).
const fromDate = ref("");
@@ -24,7 +25,7 @@ function buildQuery(): NoteListQuery {
const from = parseLocalDate(fromDate.value);
const to = parseLocalDate(toDate.value);
return {
view: "active",
view: "all",
sort: "created",
facets: {
created_after: from ? from.toISOString() : undefined,
+8 -4
View File
@@ -9,7 +9,10 @@ right by the **Trusted proxy hops** setting (default 1), and a forged prefix is
selected.
Too high a count is the dangerous direction: it believes entries no proxy of ours
wrote. When the header is shorter than configured, the socket address is used.
wrote. A header shorter than the count is read from its leftmost entry: the request
passed fewer proxies (a LAN visitor straight to the reverse proxy, behind a count set
for the CDN road), and a caller's own entries could only have made it longer. That
holds while the first proxy drops a forwarding header from a client it doesn't trust.
"""
from __future__ import annotations
@@ -19,16 +22,17 @@ from .settings import live
def trusted_entry(header: str, hops: int) -> str | None:
"""The nth-from-the-right entry of a forwarding header, or None if there isn't one.
"""The nth-from-the-right entry of a forwarding header, its leftmost if it is
shorter than that, or None when no proxy is trusted or there is no header.
Pure, so the trust boundary is testable without a request context.
"""
if hops <= 0:
return None
entries = [part.strip() for part in header.split(",") if part.strip()]
if len(entries) < hops:
if not entries:
return None
return entries[-hops]
return entries[-min(hops, len(entries))]
def forwarded_for(header: str, remote_addr: str | None, hops: int) -> str:
+24 -2
View File
@@ -19,6 +19,7 @@ from datetime import datetime, timezone
from quart import Blueprint, g, jsonify, request
from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from .auth import login_required
from .colors import normalize_color
@@ -446,6 +447,27 @@ async def _apply_child_delete(db, ch: dict, removed_files: list[str]) -> dict:
return _result(str(child_id), entity, "applied")
async def _apply_raced(db, apply, previews: list[tuple[uuid.UUID, str]]) -> dict:
"""Apply one note or label change in a savepoint, and once more if its insert lost
a race.
Two devices can push the same new note or tag at the same moment, or one device
can retry a push whose reply it never got. Both requests look the id up, find
nothing, and insert, and the slower insert hits the primary key (or a live tag's
name). Rolling back to the savepoint drops only that one change, along with any
link previews it queued. Applying it again finds the row the other push committed,
so the change goes through the usual last-write-wins path instead of failing the
whole batch with a 500.
"""
queued = len(previews)
try:
async with db.begin_nested():
return await apply()
except IntegrityError:
del previews[queued:]
return await apply()
@bp.post("/push")
@login_required
async def push():
@@ -468,9 +490,9 @@ async def push():
continue
entity = ch.get("entity")
if entity == "note":
results.append(await _apply_note(db, ch, previews))
results.append(await _apply_raced(db, lambda: _apply_note(db, ch, previews), previews))
elif entity == "label":
results.append(await _apply_label(db, ch))
results.append(await _apply_raced(db, lambda: _apply_label(db, ch), previews))
elif entity in _CHILD_ENTITIES:
results.append(await _apply_child_delete(db, ch, removed_files))
else:
+7
View File
@@ -1,5 +1,6 @@
import pytest
from inkwell.app import create_app
from inkwell.config import Config
@@ -10,3 +11,9 @@ def _isolated_data_dir(tmp_path, monkeypatch):
signing key from env-or-random, not a file), but this stays defensive."""
monkeypatch.setattr(Config, "DATA_DIR", str(tmp_path / "data"))
yield
@pytest.fixture
def app():
"""A fresh app for a test that drives routes through `app.test_client()`."""
return create_app()
-10
View File
@@ -1,13 +1,3 @@
import pytest
from inkwell.app import create_app
@pytest.fixture
def app():
return create_app()
async def test_settings_requires_auth(app):
# require_admin returns 401 before any DB access when unauthenticated.
client = app.test_client()
-7
View File
@@ -1,13 +1,6 @@
import pytest
from inkwell.app import create_app
@pytest.fixture
def app():
return create_app()
async def test_health_ok(app):
client = app.test_client()
resp = await client.get("/api/health")
-6
View File
@@ -4,7 +4,6 @@ from pathlib import Path
import pytest
from inkwell import client_dist
from inkwell.app import create_app
from inkwell.client_dist import (
BY_ID,
PLATFORMS,
@@ -54,11 +53,6 @@ def _empty_baked_client(tmp_path, monkeypatch):
yield
@pytest.fixture
def app():
return create_app()
def place(
platform_id: str = "android",
payload: bytes = PAYLOAD,
-10
View File
@@ -1,13 +1,3 @@
import pytest
from inkwell.app import create_app
@pytest.fixture
def app():
return create_app()
async def test_create_device_requires_auth(app):
# No session cookie and no bearer header → 401 before any DB access.
client = app.test_client()
-6
View File
@@ -1,7 +1,6 @@
import pytest
from inkwell import installer, settings
from inkwell.app import create_app
from inkwell.installer import PLACEHOLDER, SOURCE_SCRIPT, render, server_address
# DB-free, like test_client_dist: the route reads `public_url` from the live cache
@@ -17,11 +16,6 @@ def _defaults():
settings.reset_live()
@pytest.fixture
def app():
return create_app()
def test_the_published_script_carries_the_line_the_server_rewrites_exactly_once():
"""The forge-served script and the server-served one are the same file; this is
the one line that differs. Edit it and the server stops serving rather than
+50 -1
View File
@@ -29,7 +29,7 @@ from inkwell.models.invite import Invite
from inkwell.models.password_reset import PasswordReset
from inkwell.models.settings import Setting
from inkwell.models.share import Share
from inkwell.models.label import NoteLabel
from inkwell.models.label import Label, NoteLabel
from inkwell.models.note import Note
from inkwell.models.note_attachment import NoteAttachment
from inkwell.models.user import User
@@ -805,6 +805,54 @@ async def test_a_pushed_edit_keeps_the_clients_edit_time_when_a_tag_is_lifted(ap
assert datetime.fromisoformat(note["updated_at"]) == datetime(2026, 1, 1, tzinfo=timezone.utc)
@pytest.mark.parametrize("entity", ["label", "note"])
async def test_a_push_that_loses_a_create_race_applies_the_change_instead_of_failing(app_client, db, entity):
"""Two devices push the same new tag or note at once. The other push's row is
held here, inserted but not committed, so this push finds no row, inserts, and
waits on it. Once it commits, this push's insert fails on the primary key. That
change has to be applied to the stored row, not fail the batch with a 500."""
await _signed_in(app_client, f"race-{entity}")
owner_id = await db.scalar(select(User.id).where(User.email == f"race-{entity}@example.test"))
rid = uuid.uuid4()
first = datetime(2026, 1, 1, tzinfo=timezone.utc)
if entity == "label":
theirs = Label(id=rid, owner_id=owner_id, name="groceries", updated_at=first)
change = {"name": "groceries", "color": "teal"}
else:
theirs = Note(id=rid, owner_id=owner_id, body="pushed first", display_title="pushed first", updated_at=first)
change = {"body": "pushed second", "created_at": "2026-01-01T00:00:00Z"}
change |= {"entity": entity, "id": str(rid), "op": "upsert", "edited_at": "2026-01-02T00:00:00Z"}
async with session_scope() as other:
other.add(theirs)
await other.flush()
push = asyncio.create_task(app_client.post("/api/sync/push", json={"changes": [change]}))
# Commit only once the push's insert is blocked on that row. Committing
# earlier would let it find the row and never race at all. A fresh session per
# look: pg_stat_activity is read once per transaction and then held.
for _ in range(100):
async with session_scope() as probe:
waiting = await probe.scalar(text(
"SELECT count(*) FROM pg_stat_activity"
" WHERE datname = current_database() AND wait_event_type = 'Lock'"
))
if waiting or push.done():
break
await asyncio.sleep(0.1)
assert waiting and not push.done(), "the push should be waiting on the other push's uncommitted row"
await other.commit()
resp = await asyncio.wait_for(push, timeout=10)
assert resp.status_code == 200
assert (await resp.get_json())["results"][0]["status"] == "applied"
model = Label if entity == "label" else Note
stored = await db.scalar(select(model).where(model.id == rid).execution_options(populate_existing=True))
if entity == "label":
assert stored.color == "teal", "the later edit won"
else:
assert stored.body == "pushed second", "the later edit won"
# --- attachments as a sync entity -----------------------------------------------
@@ -1674,6 +1722,7 @@ async def test_owner_and_recipient_each_pin_archive_and_order_their_own(app_clie
async def test_search_and_tags_look_through_the_archive_but_not_the_trash(app_client, db):
await _admin_with_invite(app_client)
kept = await _owners_note(app_client, "ferry times #travel")
archived = await _owners_note(app_client, "ferry booked last summer #travel")
trashed = await _owners_note(app_client, "ferry refund #travel")
-8
View File
@@ -1,17 +1,9 @@
import uuid
import pytest
from inkwell.app import create_app
from inkwell.models.label import Label
from inkwell.serialize import serialize_label
@pytest.fixture
def app():
return create_app()
def test_serialize_label_shape():
# The base {id, name, color} shape the labels API and (S4) sync deltas both build on.
lid = uuid.uuid4()
-6
View File
@@ -5,7 +5,6 @@ from datetime import datetime, timezone
import pytest
from inkwell.app import create_app
from inkwell.common import coerce_bool, parse_dt
from inkwell.colors import NOTE_COLORS
from inkwell.models.note import Note
@@ -34,11 +33,6 @@ from inkwell.notes.recurrence import next_occurrence, normalize_recurrence
from inkwell.notes.tags import parse_tags, split_body_tags
@pytest.fixture
def app():
return create_app()
def test_all_note_routes_registered(app):
# Guards the notes package split: every route handler must still be attached to the
# blueprint. A route whose module isn't imported by notes/__init__ would silently
+12 -4
View File
@@ -41,13 +41,21 @@ def test_two_hops_sees_past_a_cdn():
assert forwarded_for("1.2.3.4, 203.0.113.7, 172.16.0.5", PEER, 2) == "203.0.113.7"
def test_a_short_header_falls_back_rather_than_reaching_left():
# Fewer proxies than configured: the socket address, rather than an entry no
# proxy of ours wrote.
assert forwarded_for("203.0.113.7", PEER, 2) == PEER
def test_a_short_header_is_read_from_its_leftmost_entry():
# Fewer proxies than configured — a LAN visitor straight to our proxy, behind a
# count set for the CDN road. The leftmost entry is what the first proxy wrote; a
# caller's own entries could only have made the header longer. Falling back to the
# socket address here would file every LAN visitor under the proxy's address.
assert forwarded_for("192.168.0.20", PEER, 2) == "192.168.0.20"
assert forwarded_for("", PEER, 1) == PEER
def test_a_single_https_from_the_cdn_counts_at_two_hops():
# Cloudflare sends one `X-Forwarded-Proto: https` and our proxy passes it on
# without appending, so at hops 2 it is a one-entry header — and still HTTPS.
assert trusted_entry("https", 2) == "https"
def test_malformed_headers_do_not_crash_or_leak_empties():
assert forwarded_for(",,,", PEER, 1) == PEER
assert forwarded_for(" , 203.0.113.7 , ", PEER, 1) == "203.0.113.7"
-6
View File
@@ -10,7 +10,6 @@ import pytest
from inkwell import ratelimit
from inkwell.settings import live
from inkwell.app import create_app
from inkwell.ratelimit import SlidingWindow
@@ -28,11 +27,6 @@ def _clean_counters():
ratelimit.reset_all()
@pytest.fixture
def app():
return create_app()
def test_under_the_limit_is_not_blocked():
w = window(3, 60)
for i in range(3):
-8
View File
@@ -4,14 +4,6 @@ Asserted on /api/health because it is the one route that needs no database and n
session — the headers are set in an after_request hook, so any response proves the
hook, and this suite has no Postgres.
"""
import pytest
from inkwell.app import create_app
@pytest.fixture
def app():
return create_app()
async def test_content_security_policy_locks_scripts_to_self(app):
-8
View File
@@ -1,8 +1,5 @@
from datetime import datetime, timezone
import pytest
from inkwell.app import create_app
from inkwell.sync import (
DEFAULT_LIMIT,
MAX_LIMIT,
@@ -17,11 +14,6 @@ from inkwell.sync import (
)
@pytest.fixture
def app():
return create_app()
async def test_changes_requires_auth(app):
client = app.test_client()
resp = await client.get("/api/sync/changes")
-6
View File
@@ -2,15 +2,9 @@ import ipaddress
import pytest
from inkwell.app import create_app
from inkwell.unfurl import UnfurlError, extract_preview, is_public_ip, validate_url
@pytest.fixture
def app():
return create_app()
def test_is_public_ip_blocks_internal_ranges():
assert is_public_ip(ipaddress.ip_address("8.8.8.8"))
assert is_public_ip(ipaddress.ip_address("2606:4700:4700::1111"))