Skip to content

Split the backend, one chat session for both chats, one declined field, unused CSS removed, fonts preloaded - #86

Merged
Yanir-R merged 6 commits into
mainfrom
claude/project-thread-klhtm4
Nov 25, 2026
Merged

Yanir-R merged 6 commits into
mainfrom
claude/project-thread-klhtm4

Conversation

@Yanir-R

@Yanir-R Yanir-R commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Requested by Yanir · project thread

What changed

Structure only, plus one fix for load-time movement. Otherwise the site should look and behave exactly as it does on main.

Backend split (FastAPI's layout for an application larger than one file)

  • main.py (1,392 lines) now only builds the app: the edge-secret check, cache headers, CORS and the routers (124 lines).
  • settings.py: all configuration read from the environment.
  • schemas.py: every request and reply model.
  • routes/: chat.py, contact.py, booking.py and content.py, one APIRouter each.
  • replies.py: the parts a chat reply is built from (cards, sources, handoff, trace, output checks).
  • mailer.py: SMTP.
  • Functions used across modules are public (no leading underscore). Tests patch names where they are looked up.

One declined field

  • The site reads the server's declined alone. The search outcome unmatched no longer stands in for it in the home chat or in the choice of drawing.
  • tests/test_contract.py reads the frontend's TypeScript and compares three things with the Pydantic models: the reply's fields, the search outcomes and the starter topics.
  • The backend workflow also runs on changes to those frontend files.

One chat session for both chats

  • chat/useAgentSession.ts holds what the home chat and the chat under a post share: one request at a time, the Turnstile token, the once-per-conversation handoff offer, and closing when the day's answers are spent.
  • foldHandoffs folds the offer the same way in both chats.
  • chat/sources.ts gives one rule for the sources row. The post chat now names Yanir's notes first, as the home chat already did.

CSS

Fonts preloaded

  • A small Vite plugin adds <link rel="preload"> for the four Assistant and Karantina files to index.html, which the prerender copies to every route.
  • Before, text painted in the fallback font and then reflowed.
  • Measured over all 70 routes at 1024px:
    • summed layout shift fell from 11.46 to 6.52
    • the worst page fell from 0.46 to 0.29
    • pages over 0.1 fell from 43 to 31
  • The shift that remains is the prerendered crawler text being replaced when the app mounts. That needs a separate decision.

Docs

  • README, ARCHITECTURE, PRIVACY and ROADMAP point at the new files.
  • The roadmap item "say which document an answer drew on" is done (ChatResponse.used) and is removed.

Why

Each module has one job, the frontend and backend contract is checked by a test, both chats share one engine, the CSS holds only what the site uses, and text no longer jumps when the fonts arrive.

How to verify

Checklist

  • Every commit is signed off (git commit -s)
  • Backend: pytest -q passes from backend/
  • Frontend: npm run typecheck, npm run lint, npm run format:check and npm run build pass from frontend/
  • bash .github/scripts/check_hygiene.sh passes from the repository root
  • No personal data, real paths, hostnames or credentials in code, tests or docs
  • Tests use invented data only
  • No duplicated logic; docs link to an existing explanation instead of repeating it
  • Docs updated if behavior or a privacy claim changed

🤖 Generated with Claude Code

https://claude.ai/code/session_014dGcvVc19RwzWGMn9NWo9s

… declined field

- main.py now only builds the app: the edge-secret check, cache headers,
  CORS and the routers. Routes live in routes/ (chat, contact, booking,
  content), request and reply shapes in schemas.py, configuration in
  settings.py, the parts a chat reply is built from in replies.py and SMTP
  in mailer.py. Functions used across modules lose their leading underscore.
- Tests patch names where they are looked up (settings, rate_limit, mailer,
  routes.chat).
- declined: the site reads the server's `declined` field alone. The search
  outcome no longer stands in for it, so a declined answer reads the same in
  the home chat, on a post page and in the choice of drawing.
- tests/test_contract.py reads the frontend's declarations and compares the
  reply fields, search outcomes and starter topics with the server's models;
  the backend workflow runs on changes to those frontend files too.
- Docs and comments point at the new files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014dGcvVc19RwzWGMn9NWo9s
Signed-off-by: Claude <noreply@anthropic.com>
- chat/useAgentSession.ts: what the home chat and the chat under a post share
  about talking to the agent: one request at a time, the Turnstile token, the
  once-per-conversation offer to talk directly, and closing when the day's
  answers are spent. Both engines send through it; each keeps only what it
  draws around the answer.
- foldHandoffs: one way to fold the offer when the conversation moves on.
- chat/sources.ts: one rule for the sources row, used by both chats. The
  post chat now names Yanir's notes first and localises profile titles, as
  the home chat already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014dGcvVc19RwzWGMn9NWo9s
Signed-off-by: Claude <noreply@anthropic.com>
- 59 class names that no source file mentions and that no page showed in a
  recorded run (every page at four sizes, every chat path, every dialog and
  hover) lose their selectors; rules left empty go with them (about 1,190
  lines of site.css). Classes built in code (`t${i}`, `k-${id}`) are kept.
- Four declarations repeated with the same value by a later rule with the
  same selector go; the later rule wins either way.
- No two rules were identical, so none was removed for that reason.
- 61 of 64 full-page screenshots are pixel-identical before and after; the
  three that differ differ only in a video's loading spinner.
- The unused QuickMessageOption type goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014dGcvVc19RwzWGMn9NWo9s
Signed-off-by: Claude <noreply@anthropic.com>
@Yanir-R Yanir-R self-assigned this Nov 25, 2026
The Hebrew and Latin subsets of Assistant and Karantina were found only
after the CSS loaded, so pages painted in the fallback font and then
reflowed: up to 0.4 of layout shift on long posts at 1024px. A small
plugin adds a preload link for those four files to index.html, which the
prerender copies to every route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014dGcvVc19RwzWGMn9NWo9s
Signed-off-by: Claude <noreply@anthropic.com>
@Yanir-R Yanir-R changed the title Split the backend, one chat session for both chats, one declined field, unused CSS removed Split the backend, one chat session for both chats, one declined field, unused CSS removed, fonts preloaded Nov 25, 2026
@Yanir-R
Yanir-R merged commit 7932c9f into main Nov 25, 2026
5 checks passed
@Yanir-R
Yanir-R deleted the claude/project-thread-klhtm4 branch November 25, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants