refactor(notebook): startpage tab/label cleanup + ts-rest auth status#693
Open
refactor(notebook): startpage tab/label cleanup + ts-rest auth status#693
Conversation
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.
9 tasks
… fallback" This reverts commit 5ba1b6d.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NotebookStartpage.tsx)/api/auth/statusto a ts-rest contractTest plan
notebookMentionset → the third tab reads "Chat" (not "Globaler Chat")/api/auth/statusstill returns the same shape on the client