Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
feat(web-studio): PWA, mobile UI polish, OAuth-setup tab, request-logs touch-ups (#2178)
Zayn Jarvis4e9473406b92
diff --git a/openviking/server/app.py b/openviking/server/app.pyindex 59e6ef5d6..d0548259b 100644--- a/openviking/server/app.py+++ b/openviking/server/app.py@@ -13,7 +13,7 @@ from typing import Callable, Optionalfrom fastapi import FastAPI, Requestfrom fastapi.exceptions import RequestValidationErrorfrom fastapi.middleware.cors import CORSMiddleware-from fastapi.responses import FileResponse, JSONResponse+from fastapi.responses import FileResponse, JSONResponse, RedirectResponsefrom starlette.exceptions import HTTPException as StarletteHTTPExceptionfrom openviking.server.api_keys import APIKeyManager@@ -652,6 +652,12 @@ def create_app(def _studio_response(path: Path, *, no_store: bool = False) -> FileResponse:return FileResponse(path, headers=_studio_no_store if no_store else None)+ @app.get("/", include_in_schema=False)+ async def _root_redirect_to_studio():+ # When web-studio is bundled, treat / as a convenience entry to+ # /studio/ so users hitting the bare origin land on the UI.+ return RedirectResponse(url="/studio/", status_code=302)+@app.get("/studio", include_in_schema=False)async def _studio_root_handler():return _studio_response(_studio_index, no_store=True)diff --git a/web-studio/index.html b/web-studio/index.htmlindex c474176d9..b17fc5644 100644--- a/web-studio/index.html+++ b/web-studio/index.html@@ -10,7 +10,16 @@/><link rel="apple-touch-icon" href="%BASE_URL%apple-touch-icon.png" /><link rel="manifest" href="%BASE_URL%manifest.json" />- <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <meta+ name="viewport"+ content="width=device-width, initial-scale=1.0, viewport-fit=cover"+ />+ <meta name="theme-color" content="#ffffff" />+ <meta name="application-name" content="OpenViking Studio" />+ <meta name="mobile-web-app-capable" content="yes" />+ <meta name="apple-mobile-web-app-capable" content="yes" />+ <meta name="apple-mobile-web-app-title" content="OpenViking" />+ <meta name="apple-mobile-web-app-status-bar-style" content="default" /><title>OpenViking Studio</title></head><body>diff --git a/web-studio/public/icon-192-maskable.png b/web-studio/public/icon-192-maskable.pngnew file mode 100644index 000000000..3beedf94dBinary files /dev/null and b/web-studio/public/icon-192-maskable.png differdiff --git a/web-studio/public/icon-192.png b/web-studio/public/icon-192.pngnew file mode 100644index 000000000..8e7eda5caBinary files /dev/null and b/web-studio/public/icon-192.png differdiff --git a/web-studio/public/icon-512-maskable.png b/web-studio/public/icon-512-maskable.pngnew file mode 100644index 000000000..2dd594c74Binary files /dev/null and b/web-studio/public/icon-512-maskable.png differdiff --git a/web-studio/public/icon-512.png b/web-studio/public/icon-512.pngnew file mode 100644index 000000000..fb9ea3329Binary files /dev/null and b/web-studio/public/icon-512.png differdiff --git a/web-studio/public/manifest.json b/web-studio/public/manifest.jsonindex ae9062b72..290449483 100644--- a/web-studio/public/manifest.json+++ b/web-studio/public/manifest.json@@ -1,6 +1,7 @@{"short_name": "OpenViking","name": "OpenViking Studio",+ "description": "OpenViking Studio — agent-native context database UI","icons": [{"src": "favicon-32.png",@@ -13,10 +14,36 @@"type": "image/png","sizes": "180x180","purpose": "any"+ },+ {+ "src": "icon-192.png",+ "type": "image/png",+ "sizes": "192x192",+ "purpose": "any"+ },+ {+ "src": "icon-192-maskable.png",+ "type": "image/png",+ "sizes": "192x192",+ "purpose": "maskable"+ },+ {+ "src": "icon-512.png",+ "type": "image/png",+ "sizes": "512x512",+ "purpose": "any"+ },+ {+ "src": "icon-512-maskable.png",+ "type": "image/png",+ "sizes": "512x512",+ "purpose": "maskable"}],- "start_url": ".",+ "start_url": "./",+ "scope": "./","display": "standalone",- "theme_color": "#000000",+ "orientation": "any",+ "theme_color": "#ffffff","background_color": "#ffffff"}diff --git a/web-studio/public/service-worker.js b/web-studio/public/service-worker.jsnew file mode 100644index 000000000..99cf18d1f--- /dev/null+++ b/web-studio/public/service-worker.js@@ -0,0 +1,24 @@+// OpenViking Studio service worker.+//+// Minimal pass-through SW whose only purpose is to satisfy the PWA+// installability criteria (Chrome requires a registered SW with a fetch+// handler). We do NOT cache application code or API responses, because:+// - The OV server already sets Cache-Control: no-store on /studio HTML+// - Cached SPA shells get out of sync with the bundled assets on upgrade+// - All API calls must hit the live server for auth and freshness.+//+// If/when we want offline support, switch to a workbox-based bundle via+// vite-plugin-pwa.++self.addEventListener('install', (event) => {+ // Activate this SW immediately; no precache step.+ self.skipWaiting()+})++self.addEventListener('activate', (event) => {+ event.waitUntil(self.clients.claim())+})++self.addEventListener('fetch', () => {+ // Intentional no-op: let the browser handle the request normally.+})diff --git a/web-studio/src/components/app-shell.tsx b/web-studio/src/components/app-shell.tsxindex 7f0e3b9ce..1686949f5 100644--- a/web-studio/src/components/app-shell.tsx+++ b/web-studio/src/components/app-shell.tsx@@ -7,6 +7,7 @@ import {FolderTreeIcon,HomeIcon,GithubIcon,+ KeyRoundIcon,LanguagesIcon,LoaderIcon,MessageSquareIcon,@@ -27,6 +28,7 @@ import {CollapsibleTrigger,} from '#/components/ui/collapsible'import { ConnectionDialog } from '#/components/connection-dialog'+import { OAuthSetupDialog } from '#/components/oauth-setup-dialog'import { buttonVariants } from '#/components/ui/button'import {DropdownMenu,@@ -347,6 +349,7 @@ export function AppShell({ children }: { children: React.ReactNode }) {function AppShellInner({ children }: { children: React.ReactNode }) {const { i18n, t } = useTranslation(['appShell', 'common'])+ const navigate = useNavigate()const pathname = useRouterState({select: (state) => state.location.pathname,})@@ -358,6 +361,27 @@ function AppShellInner({ children }: { children: React.ReactNode }) {const currentLanguageOption =LANGUAGE_OPTIONS.find((item) => item.value === currentLanguage) ??LANGUAGE_OPTIONS[0]+ const [oauthSetupOpen, setOauthSetupOpen] = React.useState(false)+ const oauthSetupActive =+ pathname === '/oauth/setup' || pathname.startsWith('/oauth/setup/')++ function openOAuthSetup(): void {+ if (oauthSetupActive) {+ return+ }+ // Desktop: open the dialog so the user keeps the current page underneath.+ // Phone / narrow tablets: navigate to the dedicated page since fullscreen+ // dialogs are awkward to dismiss on mobile.+ const useDialog =+ typeof window !== 'undefined' &&+ typeof window.matchMedia === 'function' &&+ window.matchMedia('(min-width: 768px)').matches+ if (useDialog) {+ setOauthSetupOpen(true)+ } else {+ void navigate({ to: '/oauth/setup' })+ }+ }return (<SidebarProvider@@ -440,6 +464,17 @@ function AppShellInner({ children }: { children: React.ReactNode }) {<span>{t('footer.connection', { ns: 'appShell' })}</span></SidebarMenuButton></SidebarMenuItem>+ <SidebarMenuItem>+ <SidebarMenuButton+ onClick={openOAuthSetup}+ isActive={oauthSetupActive}+ tooltip={t('navigation.oauthSetup.title', { ns: 'appShell' })}+ className="text-base"+ >+ <KeyRoundIcon className="size-5" />+ <span>{t('navigation.oauthSetup.title', { ns: 'appShell' })}</span>+ </SidebarMenuButton>+ </SidebarMenuItem><SidebarMenuItem><SidebarMenuButtonrender={@@ -543,6 +578,10 @@ function AppShellInner({ children }: { children: React.ReactNode }) {</SidebarInset><ConnectionDialog />+ <OAuthSetupDialog+ open={oauthSetupOpen}+ onOpenChange={setOauthSetupOpen}+ /></SidebarProvider>)}diff --git a/web-studio/src/components/connection-dialog.tsx b/web-studio/src/components/connection-dialog.tsxindex 6c93acebd..2bc92f43a 100644--- a/web-studio/src/components/connection-dialog.tsx+++ b/web-studio/src/components/connection-dialog.tsx@@ -1,10 +1,7 @@import * as React from 'react'import { useTranslation } from 'react-i18next'-import {- summarizeConnectionIdentity,- useAppConnection,-} from '#/hooks/use-app-connection'+import { useAppConnection } from '#/hooks/use-app-connection'import { Button } from '#/components/ui/button'import {@@ -28,27 +25,10 @@ import {FieldLabel,FieldSet,} from '#/components/ui/field'-import {- IdentityPicker,- resolveEffectiveApiKey,-} from '#/components/identity-picker'-import type { IdentityPickerValue } from '#/components/identity-picker'import { Input } from '#/components/ui/input'-type OtpResult = {- otp: string- expires_at: number- ttl_seconds: number-}--type OtpPhase =- | { kind: 'idle' }- | { kind: 'requesting' }- | { kind: 'ready'; result: OtpResult }- | { kind: 'error'; message: string }-export function ConnectionDialog() {- const { t } = useTranslation(['connection', 'oauth', 'common'])+ const { t } = useTranslation(['connection', 'common'])const {connection,isConnectionDialogOpen,@@ -206,8 +186,6 @@ export function ConnectionDialog() {</>)}</Card>-- <OAuthOtpSection /></FieldGroup></FieldSet>@@ -232,181 +210,3 @@ export function ConnectionDialog() {)}-function OAuthOtpSection() {- const { t } = useTranslation(['connection', 'oauth'])- const { connection, serverMode } = useAppConnection()- const currentIdentity = React.useMemo(() => {- const summary = summarizeConnectionIdentity(connection, serverMode)- return summary.values?.identity ?? t(summary.labelKey, { ns: 'connection' })- }, [connection, serverMode, t])-- const [identityValue, setIdentityValue] = React.useState<IdentityPickerValue>(- () =>- connection.apiKey ? { mode: 'current' } : { mode: 'custom', apiKey: '' },- )- const [phase, setPhase] = React.useState<OtpPhase>({ kind: 'idle' })- const [remaining, setRemaining] = React.useState(0)- const [copied, setCopied] = React.useState(false)-- React.useEffect(() => {- if (phase.kind !== 'ready') {- return- }- const tick = () => {- const now = Math.floor(Date.now() / 1000)- setRemaining(Math.max(0, phase.result.expires_at - now))- }- tick()- const id = window.setInterval(tick, 1000)- return () => window.clearInterval(id)- }, [phase])-- React.useEffect(() => {- if (!copied) return- const id = window.setTimeout(() => setCopied(false), 1500)- return () => window.clearTimeout(id)- }, [copied])-- async function generateOtp(): Promise<void> {- const effectiveKey = resolveEffectiveApiKey(- identityValue,- connection.apiKey,- )- if (!effectiveKey) {- setPhase({- kind: 'error',- message: t('identityPicker.noCurrent', { ns: 'oauth' }),- })- return- }- setPhase({ kind: 'requesting' })- try {- const resp = await fetch('/api/v1/auth/otp', {- method: 'POST',- cache: 'no-store',- headers: {- 'Content-Type': 'application/json',- Authorization: `Bearer ${effectiveKey}`,- },- body: '{}',- })- if (!resp.ok) {- const text = await resp.text().catch(() => '')- setPhase({- kind: 'error',- message: extractMessage(text) || String(resp.status),- })- return- }- const result = (await resp.json()) as OtpResult- setPhase({ kind: 'ready', result })- } catch (err: unknown) {- const message = err instanceof Error ? err.message : String(err)- setPhase({ kind: 'error', message })- }- }-- async function copyOtp(): Promise<void> {- if (phase.kind !== 'ready') return- try {- await navigator.clipboard.writeText(phase.result.otp)- setCopied(true)- } catch {- // Clipboard may be unavailable (insecure context); ignore.- }- }-- const hasAnyKey = Boolean(- resolveEffectiveApiKey(identityValue, connection.apiKey),- )- const expired = phase.kind === 'ready' && remaining <= 0-- return (- <Card size="sm" className="gap-3 border bg-background/70 shadow-none">- <CardHeader className="gap-1.5">- <CardTitle className="text-sm">- {t('oauthOtp.title', { ns: 'connection' })}- </CardTitle>- <CardDescription>- {t('oauthOtp.description', { ns: 'connection' })}- </CardDescription>- </CardHeader>- <CardContent className="grid gap-4">- <IdentityPicker- value={identityValue}- onChange={setIdentityValue}- currentApiKey={connection.apiKey}- currentIdentityLabel={currentIdentity}- disabled={phase.kind === 'requesting'}- />-- {phase.kind === 'ready' && !expired ? (- <div className="grid gap-2 rounded-md border bg-muted/40 p-3">- <span className="text-xs text-muted-foreground">- {t('oauthOtp.codeLabel', { ns: 'connection' })}- </span>- <div className="flex items-center gap-3">- <span className="font-mono text-2xl tracking-[0.4em]">- {phase.result.otp}- </span>- <Button- type="button"- variant="outline"- size="sm"- onClick={() => void copyOtp()}- >- {copied- ? t('oauthOtp.copied', { ns: 'connection' })- : t('oauthOtp.copy', { ns: 'connection' })}- </Button>- </div>- <span className="text-xs text-muted-foreground">- {t('oauthOtp.expiresIn', {- ns: 'connection',- seconds: remaining,- })}- </span>- </div>- ) : null}-- {expired ? (- <p className="text-xs text-destructive">- {t('oauthOtp.expired', { ns: 'connection' })}- </p>- ) : null}-- {phase.kind === 'error' ? (- <p className="text-xs text-destructive">- {t('oauthOtp.generateError', {- ns: 'connection',- message: phase.message,- })}- </p>- ) : null}-- <div>- <Button- type="button"- variant="outline"- size="sm"- onClick={() => void generateOtp()}- disabled={phase.kind === 'requesting' || !hasAnyKey}- >- {phase.kind === 'ready' && !expired- ? t('oauthOtp.regenerate', { ns: 'connection' })- : t('oauthOtp.generate', { ns: 'connection' })}- </Button>- </div>- </CardContent>- </Card>- )-}--function extractMessage(raw: string): string {- try {- const parsed = JSON.parse(raw) as { error?: { message?: string } }- return parsed.error?.message || raw.slice(0, 200)- } catch {- return raw.slice(0, 200)- }-}diff --git a/web-studio/src/components/oauth-setup-dialog.tsx b/web-studio/src/components/oauth-setup-dialog.tsxnew file mode 100644index 000000000..0874d3798--- /dev/null+++ b/web-studio/src/components/oauth-setup-dialog.tsx@@ -0,0 +1,260 @@+import * as React from 'react'+import { useTranslation } from 'react-i18next'+import { ExternalLinkIcon } from 'lucide-react'++import { Button } from '#/components/ui/button'+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from '#/components/ui/card'+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '#/components/ui/dialog'+import {+ IdentityPicker,+ resolveEffectiveApiKey,+} from '#/components/identity-picker'+import type { IdentityPickerValue } from '#/components/identity-picker'+import {+ summarizeConnectionIdentity,+ useAppConnection,+} from '#/hooks/use-app-connection'++type OtpResult = {+ otp: string+ expires_at: number+ ttl_seconds: number+}++type OtpPhase =+ | { kind: 'idle' }+ | { kind: 'requesting' }+ | { kind: 'ready'; result: OtpResult }+ | { kind: 'error'; message: string }++const OAUTH_DOCS_URL =+ 'https://github.com/volcengine/OpenViking/blob/main/docs/en/guides/11-oauth.md'++export function OAuthSetupDialog({+ open,+ onOpenChange,+}: {+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const { t } = useTranslation(['oauthSetup', 'connection', 'oauth', 'common'])+ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="max-w-2xl">+ <DialogHeader>+ <DialogTitle>{t('page.title', { ns: 'oauthSetup' })}</DialogTitle>+ <DialogDescription>+ {t('page.intro', { ns: 'oauthSetup' })}+ </DialogDescription>+ </DialogHeader>+ <a+ href={OAUTH_DOCS_URL}+ target="_blank"+ rel="noopener noreferrer"+ className="inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline"+ >+ {t('page.docsLink', { ns: 'oauthSetup' })}+ <ExternalLinkIcon className="size-3.5" />+ </a>+ <OAuthOtpForm />+ <DialogFooter>+ <Button variant="outline" onClick={() => onOpenChange(false)}>+ {t('cancel', { ns: 'common', keyPrefix: 'action' })}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ )+}++export function OAuthOtpForm() {+ const { t } = useTranslation(['connection', 'oauth'])+ const { connection, serverMode } = useAppConnection()+ const currentIdentity = React.useMemo(() => {+ const summary = summarizeConnectionIdentity(connection, serverMode)+ return summary.values?.identity ?? t(summary.labelKey, { ns: 'connection' })+ }, [connection, serverMode, t])++ const [identityValue, setIdentityValue] = React.useState<IdentityPickerValue>(+ () =>+ connection.apiKey ? { mode: 'current' } : { mode: 'custom', apiKey: '' },+ )+ const [phase, setPhase] = React.useState<OtpPhase>({ kind: 'idle' })+ const [remaining, setRemaining] = React.useState(0)+ const [copied, setCopied] = React.useState(false)++ React.useEffect(() => {+ if (phase.kind !== 'ready') {+ return+ }+ const tick = () => {+ const now = Math.floor(Date.now() / 1000)+ setRemaining(Math.max(0, phase.result.expires_at - now))+ }+ tick()+ const id = window.setInterval(tick, 1000)+ return () => window.clearInterval(id)+ }, [phase])++ React.useEffect(() => {+ if (!copied) return+ const id = window.setTimeout(() => setCopied(false), 1500)+ return () => window.clearTimeout(id)+ }, [copied])++ async function generateOtp(): Promise<void> {+ const effectiveKey = resolveEffectiveApiKey(+ identityValue,+ connection.apiKey,+ )+ if (!effectiveKey) {+ setPhase({+ kind: 'error',+ message: t('identityPicker.noCurrent', { ns: 'oauth' }),+ })+ return+ }+ setPhase({ kind: 'requesting' })+ try {+ const resp = await fetch('/api/v1/auth/otp', {+ method: 'POST',+ cache: 'no-store',+ headers: {+ 'Content-Type': 'application/json',+ Authorization: `Bearer ${effectiveKey}`,+ },+ body: '{}',+ })+ if (!resp.ok) {+ const text = await resp.text().catch(() => '')+ setPhase({+ kind: 'error',+ message: extractMessage(text) || String(resp.status),+ })+ return+ }+ const result = (await resp.json()) as OtpResult+ setPhase({ kind: 'ready', result })+ } catch (err: unknown) {+ const message = err instanceof Error ? err.message : String(err)+ setPhase({ kind: 'error', message })+ }+ }++ async function copyOtp(): Promise<void> {+ if (phase.kind !== 'ready') return+ try {+ await navigator.clipboard.writeText(phase.result.otp)+ setCopied(true)+ } catch {+ // Clipboard may be unavailable (insecure context); ignore.+ }+ }++ const hasAnyKey = Boolean(+ resolveEffectiveApiKey(identityValue, connection.apiKey),+ )+ const expired = phase.kind === 'ready' && remaining <= 0++ return (+ <Card className="gap-3">+ <CardHeader className="gap-1.5">+ <CardTitle className="text-base">+ {t('oauthOtp.title', { ns: 'connection' })}+ </CardTitle>+ <CardDescription>+ {t('oauthOtp.description', { ns: 'connection' })}+ </CardDescription>+ </CardHeader>+ <CardContent className="grid gap-4">+ <IdentityPicker+ value={identityValue}+ onChange={setIdentityValue}+ currentApiKey={connection.apiKey}+ currentIdentityLabel={currentIdentity}+ disabled={phase.kind === 'requesting'}+ />++ {phase.kind === 'ready' && !expired ? (+ <div className="grid gap-2 rounded-md border bg-muted/40 p-3">+ <span className="text-xs text-muted-foreground">+ {t('oauthOtp.codeLabel', { ns: 'connection' })}+ </span>+ <div className="flex items-center gap-3">+ <span className="font-mono text-2xl tracking-[0.4em]">+ {phase.result.otp}+ </span>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => void copyOtp()}+ >+ {copied+ ? t('oauthOtp.copied', { ns: 'connection' })+ : t('oauthOtp.copy', { ns: 'connection' })}+ </Button>+ </div>+ <span className="text-xs text-muted-foreground">+ {t('oauthOtp.expiresIn', {+ ns: 'connection',+ seconds: remaining,+ })}+ </span>+ </div>+ ) : null}++ {expired ? (+ <p className="text-xs text-destructive">+ {t('oauthOtp.expired', { ns: 'connection' })}+ </p>+ ) : null}++ {phase.kind === 'error' ? (+ <p className="text-xs text-destructive">+ {t('oauthOtp.generateError', {+ ns: 'connection',+ message: phase.message,+ })}+ </p>+ ) : null}++ <div className="flex justify-end">+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => void generateOtp()}+ disabled={phase.kind === 'requesting' || !hasAnyKey}+ >+ {phase.kind === 'ready' && !expired+ ? t('oauthOtp.regenerate', { ns: 'connection' })+ : t('oauthOtp.generate', { ns: 'connection' })}+ </Button>+ </div>+ </CardContent>+ </Card>+ )+}++function extractMessage(raw: string): string {+ try {+ const parsed = JSON.parse(raw) as { error?: { message?: string } }+ return parsed.error?.message || raw.slice(0, 200)+ } catch {+ return raw.slice(0, 200)+ }+}diff --git a/web-studio/src/components/ui/dialog.tsx b/web-studio/src/components/ui/dialog.tsxindex f01ff8be5..85847e2dd 100644--- a/web-studio/src/components/ui/dialog.tsx+++ b/web-studio/src/components/ui/dialog.tsx@@ -53,7 +53,7 @@ function DialogContent({<DialogPrimitive.Popupdata-slot="dialog-content"className={cn(- "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] max-h-[calc(100dvh-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 overflow-y-auto overscroll-contain rounded-xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className)}{...props}diff --git a/web-studio/src/i18n/locales/en.ts b/web-studio/src/i18n/locales/en.tsindex 4cb030982..7e45bd59a 100644--- a/web-studio/src/i18n/locales/en.ts+++ b/web-studio/src/i18n/locales/en.ts@@ -12,6 +12,9 @@ const en = {home: {title: 'Home',},+ oauthSetup: {+ title: 'OAuth setup',+ },operations: {title: 'Operations',},@@ -31,7 +34,7 @@ const en = {sidebar: {loadingSessions: 'Loading...',noSessions: 'No sessions',- workspaceGroupLabel: 'Workspace',+ workspaceGroupLabel: 'OpenViking Studio',},},common: {@@ -110,6 +113,14 @@ const en = {generateError: 'Could not generate OTP: {{message}}',},},+ oauthSetup: {+ page: {+ title: 'OAuth setup',+ intro:+ 'Use this page when authenticating an MCP client via OAuth — for example Claude.ai, Claude Desktop, ChatGPT, or Cursor. Generate a short-lived OTP here, then paste it into the MCP client to bind its connection to the selected identity.',+ docsLink: 'Read the OAuth integration guide',+ },+ },home: {agentAccess: {description:@@ -143,8 +154,8 @@ const en = {recentDay: 'Recent commit',},title: 'Context Commit Stats',- yearlyEmpty: 'No context commits in the last year',- yearlyTotal: '{{count}} context commits in the last year',+ yearlyEmpty: 'No context commits',+ yearlyTotal: '{{count}} context commits',tooltip: {total: 'Total commits',},@@ -203,8 +214,8 @@ const en = {todayRetrievals: {description:'Shows successful semantic retrieval calls for find() and search() today. Resets at midnight.',- find: 'find()',- search: 'search()',+ find: 'find',+ search: 'search',title: 'Retrievals Today',},todayTokens: {@@ -410,7 +421,7 @@ const en = {searchPalette: {ariaLabel: 'Search',openContainingDirectory: 'Open containing directory',- placeholder: 'Search files and directories...',+ placeholder: 'Search',scope: {global: 'Search scope: Global',current: 'Search scope: {{name}}',@@ -503,13 +514,13 @@ const en = {},retrieval: {title: 'Retrieval',- searchPlaceholder: 'Search context, e.g. how to authenticate users',+ searchPlaceholder: 'Search context',send: 'Search',controls: {function: 'Retrieval Function',modes: {- find: 'find()',- search: 'search()',+ find: 'find',+ search: 'search',},resultCount: 'Results',path: 'Path',diff --git a/web-studio/src/i18n/locales/zh-CN.ts b/web-studio/src/i18n/locales/zh-CN.tsindex 397a91235..c888eb3d3 100644--- a/web-studio/src/i18n/locales/zh-CN.ts+++ b/web-studio/src/i18n/locales/zh-CN.ts@@ -12,6 +12,9 @@ const zhCN = {home: {title: '首页',},+ oauthSetup: {+ title: 'OAuth 设置',+ },operations: {title: '运维',},@@ -31,7 +34,7 @@ const zhCN = {sidebar: {loadingSessions: '加载中...',noSessions: '暂无会话',- workspaceGroupLabel: 'OpenViking',+ workspaceGroupLabel: 'OpenViking Studio',},},common: {@@ -110,6 +113,14 @@ const zhCN = {generateError: '生成 OTP 失败:{{message}}',},},+ oauthSetup: {+ page: {+ title: 'OAuth 设置',+ intro:+ '当你需要让 MCP 客户端(例如 Claude.ai / Claude Desktop / ChatGPT / Cursor)通过 OAuth 完成鉴权时使用本页。在这里生成一个短期 OTP,粘到 MCP 客户端,它就会用所选身份完成 OAuth 授权。',+ docsLink: '阅读 OAuth 接入指南',+ },+ },home: {agentAccess: {description:@@ -143,8 +154,8 @@ const zhCN = {recentDay: '最近提交',},title: '上下文提交统计',- yearlyEmpty: '过去一年没有上下文提交',- yearlyTotal: '过去一年 {{count}} 次上下文提交',+ yearlyEmpty: '暂无上下文提交',+ yearlyTotal: '{{count}} 次上下文提交',tooltip: {total: '总提交',},@@ -203,8 +214,8 @@ const zhCN = {todayRetrievals: {description:'展示用户或 Agent 今日使用语义检索 find() 和 search() 的成功调用次数,每天零点刷新。',- find: 'find()',- search: 'search()',+ find: 'find',+ search: 'search',title: '今日检索次数',},todayTokens: {@@ -400,7 +411,7 @@ const zhCN = {searchPalette: {ariaLabel: '搜索',openContainingDirectory: '打开所在目录',- placeholder: '搜索文件和目录...',+ placeholder: '搜索',scope: {global: '搜索范围: 全局',current: '搜索范围: {{name}}',@@ -492,13 +503,13 @@ const zhCN = {},retrieval: {title: '检索',- searchPlaceholder: '输入检索内容,例如:how to authenticate users',+ searchPlaceholder: '输入检索内容',send: '检索',controls: {function: '检索函数',modes: {- find: 'find()',- search: 'search()',+ find: 'find',+ search: 'search',},resultCount: '返回数量',path: '路径',diff --git a/web-studio/src/main.tsx b/web-studio/src/main.tsxindex 0806474f1..5e7bdce92 100644--- a/web-studio/src/main.tsx+++ b/web-studio/src/main.tsx@@ -8,6 +8,17 @@ import { TooltipProvider } from './components/ui/tooltip'import { queryClient } from './lib/query-client'import { getRouterBasePath } from './lib/public-path'+// PWA: register the service worker at the SPA's base path so the scope+// matches the manifest's start_url / scope. Production builds only — the+// vite dev server's HMR doesn't play nicely with a SW intercepting requests.+if ('serviceWorker' in navigator && import.meta.env.PROD) {+ const basePath = getRouterBasePath() || '/'+ const swUrl = `${basePath}${basePath.endsWith('/') ? '' : '/'}service-worker.js`+ window.addEventListener('load', () => {+ void navigator.serviceWorker.register(swUrl, { scope: basePath })+ })+}+const router = createRouter({routeTree,basepath: getRouterBasePath(),diff --git a/web-studio/src/routeTree.gen.ts b/web-studio/src/routeTree.gen.tsindex 0719c5634..1548f93f4 100644--- a/web-studio/src/routeTree.gen.ts+++ b/web-studio/src/routeTree.gen.ts@@ -18,6 +18,7 @@ import { Route as IndexRouteImport } from './routes/index'import { Route as SessionsIndexRouteImport } from './routes/sessions/index'import { Route as ResourcesIndexRouteImport } from './routes/resources/index'import { Route as OauthVerifyRouteImport } from './routes/oauth/verify'+import { Route as OauthSetupRouteImport } from './routes/oauth/setup'import { Route as OauthConsentRouteImport } from './routes/oauth/consent'const SessionsRouteRoute = SessionsRouteRouteImport.update({@@ -65,6 +66,11 @@ const OauthVerifyRoute = OauthVerifyRouteImport.update({path: '/oauth/verify',getParentRoute: () => rootRouteImport,} as any)+const OauthSetupRoute = OauthSetupRouteImport.update({+ id: '/oauth/setup',+ path: '/oauth/setup',+ getParentRoute: () => rootRouteImport,+} as any)const OauthConsentRoute = OauthConsentRouteImport.update({id: '/oauth/consent',path: '/oauth/consent',@@ -79,6 +85,7 @@ export interface FileRoutesByFullPath {'/retrieval': typeof RetrievalRouteRoute'/sessions': typeof SessionsRouteRouteWithChildren'/oauth/consent': typeof OauthConsentRoute+ '/oauth/setup': typeof OauthSetupRoute'/oauth/verify': typeof OauthVerifyRoute'/resources/': typeof ResourcesIndexRoute'/sessions/': typeof SessionsIndexRoute@@ -89,6 +96,7 @@ export interface FileRoutesByTo {'/request-logs': typeof RequestLogsRouteRoute'/retrieval': typeof RetrievalRouteRoute'/oauth/consent': typeof OauthConsentRoute+ '/oauth/setup': typeof OauthSetupRoute'/oauth/verify': typeof OauthVerifyRoute'/resources': typeof ResourcesIndexRoute'/sessions': typeof SessionsIndexRoute@@ -102,6 +110,7 @@ export interface FileRoutesById {'/retrieval': typeof RetrievalRouteRoute'/sessions': typeof SessionsRouteRouteWithChildren'/oauth/consent': typeof OauthConsentRoute+ '/oauth/setup': typeof OauthSetupRoute'/oauth/verify': typeof OauthVerifyRoute'/resources/': typeof ResourcesIndexRoute'/sessions/': typeof SessionsIndexRoute@@ -116,6 +125,7 @@ export interface FileRouteTypes {| '/retrieval'| '/sessions'| '/oauth/consent'+ | '/oauth/setup'| '/oauth/verify'| '/resources/'| '/sessions/'@@ -126,6 +136,7 @@ export interface FileRouteTypes {| '/request-logs'| '/retrieval'| '/oauth/consent'+ | '/oauth/setup'| '/oauth/verify'| '/resources'| '/sessions'@@ -138,6 +149,7 @@ export interface FileRouteTypes {| '/retrieval'| '/sessions'| '/oauth/consent'+ | '/oauth/setup'| '/oauth/verify'| '/resources/'| '/sessions/'@@ -151,6 +163,7 @@ export interface RootRouteChildren {RetrievalRouteRoute: typeof RetrievalRouteRouteSessionsRouteRoute: typeof SessionsRouteRouteWithChildrenOauthConsentRoute: typeof OauthConsentRoute+ OauthSetupRoute: typeof OauthSetupRouteOauthVerifyRoute: typeof OauthVerifyRoute}@@ -219,6 +232,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof OauthVerifyRouteImportparentRoute: typeof rootRouteImport}+ '/oauth/setup': {+ id: '/oauth/setup'+ path: '/oauth/setup'+ fullPath: '/oauth/setup'+ preLoaderRoute: typeof OauthSetupRouteImport+ parentRoute: typeof rootRouteImport+ }'/oauth/consent': {id: '/oauth/consent'path: '/oauth/consent'@@ -261,6 +281,7 @@ const rootRouteChildren: RootRouteChildren = {RetrievalRouteRoute: RetrievalRouteRoute,SessionsRouteRoute: SessionsRouteRouteWithChildren,OauthConsentRoute: OauthConsentRoute,+ OauthSetupRoute: OauthSetupRoute,OauthVerifyRoute: OauthVerifyRoute,}export const routeTree = rootRouteImportdiff --git a/web-studio/src/routes/home/-components/context-commits-panel.tsx b/web-studio/src/routes/home/-components/context-commits-panel.tsxindex a1191c7f6..bc5a62e42 100644--- a/web-studio/src/routes/home/-components/context-commits-panel.tsx+++ b/web-studio/src/routes/home/-components/context-commits-panel.tsx@@ -1,4 +1,4 @@-import { useMemo, useState } from 'react'+import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'import { createPortal } from 'react-dom'import HeatMap from '@uiw/react-heat-map'@@ -59,10 +59,34 @@ export function ContextCommitsPanel({t: HomeT}) {const [tooltip, setTooltip] = useState<CommitTooltip | null>(null)+ const heatmapScrollRef = useRef<HTMLDivElement>(null)const items = useMemo(() => normalizeCommitHeatmapData(data?.items),[data?.items],)++ useEffect(() => {+ const el = heatmapScrollRef.current+ if (!el) return+ // Wait one frame for HeatMap to lay out, then align the viewport's+ // right edge with the rightmost rendered cell (not the SVG's trailing+ // padding). Finds the last <rect> on the heatmap to compute the+ // actual content edge.+ const raf = requestAnimationFrame(() => {+ const node = heatmapScrollRef.current+ if (!node) return+ const rects = node.querySelectorAll<SVGRectElement>('svg rect')+ let cellsRight = node.scrollWidth+ if (rects.length > 0) {+ const last = rects[rects.length - 1]+ const bbox = last.getBoundingClientRect()+ const containerLeft = node.getBoundingClientRect().left+ cellsRight = bbox.right - containerLeft + node.scrollLeft+ }+ node.scrollLeft = Math.max(0, cellsRight - node.clientWidth)+ })+ return () => cancelAnimationFrame(raf)+ }, [items])const panelColors = useMemo(() => buildHeatmapPanelColors(items), [items])const totalCommits = useMemo(() => items.reduce((total, item) => total + item.count, 0),@@ -108,7 +132,7 @@ export function ContextCommitsPanel({<><div className="grid gap-4 xl:grid-cols-[minmax(820px,auto)_minmax(180px,1fr)]"><div className="min-w-0">- <div className="overflow-x-auto">+ <div ref={heatmapScrollRef} className="overflow-x-auto"><HeatMapclassName="[--heatmap-empty:oklch(0.92_0_0)] text-muted-foreground dark:[--heatmap-empty:oklch(0.31_0_0)] [&_.w-heatmap-month]:fill-current [&_.w-heatmap-week]:fill-current"endDate={endDate}@@ -247,13 +271,36 @@ function CommitTooltipView({},]+ // Clamp the tooltip into the viewport so it never overflows on narrow+ // (mobile) screens. We render once with the centered transform, then+ // measure and re-apply a clamped horizontal offset.+ const tooltipRef = useRef<HTMLDivElement>(null)+ const [horizontalShift, setHorizontalShift] = useState(0)++ useLayoutEffect(() => {+ const el = tooltipRef.current+ if (!el) return+ const margin = 8+ const rect = el.getBoundingClientRect()+ const viewportWidth =+ window.innerWidth || document.documentElement.clientWidth+ let shift = 0+ if (rect.right > viewportWidth - margin) {+ shift = viewportWidth - margin - rect.right+ } else if (rect.left < margin) {+ shift = margin - rect.left+ }+ setHorizontalShift(shift)+ }, [item, x, y])+return (<div- className="pointer-events-none fixed z-50 w-64 rounded-xl border border-border/70 bg-popover/95 px-3.5 py-3 text-xs text-popover-foreground shadow-2xl shadow-black/10 ring-1 ring-foreground/5 backdrop-blur-md dark:shadow-black/35"+ ref={tooltipRef}+ className="pointer-events-none fixed z-50 w-64 max-w-[calc(100vw-1rem)] rounded-xl border border-border/70 bg-popover/95 px-3.5 py-3 text-xs text-popover-foreground shadow-2xl shadow-black/10 ring-1 ring-foreground/5 backdrop-blur-md dark:shadow-black/35"style={{left: x,top: y - 12,- transform: 'translate(-50%, -100%)',+ transform: `translate(calc(-50% + ${horizontalShift}px), -100%)`,}}><div className="flex items-start justify-between gap-4">@@ -294,7 +341,10 @@ function CommitTooltipView({))}</div>- <span className="absolute left-1/2 top-full size-2.5 -translate-x-1/2 -translate-y-1/2 rotate-45 border-b border-r border-border/70 bg-popover/95" />+ <span+ className="absolute top-full size-2.5 -translate-x-1/2 -translate-y-1/2 rotate-45 border-b border-r border-border/70 bg-popover/95"+ style={{ left: `calc(50% - ${horizontalShift}px)` }}+ /></div>)}diff --git a/web-studio/src/routes/home/-components/metric-panels.tsx b/web-studio/src/routes/home/-components/metric-panels.tsxindex 7f888072d..f72332107 100644--- a/web-studio/src/routes/home/-components/metric-panels.tsx+++ b/web-studio/src/routes/home/-components/metric-panels.tsx@@ -125,7 +125,7 @@ function MetricPanel({</div>{children ? (- <div className="mt-4 grid grid-cols-[repeat(auto-fit,minmax(92px,1fr))] gap-2">+ <div className="mt-4 grid grid-cols-[repeat(auto-fit,minmax(140px,1fr))] gap-2">{children}</div>) : null}diff --git a/web-studio/src/routes/home/-components/panel.tsx b/web-studio/src/routes/home/-components/panel.tsxindex 5a5862db5..12840c547 100644--- a/web-studio/src/routes/home/-components/panel.tsx+++ b/web-studio/src/routes/home/-components/panel.tsx@@ -47,9 +47,9 @@ export function SectionHeading({export function DetailRow({ label, value }: { label: string; value: string }) {return (- <div className="flex min-h-8 items-center justify-between gap-2 rounded-lg border border-[oklch(0.68_0.12_232/0.1)] bg-background/55 px-2.5 py-1.5 text-xs shadow-xs dark:border-white/10 dark:bg-white/[0.05]">- <span className="min-w-0 truncate text-muted-foreground">{label}</span>- <span className="font-medium tabular-nums text-[oklch(0.46_0.13_242)] dark:text-[oklch(0.74_0.12_232)]">+ <div className="flex min-h-8 flex-wrap items-center gap-x-2 rounded-lg border border-[oklch(0.68_0.12_232/0.1)] bg-background/55 px-2.5 py-1.5 text-xs shadow-xs dark:border-white/10 dark:bg-white/[0.05]">+ <span className="min-w-0 grow text-muted-foreground">{label}</span>+ <span className="ml-auto font-medium tabular-nums text-[oklch(0.46_0.13_242)] dark:text-[oklch(0.74_0.12_232)]">{value}</span></div>diff --git a/web-studio/src/routes/home/-lib/normalize.ts b/web-studio/src/routes/home/-lib/normalize.tsindex 942cd4772..8b73ee36a 100644--- a/web-studio/src/routes/home/-lib/normalize.ts+++ b/web-studio/src/routes/home/-lib/normalize.ts@@ -113,26 +113,48 @@ export function computeCommitHeatmapStats()}+// Re-bucket a UTC (date, hour) 4h commit row into the viewer's local+// (date, hour). Backend's projection writes buckets by container tz+// (effectively UTC in Railway), so a row at e.g. UTC 2026-05-21 hour=16+// belongs to a UTC+8 viewer's 2026-05-22 hour=0. We can do this entirely+// client-side because each bucket carries its full count — we only need+// to relabel which local day it sums under.+function shiftBucketToLocal(+ utcDate: string,+ utcHour: number,+): { date: string; hour: number } {+ const [y, m, d] = utcDate.split('-').map(Number)+ const utcMs = Date.UTC(y, m - 1, d, utcHour, 0, 0)+ const local = new Date(utcMs)+ const pad = (n: number) => String(n).padStart(2, '0')+ return {+ date: `${local.getFullYear()}-${pad(local.getMonth() + 1)}-${pad(local.getDate())}`,+ hour: local.getHours(),+ }+}+export function normalizeCommitHeatmapData(items: unknown): HeatMapDayValue[] {const rowsByDate = new Map<string, Required<ConsoleContextCommitItem>>()for (const item of normalizeCommitItems(items)) {if (!item.date) continue- const existing = rowsByDate.get(item.date) ?? {+ const local = shiftBucketToLocal(item.date, item.hour)++ const existing = rowsByDate.get(local.date) ?? {add_resource: 0,add_skill: 0,- date: item.date,+ date: local.date,hour: 0,session_add_message: 0,session_commit: 0,total: 0,}- rowsByDate.set(item.date, {+ rowsByDate.set(local.date, {add_resource: existing.add_resource + item.add_resource,add_skill: existing.add_skill + item.add_skill,- date: item.date,+ date: local.date,hour: 0,session_add_message:existing.session_add_message + item.session_add_message,diff --git a/web-studio/src/routes/oauth/setup.tsx b/web-studio/src/routes/oauth/setup.tsxnew file mode 100644index 000000000..a07d906e2--- /dev/null+++ b/web-studio/src/routes/oauth/setup.tsx@@ -0,0 +1,39 @@+import { useTranslation } from 'react-i18next'+import { createFileRoute } from '@tanstack/react-router'+import { ExternalLinkIcon } from 'lucide-react'++import { OAuthOtpForm } from '#/components/oauth-setup-dialog'++export const Route = createFileRoute('/oauth/setup')({+ component: OAuthSetupPage,+})++const OAUTH_DOCS_URL =+ 'https://github.com/volcengine/OpenViking/blob/main/docs/en/guides/11-oauth.md'++function OAuthSetupPage() {+ const { t } = useTranslation('oauthSetup')+ return (+ <div className="mx-auto w-full max-w-3xl space-y-6 p-4 sm:p-6">+ <header className="space-y-2">+ <h1 className="text-2xl font-semibold tracking-tight">+ {t('page.title')}+ </h1>+ <p className="max-w-2xl text-sm leading-6 text-muted-foreground">+ {t('page.intro')}+ </p>+ <a+ href={OAUTH_DOCS_URL}+ target="_blank"+ rel="noopener noreferrer"+ className="inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline"+ >+ {t('page.docsLink')}+ <ExternalLinkIcon className="size-3.5" />+ </a>+ </header>++ <OAuthOtpForm />+ </div>+ )+}diff --git a/web-studio/src/routes/request-logs/-components/pagination.tsx b/web-studio/src/routes/request-logs/-components/pagination.tsxindex 81ea63bdb..8ab7fe78c 100644--- a/web-studio/src/routes/request-logs/-components/pagination.tsx+++ b/web-studio/src/routes/request-logs/-components/pagination.tsx@@ -46,7 +46,7 @@ export function RequestLogPagination({return (<div className="flex flex-col gap-3 border-t px-4 py-3 sm:flex-row sm:items-center sm:justify-between">- <div className="flex flex-wrap items-center gap-3">+ <div className="flex flex-wrap items-center justify-center gap-3 sm:justify-start"><p className="text-sm text-muted-foreground">{t('pagination.summary', { page, pageCount, total })}</p>@@ -68,7 +68,7 @@ export function RequestLogPagination({</SelectContent></Select></div>- <Pagination className="mx-0 w-auto justify-start sm:justify-end">+ <Pagination className="mx-0 w-auto justify-center sm:justify-end"><PaginationContent><PaginationItem><PaginationPreviousdiff --git a/web-studio/src/routes/request-logs/-lib/format.ts b/web-studio/src/routes/request-logs/-lib/format.tsindex a6c24232c..97f1edf88 100644--- a/web-studio/src/routes/request-logs/-lib/format.ts+++ b/web-studio/src/routes/request-logs/-lib/format.ts@@ -10,14 +10,11 @@ export function formatTime(value?: string): string {if (!value) return '-'const date = new Date(value)if (Number.isNaN(date.getTime())) return value- return new Intl.DateTimeFormat(undefined, {- year: 'numeric',- month: '2-digit',- day: '2-digit',- hour: '2-digit',- minute: '2-digit',- second: '2-digit',- }).format(date)+ const pad = (n: number) => String(n).padStart(2, '0')+ const h24 = date.getHours()+ const period = h24 < 12 ? 'am' : 'pm'+ const h12 = h24 % 12 === 0 ? 12 : h24 % 12+ return `${date.getFullYear()}.${pad(date.getMonth() + 1)}.${pad(date.getDate())} ${pad(h12)}:${pad(date.getMinutes())}:${pad(date.getSeconds())}${period}`}export function formatDuration(value?: number): string {diff --git a/web-studio/src/routes/request-logs/route.tsx b/web-studio/src/routes/request-logs/route.tsxindex a58423352..367488afb 100644--- a/web-studio/src/routes/request-logs/route.tsx+++ b/web-studio/src/routes/request-logs/route.tsx@@ -69,7 +69,7 @@ function RequestLogsRoute() {<div className="grid gap-3 md:grid-cols-2"><MetricCardlabel={t('metrics.total')}- value={total}+ value={total >= 1000 ? '999+' : total}icon={<ActivityIcon className="size-4" />}/><MetricCarddiff --git a/web-studio/src/routes/resources/-components/file-list.tsx b/web-studio/src/routes/resources/-components/file-list.tsxindex c8a0177ad..cd0f9086e 100644--- a/web-studio/src/routes/resources/-components/file-list.tsx+++ b/web-studio/src/routes/resources/-components/file-list.tsx@@ -72,7 +72,7 @@ export function FileList({<buttonkey={entry.uri}className={cn(- 'flex w-full items-center gap-2 border-b px-4 py-2 text-left text-sm transition-colors hover:bg-muted/50',+ 'flex w-full items-center gap-2 border-b px-4 py-1.5 text-left text-xs transition-colors hover:bg-muted/50 md:py-2 md:text-sm',isSelected && 'bg-muted',)}type="button"diff --git a/web-studio/src/routes/resources/-components/file-preview.tsx b/web-studio/src/routes/resources/-components/file-preview.tsxindex 431596289..b52b6d8d0 100644--- a/web-studio/src/routes/resources/-components/file-preview.tsx+++ b/web-studio/src/routes/resources/-components/file-preview.tsx@@ -709,16 +709,16 @@ function JsonlMessageCard({ record }: { record: JsonlRecord }) {: `${message.text.slice(0, JSONL_MESSAGE_PREVIEW_LIMIT).trimEnd()}...`const alignClass =message.kind === 'user'- ? 'ml-auto bg-primary/10 border-primary/25'+ ? 'bg-primary/10 border-primary/25': message.kind === 'tool-result'- ? 'mx-auto border-dashed bg-muted/50'+ ? 'border-dashed bg-muted/50': message.kind === 'invalid' || message.kind === 'other'- ? 'w-full max-w-none bg-muted/40'- : 'mr-auto bg-background'+ ? 'bg-muted/40'+ : 'bg-background'return (<article- className={`w-fit max-w-[min(820px,88%)] rounded-lg border p-3 text-sm shadow-sm ${alignClass}`}+ className={`w-full min-w-0 max-w-full rounded-lg border p-3 text-sm shadow-sm ${alignClass}`}><div className="mb-2 flex min-w-0 items-center gap-2"><span className="text-xs font-semibold">{message.label}</span>@@ -839,7 +839,7 @@ function JsonlPreview({ content }: { content: string }) {</div>{dialogMode ? (- <div className="flex flex-col gap-3">+ <div className="flex min-w-0 flex-col gap-3">{filteredRecords.map((record) => (<JsonlMessageCard key={record.index} record={record} />))}diff --git a/web-studio/src/routes/resources/-components/file-tree.tsx b/web-studio/src/routes/resources/-components/file-tree.tsxindex 9dfbbee40..5838b74aa 100644--- a/web-studio/src/routes/resources/-components/file-tree.tsx+++ b/web-studio/src/routes/resources/-components/file-tree.tsx@@ -31,7 +31,7 @@ interface TreeNodeProps {const FolderIcon = ({ isOpen }: { isOpen: boolean }) => (<svg- className="size-5 shrink-0 text-foreground/70"+ className="size-4 shrink-0 text-foreground/70"viewBox="0 0 24 24"fill="currentColor"stroke="none"@@ -67,9 +67,24 @@ const LIST_OPTS = {nodeLimit: 200,}-function sortEntries(entries: VikingFsEntry[]): VikingFsEntry[] {+function isSessionSubtree(parentUri: string): boolean {+ // Children of viking://session and anything nested inside it sort by+ // modTime DESC (most recent first) instead of name.+ return parentUri.startsWith('viking://session/')+}++function sortEntries(+ entries: VikingFsEntry[],+ parentUri: string,+): VikingFsEntry[] {+ const byModTime = isSessionSubtree(parentUri)return [...entries].sort((a, b) => {if (a.isDir !== b.isDir) return a.isDir ? -1 : 1+ if (byModTime) {+ const at = a.modTimestamp ?? 0+ const bt = b.modTimestamp ?? 0+ if (at !== bt) return bt - at+ }return a.name.localeCompare(b.name)})}@@ -87,7 +102,8 @@ function TreeNode({}: TreeNodeProps) {const { t } = useTranslation('resources')const isOpen = expandedKeys.has(entry.uri)- const isDirSelected = entry.isDir && currentUri === entry.uri+ const isDirSelected =+ entry.isDir && currentUri === entry.uri && !selectedFileUriconst isFileSelected = !entry.isDir && selectedFileUri === entry.uriconst entryRef = useRef(entry)@@ -95,7 +111,7 @@ function TreeNode({const { data } = useVikingFsList(entry.uri, LIST_OPTS, entry.isDir)const children: VikingFsEntry[] = entry.isDir- ? sortEntries(data?.entries ?? [])+ ? sortEntries(data?.entries ?? [], entry.uri): []const handleToggle = useCallback(() => {@@ -107,10 +123,11 @@ function TreeNode({const handleSelect = useCallback(() => {if (entryRef.current.isDir) {onSelectDirectory(entryRef.current)+ handleToggle()} else {onSelectFile?.(entryRef.current)}- }, [onSelectDirectory, onSelectFile])+ }, [onSelectDirectory, onSelectFile, handleToggle])const handleMouseEnter = useCallback(() => {if (entry.isDir && !isOpen && prefetch) prefetch(entry.uri)@@ -127,14 +144,14 @@ function TreeNode({)}<divclassName={cn(- 'flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 transition-colors',+ 'flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition-colors md:py-1.5',isFileSelected ? 'bg-muted text-foreground' : 'hover:bg-muted/50',)}onClick={handleSelect}><span aria-hidden className="inline-flex size-4 shrink-0" /><File className="size-4 shrink-0 text-muted-foreground" />- <span className="min-w-0 truncate text-sm">{entry.name}</span>+ <span className="min-w-0 truncate text-xs md:text-sm">{entry.name}</span></div></div>)@@ -148,7 +165,7 @@ function TreeNode({)}<divclassName={cn(- 'flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 transition-colors',+ 'flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition-colors md:py-1.5',isDirSelected ? 'bg-muted text-foreground' : 'hover:bg-muted/50',)}onClick={handleSelect}@@ -172,7 +189,7 @@ function TreeNode({<span aria-hidden className="inline-flex size-4 shrink-0" />)}<FolderIcon isOpen={isOpen} />- <span className="min-w-0 truncate text-sm">{entry.name}</span>+ <span className="min-w-0 truncate text-xs md:text-sm">{entry.name}</span></div></div><divdiff --git a/web-studio/src/routes/resources/-components/find-palette.tsx b/web-studio/src/routes/resources/-components/find-palette.tsxindex d689cf5c2..9123c8f69 100644--- a/web-studio/src/routes/resources/-components/find-palette.tsx+++ b/web-studio/src/routes/resources/-components/find-palette.tsx@@ -242,7 +242,7 @@ export function FindPalette({return (<div- className="fixed inset-0 z-50 flex items-start justify-center px-4 pt-[12vh] sm:px-6"+ className="fixed inset-0 z-50 flex items-center justify-center px-4 sm:items-start sm:px-6 sm:pt-[12vh]"role="dialog"aria-modal="true"aria-label={t('searchPalette.ariaLabel')}@@ -255,7 +255,7 @@ export function FindPalette({<divclassName={cn(- 'animate-palette-in relative flex h-[46rem] max-h-[84vh] max-w-full flex-col overflow-hidden rounded-xl border bg-background shadow-2xl shadow-black/20 transition-[width] duration-300',+ 'animate-palette-in relative flex h-[46rem] max-h-[calc(100svh-2rem)] max-w-full flex-col overflow-hidden rounded-xl border bg-background shadow-2xl shadow-black/20 transition-[width] duration-300 sm:max-h-[84vh]',paletteWidth,)}onKeyDown={handleKeyDown}@@ -275,7 +275,7 @@ export function FindPalette({onCompositionEnd={() => {composingRef.current = false}}- className="h-12 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/70"+ className="h-12 flex-1 bg-transparent text-base outline-none placeholder:text-muted-foreground/70 md:text-sm"/>{query && (<buttondiff --git a/web-studio/src/routes/resources/-components/viking-file-manager.tsx b/web-studio/src/routes/resources/-components/viking-file-manager.tsxindex aa62d4b17..9f6efca76 100644--- a/web-studio/src/routes/resources/-components/viking-file-manager.tsx+++ b/web-studio/src/routes/resources/-components/viking-file-manager.tsx@@ -402,7 +402,7 @@ export function VikingFileManager({const toolbar = (<div className="flex h-10 items-center gap-1 border-b px-3">- <nav className="flex items-center gap-0.5 overflow-hidden text-sm text-muted-foreground">+ <nav className="flex flex-1 items-center gap-0.5 overflow-x-auto whitespace-nowrap text-xs text-muted-foreground md:text-sm">{breadcrumbs.map((crumb, i) => (<span key={crumb.uri} className="flex shrink-0 items-center gap-0.5">{i > 0 && <ChevronRight className="size-3" />}@@ -420,17 +420,16 @@ export function VikingFileManager({)return (- <div className="web-studio-resource-fs -mx-4 -mt-6 -mb-4 flex h-[calc(100vh-3.5rem)] flex-col md:-mx-6">+ <div className="web-studio-resource-fs -mx-4 -my-6 flex h-[calc(100svh-6rem)] flex-col md:-mx-6"><div ref={layoutRef} className="flex min-h-0 flex-1 flex-col md:flex-row"><sectionclassName="flex h-[var(--resource-tree-height)] min-h-[190px] min-w-0 flex-col bg-muted/30 md:h-auto md:min-h-0 md:w-[var(--resource-tree-width)] md:min-w-[var(--resource-tree-width)]"style={treePaneStyle}>- <div className="flex h-10 items-center gap-1 overflow-hidden border-b px-2">+ <div className="flex h-10 items-center gap-1 overflow-hidden border-b pl-4 pr-2 md:px-2"><Buttonvariant="ghost"- size="icon"- className="size-7"+ size="icon-sm"title={t('toolbar.refresh')}onClick={() => void handleRefresh()}>@@ -470,7 +469,9 @@ export function VikingFileManager({<div className="min-h-0 flex-1"><FileTreecurrentUri={currentUri}- selectedFileUri={selectedFile?.uri ?? null}+ selectedFileUri={+ selectedFile && !selectedFile.isDir ? selectedFile.uri : null+ }expandedKeys={expandedKeys}onExpandedKeysChange={setExpandedKeys}onSelectDirectory={handleOpenDirectory}diff --git a/web-studio/src/routes/resources/-lib/normalize.ts b/web-studio/src/routes/resources/-lib/normalize.tsindex 8fa0ec73b..92d1c0ddb 100644--- a/web-studio/src/routes/resources/-lib/normalize.ts+++ b/web-studio/src/routes/resources/-lib/normalize.ts@@ -169,6 +169,18 @@ export function parseSizeToBytes(value: unknown): number | null {return Math.round(amount * multiplier)}+const TIME_ONLY_RE = /^\d{1,2}:\d{2}(:\d{2})?(\s*[apAP][mM])?$/+const DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/++function todayUtcDateKey(): string {+ // Backend simplifies modTime against UTC's "today", not the user's+ // local today. We need to match that reference so time-only values+ // bind to the right UTC moment regardless of the viewer's tz.+ const d = new Date()+ const pad = (n: number) => String(n).padStart(2, '0')+ return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}`+}+export function parseModTimeToTs(value: unknown): number | null {if (typeof value === 'number') {return Number.isFinite(value) ? value : null@@ -179,6 +191,29 @@ export function parseModTimeToTs(value: unknown): number | null {return null}+ // Time-only ("HH:MM:SS", "12:34am" etc) — backend's format_simplified+ // returns this only when the entry's UTC date matches UTC's today.+ // Combine with UTC today + explicit Z so the moment is anchored in UTC,+ // and downstream Date methods naturally render it in the viewer's local+ // tz (no double-shift, no day mis-attribution).+ if (TIME_ONLY_RE.test(text)) {+ const normalized = text.replace(/\s+/g, '').toUpperCase()+ const ts = Date.parse(`${todayUtcDateKey()}T${normalized}Z`)+ if (Number.isFinite(ts)) {+ return ts+ }+ }++ // Date-only ("YYYY-MM-DD") — backend's format_simplified returns this+ // when the entry is older than UTC's today. Treat as local midnight on+ // that date for sort purposes (we have no sub-day precision anyway).+ if (DATE_ONLY_RE.test(text)) {+ const [year, month, day] = text.split('-').map(Number)+ if (year && month && day) {+ return new Date(year, month - 1, day).getTime()+ }+ }+const direct = Date.parse(text)if (Number.isFinite(direct)) {return direct@@ -195,6 +230,12 @@ export function parseModTimeToTs(value: unknown): number | null {export function formatModTime(value: unknown): string {const text = String(value ?? '').trim()if (!text) return ''+ // Date-only inputs (older entries) — the backend has already dropped+ // sub-day precision, so we render the date as-is without faking an+ // 00:00 time component.+ if (DATE_ONLY_RE.test(text)) {+ return text+ }const ts = parseModTimeToTs(text)if (ts === null) return textconst d = new Date(ts)diff --git a/web-studio/src/routes/retrieval/-components/search-bar.tsx b/web-studio/src/routes/retrieval/-components/search-bar.tsxindex 080e5f366..a5367d631 100644--- a/web-studio/src/routes/retrieval/-components/search-bar.tsx+++ b/web-studio/src/routes/retrieval/-components/search-bar.tsx@@ -32,7 +32,7 @@ export function RetrievalSearchBar({onChange={(event) => onChange(event.target.value)}onKeyDown={handleKeyDown}placeholder={placeholder}- className="flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/60"+ className="flex-1 bg-transparent text-base outline-none placeholder:text-muted-foreground/60 md:text-sm"/><Buttonvariant="ghost"diff --git a/web-studio/src/styles.css b/web-studio/src/styles.cssindex 5bc077c3e..90f333882 100644--- a/web-studio/src/styles.css+++ b/web-studio/src/styles.css@@ -171,19 +171,31 @@}}+/* FS page on phone view: respect declared Tailwind sizes (no upscaling)+ so text matches the density of Atlas / native file managers. Also+ hide internal scrollbars — iOS/Atlas pattern is overlay scroll only+ on active gesture, not a persistent track. */@media (max-width: 767px) {- .web-studio-resource-fs :where(.text-xs, .text-sm, .text-\[10px\], .text-\[11px\]) {- font-size: 1rem;- line-height: 1.5rem;+ .web-studio-resource-fs ::-webkit-scrollbar {+ width: 0;+ height: 0;+ background: transparent;}-- .web-studio-resource-fs :where(.prose-sm) {- font-size: 1rem;- line-height: 1.75;+ .web-studio-resource-fs * {+ scrollbar-width: none;}+}- .web-studio-resource-fs :where(pre, code, table, th, td) {- font-size: 1rem;+/* PWA standalone mode: iOS reports a slightly different viewport from+ Safari (no URL chrome, but full-svh includes home-indicator safe area).+ The 1–2px mismatch makes the outer SidebarInset ScrollArea show a tall+ page scrollbar on the FS route. Hide it — native iOS apps don't show a+ page-level scrollbar, and the inner panes already overlay-scroll on+ gesture. */+@media (display-mode: standalone) {+ body:has(.web-studio-resource-fs)+ [data-slot='scroll-area-scrollbar'][data-orientation='vertical'] {+ display: none;}}