Frontend App Shell
Overview
This frontend shell is a Vite-powered React 18 application that is also configured for Tauri desktop development. The browser entrypoint is index.html: it defines a single <div id="root"></div> mount point and loads /src/main.tsx as the module script. src/main.tsx imports the global stylesheet src/base.css, creates the React root with ReactDOM.createRoot(document.getElementById('root') as HTMLElement), and renders <App /> inside React.StrictMode.
src/App.tsx is the root composition point. Instead of using URL routing, it asks Tauri for the current webview via getCurrentWebview() from @tauri-apps/api/webview and dispatches by webview.label. The hard-coded label map renders ~view/Titlebar for titlebar, ~view/Ask for ask, and ~view/Settings for settings; any other label renders null. This makes the frontend shell dependent on the Tauri-created webview labels rather than on React Router paths, even though react-router-dom is listed in package.json.
Global styling starts in src/base.css, which installs Tailwind layers with @tailwind base, @tailwind components, and @tailwind utilities, then makes html, body, and #root full-height with zero margin and overflow: hidden. Tailwind scans index.html and all src/**/*.{js,jsx,ts,tsx} files per tailwind.config.js; it defines a custom tablet screen at 480px, extends colors with app-gray-1, app-gray-2, app-gray-3, and app-active, and loads typography/autoprefixer-related plugins. PostCSS is configured in postcss.config.js to run tailwindcss and autoprefixer.
The build and dependency surface is rooted in package.json and locked by pnpm-lock.yaml. Scripts are dev (vite), build (tsc && vite build), preview (vite preview), and tauri (tauri). Runtime dependencies include React, Tauri API/plugins, clsx, lodash, hotkey support, and React Router; build dependencies include Vite 5, TypeScript 5, @vitejs/plugin-react, Tailwind, PostCSS, Autoprefixer, and vite-tsconfig-paths.
vite.config.ts enables vite-tsconfig-paths() and React, then applies Tauri-oriented dev-server settings: clearScreen: false so Rust errors are not hidden, fixed port 1420 with strictPort: true, and a watcher ignore for **/src-tauri/**. TypeScript settings are split between tsconfig.json for the app and tsconfig.node.json for the Vite config. The app config targets ES2020/DOM, uses bundler module resolution, enforces strict/no-unused checks, sets jsx to react-jsx, and defines ~/*, ~components/*, ~view/*, ~hooks/*, ~utils/*, ~icons/*, and ~layout/* path aliases. src/vite-env.d.ts supplies Vite client ambient types. src/types.d.ts declares the global I namespace used by the frontend, including I.AppConf and shared SVG props. Static public assets currently include public/ChatGPT.png, which Vite serves from the public root when referenced by URL.
Coupling
- If Tauri window/webview labels change, update src/App.tsx at the same time: the root app renders solely from
getCurrentWebview().label, so a label mismatch causes that webview to mount a blanknullapp. - If a TypeScript path alias changes in tsconfig.json, verify both vite.config.ts and imports like
~view/Titlebarin src/App.tsx: Vite only resolves those aliases becausevite-tsconfig-paths()reads the tsconfig path map. - If the Tauri dev port changes outside the frontend, update vite.config.ts: the dev server is pinned to port
1420withstrictPort: true, so a port drift will fail startup rather than falling back to another port. - If global layout changes in src/base.css, verify root-level views that expect a viewport-sized app:
html,body, and#rootare forced toheight: 100%andoverflow: hidden, so scroll behavior has to be implemented inside child views rather than on the document.
Risks
- tailwind.config.js defines
app-gray-3as'#2f2f2f;'with a trailing semicolon inside the color value. If that token is used in generated utilities, Tailwind may emit an invalid color declaration or inconsistent CSS for that class. - src/App.tsx silently returns
nullfor unknown webview labels. If a new Tauri webview is added without extendingviewMap, the frontend build still succeeds but the new window renders blank.