mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 02:57:17 +01:00
main
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
10007be8b9 |
fix(routing): a missing product, service, cause, loan, event or investment answers 404, not 200 (#1662)
Measured on orangecat.ch (2026-11-12, 390px, signed out, light and dark): /products/00000000-0000-0000-0000-000000000000 answered 200 with the title "Product Not Found", and so did the same id under /services, /causes, /loans, /events and /investments. The same id under /assets, /wishlists, /research, /companions and /projects answered 404. Link checkers, uptime monitors, CDN caches and share-link validators read the status, not the HTML. Each of the six had a loading.tsx on its [id] segment, and /events, /loans and /investments one more on the list segment above. The skeleton streams first, so Next.js commits 200 before PublicEntityDetailPage reaches notFound(). Removed all nine, as #629 did for projects and profiles. /loans and /investments are redirect-only pages and /events is a client page, so their skeletons showed nothing a visitor needed. audit:routes missed it because it read only the page's own source, and these pages hand the existence check to PublicEntityDetailPage. The rule now follows the page's direct imports (type-only imports and comments ignored), lives in scripts/lib/soft-status.mjs so it can be tested on a fixture tree, and allowlists the eleven signed-in dashboard owner views that render the same component, which redirect to /auth when signed out. Checked against a local dev server: the six URLs answered 200 with the loading files and 404 without them, with the same title and h1. Claude-Session: https://claude.ai/code/session_019MDtmw3MnN44QwEv4M52CS Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
f39bb1beff |
design: every mark is one file, replaced with one command (#1315)
* design: every mark is one file, replaced with one command
pnpm run brand:import <slug> <file.svg>
converts any SVG (Figma, Illustrator, Inkscape, an icon set) into
src/config/marks/<slug>.ts, rebuilds the registry, and for this app's own
slug regenerates every static icon. Nothing else changes: the header,
hero, auth page, share cards, studio tiles, pillars and project banners
all render from the registry through one generic <Mark>, and know nothing
about which drawing they show.
- src/config/marks/: one data file per mark (viewBox + stroked/filled
shapes + motion), a generated index (MARKS, markFor), and generators/
for the marks drawn by code (OrangeCat's cat coil, Loki's coil). Solon's
scales were imported through the new command from lucide's SVG.
- <Mark>, <ProjectMark slug> (mark from the registry, else the initial),
BrandMarkIcon and the share-card mark all render any MarkDefinition.
PillarMark and sibling-marks.ts are gone.
- Giving any studio project a face is the same command with its fleet
slug; its tile and banner pick it up.
- The importer keeps geometry and how each shape is painted, drops colours
and a full-size background, and refuses transforms, clip paths, masks,
<use>, <text> and <image> with a message saying what to do, rather than
producing a mark that is quietly wrong.
- The brand test is written against any mark: registry matches the folder,
every mark is drawable, static icons equal exactly what the generator
writes. Replacing the drawing never means rewriting the test.
- Brand scripts run with plain node: a dependency-free resolve hook maps @/
and extensionless imports so they load the app's TypeScript directly.
Verified by swapping in a throwaway SVG end to end (icons regenerated,
background dropped, holes kept, gate green) and restoring the coil.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf
* fix(home): the badge fits a phone, the headline breaks at its tone, Loki's banner opens Loki
Found reviewing the live site after #1314 deployed:
- the three-part hero badge ran off a 390px screen; on phones it now
carries the lead phrase alone
- the two-tone headline wrapped mid-phrase on desktop, so the dim tone
started partway through a line; the tail now takes its own line from sm
- StudioProjectBanner reused the tile's link for its door, which for a
project funded here is the page itself — Loki's banner had no way to
open Loki. FleetTile now carries liveUrl, tested.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf
* fix(brand): the importer strips to a fixed point and refuses non-path data
CodeQL (3 high, incomplete multi-character sanitization): one pass of the
comment/<style> stripping over '<!<!--x-->-- … -->' leaves a fresh '<!--'
behind, and what it hid was then read as markup. The path is narrow — a
crafted SVG given to brand:import — but a mark's path data is written
verbatim into public files (favicon.svg), so it is closed twice:
- stripping repeats until nothing changes;
- every shape's path data must be pure path syntax (commands, numbers,
separators), or the import is refused with a message. A quote or angle
bracket can never reach a file, whatever the input looked like.
Tested both: a hidden shape behind a nested comment is not imported (a
single-pass strip imports it), and markup smuggled through a single-quoted
d is refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf
* fix(brand): read SVG comments and ignored blocks in one forward scan
CodeQL still flagged the comment/<style> stripping after
|
||
|
|
483cb9e0d6 |
refactor: one definition per concern, and slugs that survive a non-Latin name (#1059)
* refactor(lib): one sanitizeApiKey and one escapeHtml, with tests Two helpers that touch security-relevant material had drifted into copies: - sanitizeApiKey existed five times (transcribe route, groq, openai-compat, openrouter, health probes). It stands between a pasted credential and an Authorization header, so it now has one definition in src/lib/api-key.ts and a test. health-probes wanted the "did anything get stripped?" answer, which is sanitizeApiKeyChecked over the same regex rather than a sixth one. - escapeHtml existed four times across the email templates — the injection guard between a user-supplied name and an inbox. It is now exported once from templates/layout.ts, which all three callers already import. No behaviour change: the regex and the replacement chain are byte-identical to what every copy did. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(utils): one home for the display formatters that had drifted Four helper names were declared in three or four files each. Consolidated, with every call site printing byte-for-byte what it printed before — pinned by __tests__/unit/lib/display-formatters.test.ts. - formatDate x4 -> src/utils/dates.ts, which already owned one of them. The three copies were three DIFFERENT formats, so the module gained the two it was missing rather than flattening them: formatDateLong ("July 22, 2026") for article datelines, and formatIsoDay for 'YYYY-MM-DD' strings. formatIsoDay keeps the changelog's deliberate property of never building a Date: a calendar date has no timezone, and `new Date('2026-07-22')` is UTC midnight, which renders the day before west of Greenwich and renders it differently on the server than in the browser. - formatTimestamp x3 (identical) -> formatDateTimeOrDash in utils/locale.ts, next to the formatDateTime it wrapped. The two row components took it as a prop from their parent; they import it instead, so the prop is gone. - formatCountdown x3 -> src/utils/countdown.ts. These were not one helper that drifted but three formats sharing a name — 45 seconds read as "45s", "1m" or "0:45" depending on which file you imported from. They keep their three behaviours under names that say what they print. - readJson + errorMessage x3 in the browser payment clients -> the unwrapApiResponse that src/lib/api/client-response.ts already exports, and whose docblock warns about exactly these hand-rolled copies drifting. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * fix(slug): slugify transliterates, so a non-ASCII name is not deleted `slugify()` filtered to ASCII, which does not mean "strip accents" — it means "delete every letter that is not ASCII". `Café Genève` became `caf-genve`, `Grüße` became `gre`, and a Cyrillic or Japanese name produced the EMPTY STRING. Under a unique constraint an empty slug means the second such record cannot be saved at all, and the first one is addressed by a slug that identifies nobody — walked live on 2026-09-11, `Марина` became /profiles/someone and @someone. That was already known and already fixed, but in domain/profileClaims only: it kept its own `transliterate` and wrapped the broken slugify with it. Group creation, the Cat's organization handler and the entity create form all still went through the unwrapped path. So the transliteration moves into `slugify()` itself — German digraphs first (ß has no decomposition and would otherwise vanish), then NFKD plus a combining-mark strip for everything that decomposes, then a Cyrillic table for the script that does not. claimSlugFor keeps only what is specific to a claim: the person-<random> fallback. Also in this commit, same concern: - groups' `generateSlug` was `(name) => slugify(name)` — an alias, deleted; its one caller calls slugify, with a 'group' fallback so an unslugabble name cannot become the empty slug that ensureUniqueSlug would then extend. - slugify with randomSuffix no longer returns a slug starting with a dash when the base is empty. - scripts/cli/create-entity.ts deleted: a dead twin of create-entity.js, which is what `pnpm run create-entity` actually runs, carrying a third generateSlug. knip already listed it as unused. - formatAmount: the real implementation inside <CurrencyDisplay> moves to services/currency/formatting.ts as formatAmountSuffixed. Output is unchanged — it is deliberately not formatCurrency(), which prefixes BTC with ₿ where every card in the app suffixes the ticker. Tests: __tests__/unit/lib/slugify.test.ts covers the accented, German and Cyrillic cases plus the ASCII behaviour that must not have moved. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor: say the repeated blocks once — chat types, footer, Esplora readers Three places where the same thing was written out two to five times. - The Cat's tool-call vocabulary (ToolCallResultRef, ToolCallEvent, PrefillProposal) was defined twice: once by the pipeline that emits it and once by the panel that renders it, 55 lines of discriminated union that had to agree with nothing making them. The panel now re-exports the service's types. Type-only, so nothing enters the bundle. The two copies had already drifted: the service carries `handle?` on a result ref (the citation handle the UI needs to link the right source) and types `entityType` as the entity union rather than `string`. - <Footer> wrote out the same seventeen-line link column five times, and only two of the five carried the external-link branch — so which columns could hold an external link was an accident of which had been copied last. One <FooterColumn>. Renders identically: only `ecosystem` has external items today. - The Bitcoin service listed mempool.space and blockstream.info with byte-identical processBalance and processTransactions, 60 lines each. They both serve the Esplora API, so there is one reader for each now — one place for the satoshi arithmetic instead of one place to fix it and another to leave wrong. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor(timeline): the feed envelope is written once, not fourteen times Six feed functions across four files each spelled out the same three things by hand: the page window, the success envelope, and — twice per function, once for "no rows" and once for the catch — the empty envelope. Twenty copies of the same twenty-line object literal, which is why userFeeds.ts was the most-duplicated file in the repo (9 clones, 184 duplicated lines). The cost was not the lines. A field added to TimelineFeedResponse had to be remembered in all twenty places, and the ones that forgot it still compiled; `hasNext` was computed from `offset + limit` in fourteen separate expressions, any one of which could be edited alone. queries/feed-shape.ts now owns pageWindow(), feedResponse() and emptyFeed(). What differs between the feeds — which rows they fetch, and the RPC or view they fetch them from — stays in each file, which is the part that was ever worth reading. Two behaviours that looked accidental were kept deliberately and documented rather than "tidied": - emptyFeed echoes the requested limit WITHOUT clamping it to MAX_PAGE_SIZE. There are no rows for it to bound, and three call sites did exactly this. - emptyFeed with no pagination reports page 1: the early returns that never read their arguments (no session, follows nobody) did that, and the numbers are what the UI paginates on. userFeeds.ts 407 -> 281 lines, profileFeeds 87 -> 54, projectFeeds 122 -> 89, communityFeeds 94 -> 61, plus 95 shared. Existing timeline tests pass unchanged (62 files, 601 tests). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * refactor: extract the preludes that PUT/DELETE and five seed scripts repeated Five more places where the same block was written out twice or five times. - entityCrudHandler's PUT and DELETE each carried the same thirty lines: authenticate, load the row, run the ownership check. Now authorizeEntityMutation(), taking the verb and the optional per-entity access check. A change to the 401, the not-found copy or the ownership rule could previously land on update and not on delete — and delete is the half where getting it wrong is permanent. - /api/projects/[id]/favorite: POST and DELETE both throttled the write, loaded the project and looked up the existing favourite. One helper in lib/api/projectFavorites.ts. It is called rateLimitedFavoriteContext for a reason, spelled out in its docblock: api-route-guards.test.ts reads route SOURCES for evidence of a write quota, and a helper called loadX would have hidden that evidence behind an import — the gate goes quiet while the protection is still there, which is the shape of a gate that later goes quiet when it is not. - messaging/api-helpers.server.ts declared ActorRow, GroupMembershipRow and GroupActorRow twice, 27 lines apart-but-identical. TypeScript merges identical interfaces, so it compiled and nobody noticed. - The group-activity and re-engagement email templates each wired their config into emailLayout + emailPlainText by hand. One renderEmail() in layout.ts. - Five owner-gated operational scripts opened with the same thirty lines: load .env.local, read the service-role key, refuse without ORANGECAT_OWNER_SEED=1, build an admin client. These run against the LIVE database with a key that bypasses RLS, so that gate is the only thing between a stray `npx tsx` and production — not a check to keep in five versions. scripts/lib/owner-gate.ts owns it; the client it returns carries its own supabaseUrl so the two scripts that print which database they are about to write to still can. Also: webhook signature verification stays duplicated between the app and packages/sdk, because the SDK ships to customers and cannot import from src/, and the app should not take a build dependency on a customer-facing package. What is new is that the copy can no longer drift silently: __tests__/unit/services/webhook-signature-parity.test.ts drives BOTH through the same vectors — replay, forged body, bumped timestamp, wrong secret, truncated and non-hex signatures, multi-signature rotation — and fails if they ever disagree. Both files now say so at the top. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 * test(slug): the assertions that pinned the limitation the fix removes #1051 landed NFKD for slugify while this branch was in flight, and its tests pinned what NFKD alone cannot do: `slugify('Марина') === ''`, and an article titled in Cyrillic slugging to the literal word "article". Both were true, both were documented as "callers transliterate first" — and this branch moves that transliteration into slugify, so neither is true any more. Updated rather than deleted, because the cases are the interesting ones: they now assert 'marina' and 'shcherbakov', plus the sharp s that NFKD deletes ('Straße' → 'strasse', not 'strae'). The fallback assertion survives where it still applies — a title with no letters at all. The two slug test files are merged into the one that came with #1051; keeping a second file for the same function would have been the thing this branch is about. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8 --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
391f08b801 |
fix(profiles): count wallets with a function that exists, and gate the class (#760)
The profile page counted a visitor-visible wallet by calling an RPC named
`get_entity_wallets`. That function appears in no migration and returns
PGRST202 in production — it has never existed. The call sat inside a
try/catch whose comment read "if it errs we just show 0", so the error
path was not a fallback, it was the only path, for as long as the code
has been there.
The count is not cosmetic. ProfileLayout hides the Wallets tab from
visitors unless walletCount > 0 or the profile still carries a legacy
bitcoin_address/lightning_address. A profile whose receive methods live
in the modern wallets table therefore showed a visitor no way to pay it.
Confirmed on the live site: testuser123 has an active on-chain wallet and
their public profile offers only Overview / Timeline / Info.
Measured 2026-08-26: 3 of 83 profiles have an active wallet and only 1
has a legacy address, so 2 profiles are affected today. Small only
because wallet adoption is small — it scales with exactly the number we
want to grow, and would have quietly blunted any push to grow it.
Counted through the same admin-client path GET /api/wallets already uses
rather than by writing the missing function. That route's comment states
the intent — "the API is the one public surface, so raw PostgREST can no
longer enumerate balances or other wallet internals" — and a SECURITY
DEFINER function would open a second public surface over a table holding
nwc_connection_uri, a write-only secret. Counting adds no surface: it
returns a number, never a row. Failures are logged rather than swallowed,
so a permanently-broken count cannot hide again.
Asking production which functions PostgREST exposes turned up three more
RPCs that do not exist: update_presence and set_typing_indicator (so
presence and typing indicators are inert), and create_timeline_event on a
fallback branch. Four instances is a class, so check:rpc-exists joins
`verify`: every `.rpc('name')` must have a CREATE FUNCTION in
supabase/migrations. The three remaining are baselined with their
consequence written down — each needs its own migration and design.
The gate is parser-based so CI needs no database, and `--verify` proves
the parser against the live one: 37 called names checked against 80 live
functions, migrations and database agreeing on every one. Proven by
mutation too — re-adding the removed call turns it red.
Its own first run said "RPCs called: 0" and passed. It had reached for
blankNonCode, which blanks string CONTENTS, so it had erased every name
it was looking for — green because blind, the exact failure it exists to
catch. The shared tokenizer now offers blankComments for the case where
the string literal IS the thing you are looking for.
Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
df6edd3c7f |
fix(wallets): stop dividing a BTC balance by a goal denominated in francs (#758)
A wallet's balance is BTC. Its goal is not: `goal_amount` is denominated
in `goal_currency`, and the wallet form defaults that to fiat. Both
surfaces that drew the progress bar divided one straight into the other:
const progressPercent = (wallet.balance_btc / wallet.goal_amount) * 100
Measured against production today: 18 of 33 wallets carry a goal, every
one of them in fiat (CHF 11, USD 6, EUR 1), and not one in BTC. So every
savings-goal bar in the app was computed from BTC divided by francs —
including the one on the PUBLIC profile, which is the second copy of the
same expression.
It is invisible right now only because every one of those balances is
still 0.00, and zero over anything is zero. It starts lying on the first
deposit: a wallet holding 0.025 BTC toward a CHF 2 500 goal would have
read "0.001% funded" while sitting at the whole target. That case is
pinned as a test.
Both sides now meet in the goal's own currency before they meet in one
expression, via a single lib/wallet-goal.ts rather than a third inline
copy. When no rate is available the helper returns null instead of a
number: useCurrencyConversion signals a missing rate with 0 precisely so
callers do not guess, and 0 read as a percentage would tell someone they
have saved nothing when they may be fully funded.
Fixing the same line in two files is where the Never-Twice rule says to
automate, so check:currency-units joins `verify`: it fails on arithmetic
between a BTC-suffixed identifier and a bare `*_amount`. Proven by
mutation — restoring the original expression turns it red, and it caught
the naive version of its own scanner on the first run (it stripped only
`//`, and the first thing it read was a block comment describing the
bug). That is why blankNonCode moved to scripts/lib/: one tokenizer, so
a third scanner cannot reinvent the version that already cost a day.
Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|