Skip to content

refactor(notebook): startpage tab/label cleanup + ts-rest auth status#693

Open
Movm wants to merge 5 commits intomasterfrom
feat/notebook-startpage-tabs-and-stats
Open

refactor(notebook): startpage tab/label cleanup + ts-rest auth status#693
Movm wants to merge 5 commits intomasterfrom
feat/notebook-startpage-tabs-and-stats

Conversation

@Movm
Copy link
Copy Markdown
Collaborator

@Movm Movm commented Apr 26, 2026

Summary

  • Rename Globaler Chat tab label to Chat on the notebook startpage (NotebookStartpage.tsx)
  • Drop the Kategorien and Quellen stat cards from the startpage statistics section
  • Migrate /api/auth/status to a ts-rest contract

Test plan

  • Open a notebook startpage with notebookMention set → the third tab reads "Chat" (not "Globaler Chat")
  • Statistics section no longer renders Kategorien / Quellen cards
  • /api/auth/status still returns the same shape on the client

Movm added 4 commits April 25, 2026 19:50
Fixes the admin gate ("Kein Zugriff" page) caused by the legacy /status
handler stripping fields from the user response. The hand-picked literal
omitted is_admin and ~30 other UserProfile fields, so the frontend's
useAuthStore could never see is_admin=true even when the DB row had it.

Replaces the manual pick with toBetterAuthUser() — the same null-strip +
Zod-parse boundary already used by authMiddleware. The new ts-rest
contract enforces the response shape end-to-end, making this regression
class impossible to reintroduce.

- packages/contracts: authStatusContract + authStatusResponseSchema
  reusing userProfileSchema.nullable()
- apps/api: authStatusContractRouter mounted in routes.ts before the
  legacy authRouter; legacy /status removed from authCore.ts
- packages/shared: authStatus added to the typed ContractsClient
- middleware: toBetterAuthUser exported for reuse
…page

Remove the two cards from the StatisticsSection grid so the startpage
focuses on document count and date range. Collapse the grid from
four columns to two so the remaining cards fill the row at all
breakpoints, and shrink the matching skeleton placeholders.
Regolo's gemma4-31b endpoint hangs upstream — every notebook chat with
the default Gemma model just spun forever because the AI SDK has no
built-in first-token deadline. This change:

- Adds litellmFetchWithThinkingDisabled (sibling to regoloThinkingFetch)
  injecting Ollama's `think: false` so LiteLLM-served gemma streams
  content instead of burning its entire token budget on `reasoning`.
- Re-routes the user-facing "Gemma 4" model from Regolo → LiteLLM. Old
  `gemma-regolo` ID is aliased server-side and migrated client-side
  (chatStore v6) to the new `gemma-litellm` ID.
- Adds Qwen 3.6 27B as a selectable model (already in the existing
  Regolo reasoning-stream allowlist, so no extra wiring).
- Introduces a 20s first-token deadline + single-step cross-provider
  fallback (gemma-litellm ↔ gpt-oss-regolo) in responseStreamingService.
  Qwen entries intentionally have no `fallback` field — the
  Chinese-only-when-selected firewall (informed-consent boundary,
  documented in ModelConfig).
- Fixes pre-existing bug: getModel('litellm', modelId) ignored the
  modelId arg and always used LITELLM_DEFAULT_MODEL.

Fallback is silent end-user-side: server emits a `fallback` SSE event,
both runtime adapters log it to the browser console, no UI banner.

Implementation notes:
- streamAndAccumulate / streamAndAccumulateWithReasoning now have a
  shared `wrapWithCompatCatch` factory and an `*OrThrow` internal layer
  used by streamWithFallback. Existing chat router callers see the same
  null-on-failure shape, plus the new deadline + empty-completion
  safety nets for free.
- Single shared deadline across initial-probe iterations (was
  accidentally giving 40s grace via per-call setTimeout).
- Reasoning streamer split into Phase-1 (race vs deadline until first
  text) + Phase-2 (drain without race) — eliminates wasted Promise.race
  microtask hops on every reasoning chunk after first content.
- Uses native AbortSignal.any() (Node 20.3+) instead of a hand-rolled
  composeAbortSignals helper.
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.

1 participant