Commit graph

521 commits

Author SHA1 Message Date
Jon Seager
577c0e39d3
feat(ui): add horizontal scrolling recent brews on homepage
- Load last 10 brews instead of 3, display in horizontal scroll
- Extract brew card into reusable partial with portrait layout
- Add grinder_model field to BrewView for compact card display
- Move brew-again button to top-right icon, truncate long names
2026-02-07 10:40:20 +00:00
Jon Seager
55e549ceac
feat(tasting-notes): add Levenshtein fuzzy matching for typo tolerance
Add third-tier fuzzy matching using edit distance to catch common typos
and spelling variants in tasting notes (e.g. "cinamon", "smokey").
2026-02-07 10:33:05 +00:00
Jon Seager
a3cfc22f09
fix(ui): show native camera/gallery picker on mobile photo capture
Remove capture="environment" from the file input so mobile browsers
present the OS-native action sheet instead of opening the camera directly.
2026-02-07 10:27:32 +00:00
Jon Seager
8410b46a11
feat(ui): add horizontal scrolling open bags on homepage
- Load all open bags instead of limiting to 3
- Replace grid layout with horizontal scroll container using snap
- Redesign bag cards as portrait layout with icon actions
- Add scrollbar-hide CSS utility and x_mark icon
2026-02-07 10:22:48 +00:00
Jon Seager
f9adc849c2
style: reformat checkin and home page templates 2026-02-07 09:48:37 +00:00
Jon Seager
3747ab1e93
refactor(bootstrap): use --created-at flags instead of SQL timestamps
Replace ~880 lines of post-hoc SQL UPDATEs with inline --created-at
flags on every entity creation command. Also fix bag roast dates and
finished dates to match the backdated 6-month timeline.

Keep one small SQL block for enriching cafe timeline events with
Website and Position fields (not generated by Rust to_timeline_event).
2026-02-07 09:48:33 +00:00
Jon Seager
3fccfa2cd0
test: update test struct initializers for created_at field
Add `created_at: None` to all New*/Update* struct constructions in
integration tests so they compile with the new optional field.
2026-02-07 09:48:26 +00:00
Jon Seager
e01b6d0a1c
feat: add optional created_at to entity creation and updates
Add `created_at: Option<DateTime<Utc>>` through all layers so CLI users
can backdate entities at creation/update time. When omitted, falls back
to `Utc::now()`.

- Domain: add field to all New*/Update* structs with serde(default)
- Domain: timeline events use entity created_at instead of Utc::now()
- Repos: unify INSERT to explicit Rust-side created_at with unwrap_or_else
- Repos: add created_at to UPDATE dynamic query builders
- Routes: add field to submission structs and has_changes guards
- Clients: pass created_at through manual JSON client methods
- CLI: add --created-at flag with parse_created_at helper (RFC 3339 or YYYY-MM-DD)
2026-02-07 09:48:20 +00:00
Jon Seager
e58ea5758f
feat(backup): add database reset action to account page
- Add reset() method to BackupService that deletes all 8 coffee tables
  in a transaction, respecting FK constraint order
- Add POST /api/v1/backup/reset endpoint (requires auth)
- Add "Reset Database" button with double-confirmation to account page
- Stack data buttons vertically on mobile for better layout
2026-02-07 08:45:30 +00:00
Jon Seager
47feedb273
refactor(ui): simplify navigation and page layouts
- Replace dropdown hamburger menu with inline icon buttons for add,
  theme toggle, account/login
- Move sign-out button to account page header
- Remove unused icons (home, hamburger, close, checkin, timeline,
  squares) and add plus icon
- Simplify data page header (remove inline add button, now in nav)
2026-02-07 08:43:05 +00:00
Jon Seager
28a64a93d1
fix(ui): block native change events in searchable-select component
Native change events from child inputs were bubbling up and reaching
data-on:change handlers, which expect only the CustomEvent with
evt.detail. Capture and stop native change events so only the
component's own CustomEvent propagates.
2026-02-07 08:28:22 +00:00
Jon Seager
766376be12
fix(checkin): use services instead of repos to record timeline events
The check-in handler was calling cafe_repo.insert() and
cup_repo.insert() directly, bypassing the service layer that records
timeline events. Switch to cafe_service.create() and
cup_service.create() so cafes and cups created via check-in appear on
the timeline.

Add timeline tests for cups (existing cafe, new cafe) and brews to
prevent this regression.
2026-02-07 08:28:12 +00:00
Jon Seager
9cccbd3b9b
fix(deploy): change healthcheck path 2026-02-06 20:51:47 +00:00
Jon Seager
251e4aebb5
fix(ci): match docker tag to Cargo.toml version in deploy workflow
The container image is tagged with the package version from flake.nix,
not the git short hash. Read the version from Cargo.toml so the
docker tag command references the correct source image.
2026-02-06 20:16:31 +00:00
Jon Seager
5033c7b2f6
fix(nix): resolve missing libssl.so.3 when running via nix run
- Add autoPatchelfHook to patch RPATH in the output binary so it can
  find libssl and libcrypto at runtime
- Add stdenv.cc.cc.lib to buildInputs to satisfy libgcc_s.so.1
  dependency during auto-patchelf
- Move LD_LIBRARY_PATH from devShell to the package so test binaries
  can find libssl during checkPhase (before patchelf runs)
2026-02-06 19:23:02 +00:00
Jon Seager
5959f625b5
chore: remove unused favicon.ico 2026-02-06 19:07:20 +00:00
dependabot[bot]
c0d6e588f6
build(deps): bump axum from 0.7.9 to 0.8.8 (#6)
* build(deps): bump axum from 0.7.9 to 0.8.8

Bumps [axum](https://github.com/tokio-rs/axum) from 0.7.9 to 0.8.8.
- [Release notes](https://github.com/tokio-rs/axum/releases)
- [Changelog](https://github.com/tokio-rs/axum/blob/main/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/axum/compare/axum-v0.7.9...axum-v0.8.8)

---
updated-dependencies:
- dependency-name: axum
  dependency-version: 0.8.8
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(deps): adapt code for axum 0.8 and tower-cookies 0.11

- Bump tower-cookies 0.10 → 0.11 (requires axum-core 0.5 / axum 0.8)
- Remove axum::async_trait usage (axum 0.8 uses native async traits)
- Migrate route path params from :param to {param} syntax

* fix(deps): correct axum and tower version constraints

Dependabot updated the lockfile for axum 0.8 but left the Cargo.toml
constraint at "0.7", causing CI to resolve back to 0.7.9. It also
incorrectly downgraded tower from "0.5" to "0.4", creating a duplicate
tower version in the lockfile and trait mismatches with axum 0.8.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jon Seager <jon@sgrs.uk>
2026-02-06 19:04:14 +00:00
Jon Seager
2fff8e8124
ci: better CI job naming 2026-02-06 19:03:07 +00:00
Jon Seager
8a669f70d2
ci: add linting to CI 2026-02-06 19:01:28 +00:00
Jon Seager
6431d97afa
ci: remove push trigger from CI workflow
Only run CI on pull requests to main, not on direct pushes.
2026-02-06 18:58:41 +00:00
Jon Seager
44db12298f
fix(nix): move build tools to nativeBuildInputs and fix test linker path
clang and lld are build-time tools but were in buildInputs, causing
"cannot find ld" during compilation. Set LD_LIBRARY_PATH for openssl
so integration tests can find libssl.so.3 during the check phase.
2026-02-06 18:51:29 +00:00
Jon Seager
531b58e8e6
feat(tasting-notes): add "creamy" to vegetal flavour category 2026-02-06 18:51:28 +00:00
dependabot[bot]
ea4093b699
build(deps): bump askama from 0.12.1 to 0.15.4 (#7)
* build(deps): bump askama from 0.12.1 to 0.15.4

Bumps [askama](https://github.com/askama-rs/askama) from 0.12.1 to 0.15.4.
- [Release notes](https://github.com/askama-rs/askama/releases)
- [Commits](https://github.com/askama-rs/askama/compare/0.12.1...v0.15.4)

---
updated-dependencies:
- dependency-name: askama
  dependency-version: 0.15.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(deps): adapt templates and tests for askama 0.15

- Migrate macro calls from {% call %} to {{ }} expression syntax (134 occurrences)
- Update test assertion for askama 0.15's numeric HTML entity encoding (&#38; vs &amp;)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jon Seager <jon@sgrs.uk>
2026-02-06 18:45:34 +00:00
dependabot[bot]
5bba529936
build(deps): bump tower from 0.4.13 to 0.5.2 (#8)
Bumps [tower](https://github.com/tower-rs/tower) from 0.4.13 to 0.5.2.
- [Release notes](https://github.com/tower-rs/tower/releases)
- [Commits](https://github.com/tower-rs/tower/compare/tower-0.4.13...tower-0.5.2)

---
updated-dependencies:
- dependency-name: tower
  dependency-version: 0.5.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-06 18:27:41 +00:00
Jon Seager
60dc9513f4
fix(backup): include brew quick_notes and cups in backup/restore
- Add missing quick_notes column to restore_brews INSERT
- Add cups export/restore with CupRecord and BackupData field
- Bump backup version to 2; old v1 backups still restore via serde default
2026-02-06 18:26:28 +00:00
Jon Seager
4ba21269ed
ci: build the right container 2026-02-06 18:24:23 +00:00
Jon Seager
ca43ad1d00
fix: set HTTP client timeout and remove pagination double-fetch
- Set a 30-second default timeout on the shared reqwest client so
  future call sites can't hang indefinitely.
- Use ensure_page_within() to clamp the page before querying instead
  of fetching, detecting an empty result, and re-fetching.
2026-02-06 18:19:37 +00:00
Jon Seager
42b971658d
fix(auth): clean up expired sessions on server startup
Wire the existing delete_expired() method to run at startup so the
sessions table doesn't grow unboundedly with stale rows.
2026-02-06 18:19:30 +00:00
Jon Seager
b5fdf8b27c
fix(logging): log errors instead of silently discarding with .ok()
Replace silent .ok() calls with explicit match + warn! logging in
encode_quick_notes and passkey deserialization for exclude lists.
2026-02-06 18:19:24 +00:00
Jon Seager
3594ad40ea
style(js): convert webauthn.js to arrow functions and template literals
Replace function declarations with const arrow functions and string
concatenation with template literals to match the project's JS style.
2026-02-06 18:19:18 +00:00
Jon Seager
26e1a4d930
refactor(ui): extract duplicated row-expand handler into shared function
The same ~250-character inline onclick handler was copy-pasted across
all 7 list templates. Extract it into a toggleRow() function in
base.html and replace the inline copies with a single call.
2026-02-06 18:19:12 +00:00
Jon Seager
f2fcada799
perf(auth): fix N+1 queries in WebAuthn authentication
Add list_all() to PasskeyCredentialRepository so auth_start and
auth_finish fetch all credentials in a single query instead of
looping through every user with a per-user query.
2026-02-06 18:18:58 +00:00
Jon Seager
a3cf7970d1
ci: split CI and deploy into separate workflows
Move test running to a dedicated push.yml workflow that triggers on both
push and PR, and restrict deploy.yml to push-to-main only.
2026-02-06 18:08:18 +00:00
Jon Seager
5bcd01d358
docs: document SQLite config and HTTP middleware stack in CLAUDE.md 2026-02-06 18:05:21 +00:00
Jon Seager
5c75c39883
perf(build): add release profile, lld linker, and defer script tags
- Add [profile.release] with thin LTO and symbol stripping
- Configure lld linker via .cargo/config.toml for faster linking
- Add clang and lld to Nix devShell
- Add defer attribute to component script tags to unblock HTML parsing
2026-02-06 18:05:16 +00:00
Jon Seager
4fb2e945a4
perf(http): add gzip compression and static asset cache headers
- Add CompressionLayer with gzip to the middleware stack
- Add Cache-Control: public, max-age=604800 (1 week) to all static
  asset routes (CSS, JS, favicons)
2026-02-06 18:05:09 +00:00
Jon Seager
494e0346bf
perf(db): enable WAL mode, add tuning pragmas and missing indexes
- Enable WAL journal mode for concurrent reads during writes
- Set synchronous=NORMAL, cache_size=8MB, temp_store=MEMORY, busy_timeout=5s
- Add indexes on brews.grinder_id, brews.brewer_id, brews.filter_paper_id
  to speed up the 6-table brew list JOIN
- Gitignore WAL sidecar files (*.db-shm, *.db-wal)
2026-02-06 18:04:58 +00:00
Jon Seager
1bcadf1d3e
ci: don't build twice in the test phase 2026-02-06 17:57:47 +00:00
Jon Seager
a8465826b5
docs: add security gotchas to CLAUDE.md
Document CSP update requirements, cookie Secure default, URL scheme
validation pattern, and Datastar fragment target checking so future
changes don't regress the security hardening.
2026-02-06 17:55:51 +00:00
Jon Seager
b4f9c02e5a
fix(brews): return reload response for brew-again from non-brew pages
The create_brew handler returned a #brew-list fragment for all Datastar
requests, but that element only exists on the brews data page. Requests
from the homepage or timeline now get a reload-script response instead,
fixing the PatchElementsNoTargetsFound error.
2026-02-06 17:52:28 +00:00
Jon Seager
835423f6ca
chore: remove unused ADMIN env vars, document BREWLOG_INSECURE_COOKIES
BREWLOG_ADMIN_USERNAME and BREWLOG_ADMIN_PASSWORD were referenced in
docs but never used in the codebase (WebAuthn-only auth). Replace with
the new BREWLOG_INSECURE_COOKIES variable.
2026-02-06 17:52:21 +00:00
Jon Seager
830d424297
fix(security): add server-side URL scheme validation for roaster homepage
Reject non-http(s) URL schemes (javascript:, data:, etc.) in both
NewRoaster::normalize() and new UpdateRoaster::normalize(). The HTML
input type="url" provides browser-side validation, but the API path
had no server-side check.
2026-02-06 17:52:15 +00:00
Jon Seager
1f2ec0fc14
fix(security): replace string interpolation with static match in gear SQL filter
GearCategory is a Rust enum so this was not exploitable, but the
format!() pattern is a code smell. Use a match returning &'static str
literals instead for consistency with the rest of the parameterised
query codebase.
2026-02-06 17:52:08 +00:00
Jon Seager
533a0a067f
fix(security): make session insert synchronous and default cookie Secure flag to on
- Await session DB insert before setting cookie, preventing orphaned sessions
- Invert cookie Secure default: now on by default, opt out via
  BREWLOG_INSECURE_COOKIES=true for local HTTP development
2026-02-06 17:52:01 +00:00
Jon Seager
85946ba9a4
fix(security): add security response headers and request body size limit
- Add Content-Security-Policy, X-Frame-Options, X-Content-Type-Options,
  Referrer-Policy, and Strict-Transport-Security response headers
- Set explicit 5 MB request body size limit via RequestBodyLimitLayer
- Enable tower-http "limit" and "set-header" features
2026-02-06 17:51:53 +00:00
Jon Seager
d35e1792da
ci: update to latest github checkout action 2026-02-06 17:35:26 +00:00
Jon Seager
95032f4014
chore: run cargo update 2026-02-06 17:34:57 +00:00
Jon Seager
0503fde8de
fix: ensure openssl linking works in clean build environments 2026-02-06 17:34:50 +00:00
Jon Seager
3fc21658a2
chore: update flake.lock file 2026-02-06 17:27:49 +00:00
Jon Seager
90d4b5eb74
ci: initialise ci configuration 2026-02-06 17:17:02 +00:00