Frontend application
The Unstract frontend is a browser application that lets users build and run document workflows and manage the platform around them. It presents organization-scoped workspaces, sends user actions to the backend API, and shows workflow progress and results through normal requests and live updates.
Application role
The browser application is the user-facing control plane for Unstract. It turns backend workflow and platform services into guided screens while keeping the current session, organization, product choice, and page state available to those screens.
Browser shell
The browser shell starts from the HTML entry point and mounts the React application at the page root. It supplies routing, page titles, theme selection, analytics, confirmation dialogs, and shared notification surfaces before it loads the page selected by the URL (frontend/index.html• L1-14, frontend/…/index.jsx• L14-83, frontend/…/App.jsx• L40-143).
Global alerts use one v0 toast surface. The shell also keeps confirmation dialogs alive while the page that opened them changes. Alerts can show safe Markdown and request or execution identifiers, while the same notice is added to the in-app log (frontend/…/App.jsx• L56-107, frontend/…/App.jsx• L122-140). A sign-out in another tab clears this tab's session state so the previous user's pages do not remain open (frontend/…/App.jsx• L45-54).
This arrangement keeps page features focused on user work while the shell handles concerns that must work across the whole application. A loading view and an error boundary protect navigation when a page or its code cannot load. The authenticated page layout places the top bar above the workspace and keeps navigation, optional marketplace status, page content, and logs in the same frame (frontend/…/Router.jsx• L184-205, frontend/…/PageLayout.jsx• L34-65, frontend/…/PageLayout.css• L1-29).
References: frontend/index.html• L1-14 frontend/…/index.jsx• L14-83 frontend/…/App.jsx• L40-143 frontend/…/Router.jsx• L184-205 frontend/…/PageLayout.jsx• L34-65
Top navigation
The top navigation gives the current workspace a stable identity and a small set of account controls. It shows the active product mark or configured logo, identifies review pages, warns users when setup is incomplete, and provides profile, organization, product, and session actions (frontend/…/TopNavBar.jsx• L36-142, frontend/…/TopNavBar.jsx• L143-230, frontend/…/TopNavBar.jsx• L285-387, frontend/…/TopNavBar.jsx• L399-485). Product and subscription features are optional, so the same shell can run in the public open-source build and in builds with cloud overlays.
The organization control shows the active organization's display name when the session identifies a normal organization. Its menu keeps the organization list open for pointer and keyboard users, confirms a change, and reports when the selected organization is already active. For a normal session, the browser sends the selected organization to the backend with the session CSRF token, then reloads the application after the backend accepts the change. When the session says that the identity provider owns organization selection, the browser silently starts login again with the chosen organization instead (frontend/…/TopNavBar.jsx• L191-203, frontend/…/TopNavBar.jsx• L236-287, frontend/…/TopNavBar.jsx• L317-343, frontend/…/orgSwitchLogin.js• L3-25).
The avatar menu uses a single 40-pixel interaction target for the avatar and its chevron. Its menu rows share the same horizontal icon-and-label layout, while the avatar uses either the session picture or user initials. The navigation styles use theme values for the avatar, text, hover surface, and product bar so the control remains readable in both themes (frontend/…/TopNavBar.css• L3-56, frontend/…/TopNavBar.css• L63-86, frontend/…/TopNavBar.css• L123-153, frontend/…/TopNavBar.jsx• L453-494). The focused tests cover pointer and keyboard organization switching, the normal and identity-provider-owned switch paths, current-organization display, open-source behavior, and the already-selected organization message (frontend/…/TopNavBar.test.jsx• L92-179, frontend/…/TopNavBar.test.jsx• L182-256).
References: frontend/…/TopNavBar.jsx• L36-142 frontend/…/TopNavBar.jsx• L143-287 frontend/…/TopNavBar.jsx• L317-343 frontend/…/TopNavBar.jsx• L399-499 frontend/…/TopNavBar.css• L3-56 frontend/…/TopNavBar.css• L63-86 frontend/…/TopNavBar.css• L123-153 frontend/…/TopNavBar.test.jsx• L92-179 frontend/…/TopNavBar.test.jsx• L182-256 frontend/…/orgSwitchLogin.js• L3-25
Frontend source architecture
The application is a React browser client built and served through Vite. Route pages and heavy views load when the user reaches them, which keeps the public entry page small and avoids loading tools such as the PDF viewer, charts, or code editor before login (frontend/package.json• L70-91, frontend/…/Router.jsx• L24-45, frontend/…/useMainAppRoutes.jsx• L13-29).
The shared visual system uses semantic theme values and reusable UI primitives. Shared table, overlay, form, input, calendar, and layout surfaces keep feature pages consistent as the visual system evolves (frontend/…/App.jsx• L147-183, frontend/…/index.css• L1-93, frontend/components.json• L1-20, frontend/…/DataTable.jsx• L313-433). The v0 styles remain separate from the v1 style tree so both application generations can run in the same browser document without taking control of each other's classes (frontend/…/index.css• L1-15, frontend/…/index.css• L1-29).
The v1 surface adds shared menus, selection controls, forms, code, structured data, charts, and feedback. These shared surfaces give new pages one set of interaction and accessibility rules instead of making each feature create its own renderer (frontend/…/README.md• L1-18, frontend/…/README.md• L1-21, frontend/…/README.md• L1-25, frontend/…/README.md• L78-175). Its boundary checks keep v1 TypeScript-only, prevent direct v0 imports, and require backend access through typed service modules rather than raw browser requests (frontend/…/check-v1.mjs• L1-18, frontend/…/check-v1.mjs• L554-572, frontend/…/check-v1.mjs• L974-1076).
The browser has separate quality gates for the v0 client and the v1 surface. The v0 test setup handles JSX in JavaScript and absent optional cloud plugins, while the v1 suites use their own core and cloud-plugin scopes and keep v1 out of the v0 run. v1 checks also enforce its file, import, style, notification, backend-access, extension-point, and shared code-surface contracts (frontend/vitest.config.mjs• L7-127, frontend/vitest.v1.config.mts#L6-L107, frontend/vitest.v1-plugins.config.mts#L1-L4, frontend/…/check-v1.mjs• L1-18, frontend/…/check-v1.mjs• L54-116, frontend/package.json• L75-91).
The child page Frontend UI architecture explains the source layout, feature boundaries, route organization, and shared UI patterns. This page stays at the system level and describes how those parts work together.
References: frontend/package.json• L70-91 frontend/…/Router.jsx• L24-45 frontend/…/useMainAppRoutes.jsx• L13-29 frontend/…/App.jsx• L147-183 frontend/…/index.css• L1-93 frontend/…/index.css• L1-29 frontend/…/README.md• L1-18 frontend/…/README.md• L1-21 frontend/…/README.md• L1-25 frontend/…/README.md• L78-175 frontend/…/check-v1.mjs• L1-18 frontend/…/check-v1.mjs• L554-572 frontend/…/check-v1.mjs• L974-1076 frontend/vitest.config.mjs• L7-127 frontend/vitest.v1.config.mts• L6-107
Versioned frontend foundation
The frontend supports a v1 application foundation beside the existing v0 application. The v0 router wraps its routes in a version switch, and a route registry decides whether a URL stays in v0, redirects to its v1 route, or renders the v1 tree (frontend/…/Router.jsx• L184-205, frontend/…/VersionSwitch.tsx• L73-93, frontend/…/resolve.ts• L88-120).
The v1 public entry is intentionally small because v0 loads it eagerly. It exposes the version switch and a few browser helpers, while the v1 application loads only when a registered v1 page renders. That application has its own query cache, theme provider, plugin provider, route gate, and notification surface rather than running inside a v0 layout or guard (frontend/…/index.ts• L1-24, frontend/…/V1App.tsx• L25-57, frontend/…/VersionSwitch.tsx• L20-22).
The route registry separates page declaration from go-live selection. A page declares its v1 routes, the v0 routes it replaces, access rules, and mappings in both directions. The current source keeps production page declarations and registrations empty, while development builds can register demo pages and preview declared pages before they go live (frontend/…/entries.ts• L9-50, frontend/…/live.ts• L17-77).
Registry validation protects the version boundary before a page can change routing. It checks route shape, page identity, distribution, access, route coverage, parameter compatibility, and overlap between pages. This prevents redirects from landing on the wrong version or creating loops (frontend/…/validate.ts• L43-71, frontend/…/validate.ts• L81-167).
The switch supports a per-user browser preference for pages that allow an old-version toggle, currently Human Review and its development stand-in. It maps between the two versions without a reload. The preference is tied to the user once a v0 or v1 session identifies that user, but a saved last-user marker can provide the choice before the next session finishes loading (frontend/…/VersionSwitch.tsx• L48-64, frontend/…/VersionSwitch.tsx• L73-93, frontend/…/README.md• L184-216).
The v1 application creates one provider tree for a page. It loads the session through RouteGate, applies the current organization before organization-scoped queries run, shares the query client across v1 pages, and mounts one notification surface. A page or lazy chunk failure stays within its v1 boundary; a stale chunk gets one reload attempt and then shows a reload action (frontend/…/V1App.tsx• L27-57, frontend/…/RouteGate.tsx• L49-73, frontend/…/V1ErrorBoundary.tsx• L14-55).
The v1 session foundation shares v0's browser cookies but has its own load and guard path. It checks the session, lists organizations, restores or selects the current organization, reads the organization profile, and then allows the page, sends the user to sign-in, requests organization selection, or shows an access state. Organization-scoped routes also require the URL organization to match the current session (frontend/…/session.ts• L35-55, frontend/…/session.ts• L179-200, frontend/…/RouteGate.tsx• L217-269, frontend/…/guard.ts• L17-54).
The v1 foundation uses plugin slots for distribution-specific shell and access behavior. OSS pages use fallbacks, while cloud and on-premise builds can fill entitlement, platform-admin, account, dashboard, and product slots. Plugin routes are available from the registry for future v1 routing, but the current v1 shell does not add them to its page router (frontend/…/types.ts• L9-41, frontend/…/index.ts• L44-87).
The v1 data layer gives pages one way to read and change server state. Typed service functions describe backend resources, TanStack Query owns shared request state, and QueryView presents loading, retry, and first-read error states. The shared query client retries transient reads, does not retry writes, and reports failures with request IDs through the v1 notification path (frontend/…/README.md• L1-15, frontend/…/query.ts• L12-68, frontend/…/QueryView.tsx• L14-46).
The document viewer supports both rendered PDF pages and extracted text. PDF pages keep their layout available for navigation and highlight focus while rendering only the nearby page window. Text views preserve line numbers and whole-line highlights, and they report empty extracted text as a distinct state (frontend/…/PdfPageList.tsx• L152-167, frontend/…/TextView.tsx• L96-100, frontend/…/TextView.tsx• L164-183).
The v1 foundation also includes common code, structured-data, chart, form, menu, toggle, button, and feedback surfaces. These surfaces keep workflow output, API descriptions, metrics, configuration views, and user controls consistent across pages (frontend/…/README.md• L78-175, frontend/…/README.md• L1-18, frontend/…/README.md• L1-21, frontend/…/README.md• L1-25).
The v1 shell foundation defines account and organization services around the current session. Organization changes use a backend service and a full navigation so data from the old organization does not remain in browser state. Sign-out clears browser data and leaves through a validated backend-provided destination (frontend/…/OrganizationSwitcher.tsx• L130-181, frontend/…/organizations.ts• L52-99, frontend/…/session.ts• L203-254). The child page Frontend v1 foundation explains this boundary, the shared theme, document, code, chart, form, menu, toggle, query, and extension capabilities in more detail.
References: frontend/…/Router.jsx• L184-205 frontend/…/index.ts• L1-24 frontend/…/V1App.tsx• L25-57 frontend/…/VersionSwitch.tsx• L20-93 frontend/…/entries.ts• L9-50 frontend/…/live.ts• L17-115 frontend/…/resolve.ts• L88-153 frontend/…/validate.ts• L43-167 frontend/…/RouteGate.tsx• L49-269 frontend/…/session.ts• L179-254 frontend/…/README.md• L1-15 frontend/…/index.ts• L44-87
Runtime configuration
The frontend supports one built application that can receive different values when it starts. This lets container deployments change branding and analytics choices without building a new image for each deployment.
Configuration sources
Runtime values from window.RUNTIME_CONFIG take priority over Vite environment values. The frontend then falls back to build-time values and safe defaults (frontend/…/config.js• L1-26, frontend/…/index.jsx• L26-33).
The container start script writes the runtime object into the served web root. It accepts current VITE_ names and older REACT_APP_ names for selected branding and analytics values (frontend/generate-runtime-config.sh• L3-27). The main browser-facing values control the favicon, logo, version, and the optional URL of an Unstract Flow app. Analytics events use one PostHog project and attach a deployment label. Known Unstract SaaS hosts are marked as production deployments. Other hosts use the self-hosted label (frontend/…/PostHogDeployment.js• L1-19, frontend/…/PostHogDeployment.test.js• L8-29).
The v1 route set and plugin set also depend on build distribution and development flags. VITE_DISTRIBUTION selects the OSS, cloud, or on-premise page and plugin set, while VITE_V1_DEV_ROUTES enables development-only demo and preview routes. Invalid distribution values fall back safely when the eagerly loaded registries are evaluated, while the build configuration remains the release-time validation point (frontend/…/live.ts• L17-37, frontend/…/live.ts• L88-110, frontend/…/index.ts• L24-35).
References: frontend/…/config.js• L1-26 frontend/…/index.jsx• L26-33 frontend/generate-runtime-config.sh• L3-27 frontend/…/PostHogDeployment.js• L1-19 frontend/…/live.ts• L17-37 frontend/…/index.ts• L24-35
Development connection
During local development, Vite proxies /api requests to the backend URL. The proxy also forwards WebSocket upgrades so live workflow messages work in the browser. The development server can listen on a configured port and allow a configured host behind an ingress (frontend/vite.config.js• L190-242).
References: frontend/…/config.js• L1-26 frontend/index.jsx• L26-53 frontend/vite.config.js• L190-242
Navigation and access
The URL identifies the public page or the organization workspace. Routing separates public entry points from authenticated workspace pages, then applies role and organization checks before it renders protected content.
Session lifecycle
The application checks the current session when a user enters the app. It resolves product and organization choice before it loads organization data, then stores organization identity, role, usable adapters, feature flags, theme, and the CSRF token in shared browser state (frontend/…/useSessionValid.js• L35-175, frontend/…/GetSessionData.js• L1-33, frontend/…/session-store.js• L3-22).
An expired or missing session clears user-local data and the dashboard metrics cache in the current tab. This prevents a later visitor from seeing business metrics left by the prior session while preserving only the storage needed to prevent a silent sign-in loop (frontend/…/useUserSession.js• L15-41, frontend/…/metricsCache.js• L1-10, frontend/…/metricsCache.js• L129-144).
The login and signup entry points preserve a selected product only when that product is declared by the active product set. Plugin builds supply that set, while an OSS-only build keeps its small default set. An unknown value in browser storage is omitted so the backend does not receive an unsupported product (frontend/…/Login.jsx• L17-60, frontend/…/Login.test.jsx• L87-152).
Unauthenticated users go to the landing page. Users with more than one organization select one, and users who must choose a product go to product selection before the workspace loads. Other users go to onboarding, the workspace home, or a review area based on setup and role (frontend/…/useSessionValid.js• L51-121, frontend/…/RequireAuth.jsx• L32-97). When a selected product belongs to a separate application, the guest guard leaves this application with a real browser navigation. It accepts only an absolute HTTP(S) address or a root-relative path, so a missing or unsafe destination cannot become a local /undefined route (frontend/…/RequireGuest.jsx• L43-80, frontend/…/RequireGuest.jsx• L104-132, frontend/…/ExternalRedirect.jsx• L4-56).
The v1 session path follows the same product boundary without sharing v0's route wrappers. A v1 page loads the session once, restores the current organization through the backend, and identifies the user for analytics before its organization-scoped content runs. A guest page receives no session object, while signed-in pages receive a normalized user and organization record (frontend/…/RouteGate.tsx• L49-73, frontend/…/session.ts• L179-200, frontend/…/session.tsx• L30-56, frontend/…/analytics.ts• L34-63).
References: frontend/…/useSessionValid.js• L35-175 frontend/…/useUserSession.js• L15-41 frontend/…/metricsCache.js• L1-10 frontend/…/metricsCache.js• L129-144 frontend/…/Login.jsx• L17-60 frontend/…/orgSwitchLogin.js• L11-25 frontend/…/RequireAuth.jsx• L32-97 frontend/…/RequireGuest.jsx• L43-80 frontend/…/RequireGuest.jsx• L104-132 frontend/…/ExternalRedirect.jsx• L4-56 frontend/…/RouteGate.tsx• L49-73 frontend/…/session.ts• L179-200
Workspace boundaries
Authenticated workspace routes use the organization name as a URL segment. The application compares that segment with the active session and redirects to the correct workspace when they differ (frontend/…/RequireAuth.jsx• L57-90, frontend/…/GetStaticData.js• L39-51).
Administrative screens add a backend profile check. Users without administrator rights see an unauthorized response, and some administrator features are not exposed in the open-source organization (frontend/…/RequireAdmin.jsx• L9-60).
Registered v1 pages render through their own application tree rather than through the v0 PersistentLogin and RequireAuth wrappers. The v1 route gate handles guest, authenticated, admin, organization, and cloud platform-admin decisions. Cloud entitlement behavior can wrap signed-in pages through a plugin gate, while OSS denies platform-admin routes (frontend/…/guard.ts• L17-54, frontend/…/RouteGate.tsx• L103-173, frontend/…/types.ts• L30-41).
References: frontend/…/RequireAuth.jsx• L57-90 frontend/…/GetStaticData.js• L39-51 frontend/…/RequireAdmin.jsx• L9-60 frontend/…/guard.ts• L17-54 frontend/…/RouteGate.tsx• L103-173 frontend/…/types.ts• L30-41
Resource access
Resource access describes what a user may change after a workflow, Prompt Studio project, deployment, or pipeline is shared. The browser uses ownership, administrator state, and organization capability settings to guide the available controls, while the backend remains the final authority for every write (frontend/…/resourceAccess.js• L1-21, frontend/…/permissions.ts• L1-85).
Most shared resources become view-only for a non-owner. Prompt Studio has a narrower boundary: shared users can collaborate on project content while owner actions remain protected. In v1, actions the current user cannot take are removed rather than shown as disabled, and capability settings cover creation, member management, API keys, platform defaults, and deletion (frontend/…/ReadOnlyNotice.jsx• L6-16, frontend/…/usePromptStudioCanEdit.js• L5-19, frontend/…/capabilities.ts• L6-35, frontend/…/permissions.ts• L31-85).
References: frontend/…/resourceAccess.js• L1-21 frontend/…/useWorkflowCanEdit.jsx• L5-15 frontend/…/usePromptStudioCanEdit.js• L5-19 frontend/…/ReadOnlyNotice.jsx• L6-16 frontend/…/capabilities.ts• L6-35 frontend/…/permissions.ts• L31-85
Workflow and platform capabilities
The authenticated application groups work around workflows, reusable tools, deployments, documents, and organization settings. A workflow is the user-defined document-processing unit; tools and configured services supply its extraction behavior, while deployments make a workflow available for use outside the editor.
Workflow workspace
Users can create and manage workflows, configure prompts and tools, inspect documents, run prompts, and review generated output. The workflow area also supports sharing and co-owner management so work can move across an organization (frontend/…/useMainAppRoutes.jsx• L260-271, frontend/…/workflow-service.js• L13-168).
The workflow setup view links source configuration, destination configuration, an exported Prompt Studio project, and deployment. Connector types determine which deployment choice is valid. A deployed workflow becomes locked against endpoint changes (frontend/…/Agency.jsx• L160-186, frontend/…/Agency.jsx• L443-496, frontend/…/Agency.jsx• L657-685).
The workflow can run normally or run a selected execution step. API workflows can request files for execution, while other supported source and destination pairs run from their configured connectors. A normal run returns an execution ID and sends the user to logs for long-running progress (frontend/…/Agency.jsx• L726-925). Results can include structured output, highlights, confidence data, token use, run cost, and elapsed time. Large result arrays reveal their content in batches rather than rendering every item at once (frontend/…/DisplayPromptResult.jsx• L17-63, frontend/…/DisplayPromptResult.jsx• L101-145).
Prompt Studio projects can be shared or exported as tools and can start an API deployment. The browser checks related lookups first, warns when a project has unfinished prompts before a tool export, and warns when the organization already has API deployments before opening the creation flow (frontend/…/Header.jsx• L80-177, frontend/…/Header.jsx• L270-312, frontend/…/Header.test.jsx• L69-95).
References: frontend/…/useMainAppRoutes.jsx• L260-271 frontend/…/workflow-service.js• L13-168 frontend/…/Agency.jsx• L160-186 frontend/…/Agency.jsx• L443-496 frontend/…/Agency.jsx• L657-685 frontend/…/Agency.jsx• L726-925 frontend/…/DisplayPromptResult.jsx• L17-63 frontend/…/Header.jsx• L80-177
Platform operations
The platform screens cover the operational steps around a workflow. They let users configure model and document services, manage connectors, set organization defaults, inspect metrics and logs, manage API keys, and create API, ETL, or task deployments (frontend/…/useMainAppRoutes.jsx• L234-325, frontend/…/SideNavBar.jsx• L97-150).
API deployments expose a workflow or Prompt Studio project to an external caller. The deployment area covers creation, activation, logs, API keys, code snippets, notifications, sharing, and co-owner management (frontend/…/ApiDeployment.jsx• L201-415, frontend/…/api-deployments-service.js• L18-160). ETL and task deployments make file-driven workflows run on demand or on a schedule (frontend/…/Pipelines.jsx• L140-199, frontend/…/Pipelines.jsx• L244-287). The v0 settings surface also manages tenant-scoped Agent-KV API keys; the resulting key is used as a bearer credential by the separate extraction API (frontend/…/AgentKvKeys.jsx• L7-35).
The metrics dashboard gives an organization a view of workflow and deployment activity. It combines summary values, activity charts, recent activity, usage by deployment, and an optional cloud subscription view. Short-lived session storage caching reduces repeated reads without sharing organization data with another tab or later visitor (frontend/…/MetricsDashboard.jsx• L95-186, frontend/…/MetricsDashboard.jsx• L188-282, frontend/…/metricsCache.js• L12-22, frontend/…/metricsCache.js• L56-101).
Credential screens keep keys masked by default and restrict write actions to resource owners. Notification forms change with the selected authorization mode, and co-owner changes are staged before they are applied (frontend/…/ManageKeys.jsx• L23-75, frontend/…/ManageKeys.jsx• L245-365, frontend/…/CreateNotification.jsx• L109-193, frontend/…/useCoOwnerManagement.jsx• L47-91).
The workflow and platform path is therefore: connect data and processing services, shape a workflow, verify its behavior, then expose it through a deployment or application. Optional product modules can add routes and richer output views without changing the core route set or result path (frontend/…/useMainAppRoutes.jsx• L102-187, frontend/…/usePromptOutput.js• L9-44, frontend/…/Router.jsx• L39-57).
References: frontend/…/useMainAppRoutes.jsx• L234-325 frontend/…/SideNavBar.jsx• L97-150 frontend/…/ManageKeys.jsx• L23-75 frontend/…/ApiDeployment.jsx• L201-415 frontend/…/Pipelines.jsx• L140-199 frontend/…/MetricsDashboard.jsx• L95-186 frontend/…/metricsCache.js• L12-22 frontend/…/metricsCache.js• L56-101 frontend/…/AgentKvKeys.jsx• L7-35 frontend/…/usePromptOutput.js• L9-44
Backend integration
The frontend is a client of the backend API. It sends session and organization-scoped requests, includes the session CSRF token for state changes, and turns backend errors into user alerts that can include request or execution IDs.
API request model
Public session checks use the same-origin /api/v1/session endpoint. Authenticated organization requests use the /api/v1/unstract/<organization-id>/ path so the backend can apply the active organization boundary (frontend/…/useUserSession.js• L15-23, frontend/…/useRequestUrl.js• L3-15, frontend/…/http.ts• L22-28).
The v0 private request client adds a request ID to calls and treats an unauthorized response as a session loss. Mutating requests send X-CSRFToken, which ties browser actions to the session accepted by the backend (frontend/…/useAxiosPrivate.js• L7-43, frontend/…/requestId.js• L1-30, frontend/…/workflow-service.js• L35-58). Logout clears local session state, cookies, analytics identity, v1 browser storage, and metrics cache, then uses page navigation to the backend logout endpoint so the identity provider can complete its redirect (frontend/…/useLogout.js• L9-29, frontend/…/metricsCache.js• L129-144).
The v1 services use one credentialed HTTP client. Every request receives a request ID, and same-origin state-changing methods copy the CSRF cookie into X-CSRFToken. Backend URLs and raw request APIs stay in service modules, so pages use typed service functions and query keys instead of creating their own request or error contract (frontend/…/http.ts• L9-28, frontend/…/http.ts• L64-105, frontend/…/README.md• L18-38, frontend/…/check-v1.mjs• L554-572).
The v1 session contract treats the current organization as part of request context. Session loading first checks identity, then selects or restores an organization and reads its profile. A normal organization change posts the new organization and reloads the browser; an identity-provider-owned change starts a silent login instead (frontend/…/session.ts• L66-117, frontend/…/session.ts• L120-200, frontend/…/organizations.ts• L71-99, frontend/…/OrganizationSwitcher.tsx• L151-181).
The v1 error contract turns backend failures into one ApiError shape. Query reads retry transient failures, writes do not retry, first-load failures remain on the page for retry, and refresh failures use one request-aware notification. Cancellations stay silent and an expired session leaves the page once (frontend/…/errors.ts• L46-65, frontend/…/query.ts• L18-68, frontend/…/report.ts• L18-49, frontend/…/context.ts• L52-89).
Prompt output requests select the standard organization endpoint or an optional Simple Prompt Studio or public-share endpoint. Returned records are normalized into shared output and token state. If a live completion has no inline result, the browser refetches the result and preserves existing output when that fetch fails (frontend/…/usePromptOutput.js• L81-109, frontend/…/usePromptOutput.js• L111-195, frontend/…/usePromptStudioSocket.js• L44-114).
References: frontend/…/useUserSession.js• L15-23 frontend/…/useRequestUrl.js• L3-15 frontend/…/useAxiosPrivate.js• L7-43 frontend/…/requestId.js• L1-30 frontend/…/useLogout.js• L9-29 frontend/…/http.ts• L9-105 frontend/…/README.md• L18-38 frontend/…/session.ts• L66-254 frontend/…/organizations.ts• L71-99 frontend/…/OrganizationSwitcher.tsx• L151-181 frontend/…/errors.ts• L46-65 frontend/…/query.ts• L18-68 frontend/…/context.ts• L52-89 frontend/…/usePromptOutput.js• L81-195
Live execution feedback
The browser opens a same-origin Socket.IO connection for messages that should appear while work is running. The backend path is /api/v1/socket; same-origin routing keeps session cookies with the connection and lets development and production routing handle the backend location (frontend/…/SocketContext.jsx• L7-36).
Persistent session content mounts the socket message handler beside the current route. This lets execution status, logs, and results reach the user while the user changes views within the application (frontend/…/PersistentLogin.jsx• L77-85). Prompt Studio and workflow views match events to the active tool, document, profile, and run, then update only the related progress or result state (frontend/…/usePromptStudioSocket.js• L11-19, frontend/…/usePromptStudioSocket.js• L44-141, frontend/…/usePromptStudioSocket.js• L154-189, frontend/…/PromptCard.jsx• L94-131, frontend/…/Agency.jsx• L547-609).
References: frontend/…/SocketContext.jsx• L7-36 frontend/…/PersistentLogin.jsx• L77-85 frontend/…/usePromptStudioSocket.js• L11-19 frontend/…/usePromptStudioSocket.js• L44-141 frontend/…/usePromptStudioSocket.js• L154-189 frontend/…/PromptCard.jsx• L94-131 frontend/…/Agency.jsx• L547-609
Change checklist
When these files or sections are changed, remember to consider these:
- Keep runtime configuration names aligned across the startup script, config reader, and served web root. A value that is written but not read silently falls back to an older or default value.
- Keep the
/apidevelopment proxy and/api/v1/socketWebSocket route aligned with the backend ingress. HTTP requests may work while live execution updates fail if only the HTTP path is routed. - Keep organization URL parsing, session organization fields, and organization-scoped API paths consistent. A mismatch can show one organization in the URL while sending requests for another.
- Keep the organization-switch mode flag aligned across the session response, normalized session state, organization picker, top navigation, and silent login URL.
- Keep top-navigation menu triggers aligned with the overlay library's event and focus model. A nested organization menu must stop parent-row selection for pointer and keyboard activation or the list can close before a choice is made.
- Keep logout as browser navigation to the backend endpoint. A client-side request cannot follow the identity provider's cross-origin logout redirect.
- Keep external product destinations outside the local route tree. Use a real browser navigation and allow only absolute HTTP(S) or root-relative destinations.
- Keep metrics cache clearing aligned with session expiry and logout. Organization business data must not survive a user change in the same tab.
- Keep prompt output identity fields aligned across fetch, store, socket, and display paths. A changed key can show one document's result under another prompt.
- Keep deployment type rules aligned with source and destination connection types. Changing a connector can invalidate the current deployment choice and locked state.
- Keep v1 route declarations, registration, distribution filters, and both URL mapping directions aligned. A page can otherwise render the wrong version or redirect to an unmapped screen.
- Keep v1 route gates aligned with session loading and plugin gates. A failed entitlement or platform-admin filler must close the page rather than show it without the check.
- Keep the v1 old-version preference tied to the current user ID and understand the last-user bootstrap behavior. A switch that resolves before session identity is synced can apply a saved previous-user choice.
- Keep v1 backend URLs, the shared HTTP client, and raw request APIs inside service modules. A page-level call bypasses request IDs, CSRF handling, session expiry, or the typed error path.
- Keep v1 query keys scoped by organization and resource. A missing organization key can show one organization's cached data in another organization's page.
- Keep v1 notification calls behind
@v1/lib/notifyand mount the v1 toaster once. A second toast surface or an unmounted toaster can hide user feedback. - Keep v1 plugin slot IDs, distribution names, route paths, and route overlap rules aligned with the registry. A valid-looking overlay can fail at build time or claim an OSS route.
- Keep v0 and v1 test scopes separate. Changes to aliases, optional plugin resolution, file transforms, or coverage paths can make a suite skip tests or load the wrong frontend generation.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Runtime config is absent or empty | Branding, version, Flow link, or analytics uses an unintended value | Apply the documented runtime, build-time, and default precedence. |
| WebSocket upgrade is not forwarded | Prompt and workflow results do not stream to the UI | Keep the socket path and WebSocket proxy enabled in development and ingress routes. |
| Session organization and URL organization differ | Requests can target a different organization than the page suggests | Compare the URL segment with session state before rendering the workspace. |
| A nested organization menu does not stop parent-row selection | The profile menu closes before the organization list can be used | Keep the nested trigger as the focused menu row and stop pointer and keyboard propagation. |
| Logout uses an API request instead of navigation | The identity provider redirect cannot complete from the browser client | Clear local state, then navigate to the backend logout path. |
| A separate product home is passed through the local router | The router renders its catch-all instead of opening the other application | Use a real browser navigation only for a valid absolute or root-relative destination. |
| Metrics cache survives session expiry | A later session can see stale organization metrics | Clear the metrics cache when the session ends and when logout starts. |
| A prompt result event belongs to another tool or run | One browser view can display another run's output | Match the event's tool, document, profile, and run identity before updating state. |
| A workflow uses incompatible source and destination types | The wrong deployment path is offered or the workflow locks incorrectly | Derive deployment choices from both endpoint types. |
| A v1 service bypasses the shared HTTP client | CSRF, request IDs, error mapping, or session-expiry handling can be lost | Keep backend URLs and request calls in typed service modules. |
| A query key omits the organization or filter | Cached rows from another context remain on screen | Include organization and resource identity in every query key. |
| A v1 registry entry lacks a route mapping or overlaps another entry | A v0 URL can redirect to the wrong v1 screen or loop between versions | Validate route shape, coverage, overlap, and page ownership before release. |
| A v1 page is rendered before the current user is synced | A toggle page can use a saved previous user's old-version choice | Keep the choice unknown until the switch store matches the current session user, except for the documented last-user bootstrap. |
| A v1 chunk is stale after a deployment | The page cannot load from the browser's cached module name | Reload once for a chunk-load error, then show the manual fallback instead of looping. |
| A route gate plugin fails to load | A protected v1 page could appear without entitlement or platform-admin checks | Keep gate slots closed while loading and show the gate failure state on load errors. |
| A plugin fills a slot twice or claims an overlapping route | The distribution cannot build a deterministic shell or router | Validate slot ownership, route patterns, distribution, and OSS route conflicts. |
| Organization switching keeps the old page state | Data from the old organization can remain visible after the switch | Post the switch through the backend and perform a full navigation. |
| Agent-KV management uses the public extraction path | The key-management request does not use the tenant session boundary | Keep management under the organization-scoped key path and use the generated key only for extraction calls. |
| A large PDF renders every page at once | Scrolling uses excessive browser memory and becomes slow | Keep page layout available while limiting live canvases to the nearby page window. |
| v1 styles are unscoped or use unprefixed utilities | v1 changes v0 surfaces or v0 styles change v1 surfaces | Keep v1 under .v1, use ui: utilities, and exclude v1 from the v0 scan. |
| A token source and generated CSS differ | Code or diff colors can be missing or use stale theme values | Change the token source, regenerate CSS, and run the v1 token checks. |
Key files
| File | Why to read it |
|---|---|
| frontend/…/index.jsx | Shows application bootstrap, runtime branding, analytics setup, and shared providers. |
| frontend/…/App.jsx | Shows the browser shell, theme synchronization, notifications, cross-tab sign-out, and router. |
| frontend/…/Router.jsx | Shows the split between public, authenticated, marketplace, optional product routes, and the v0/v1 version switch. |
| frontend/…/useMainAppRoutes.jsx | Shows the organization workspace and the main workflow and platform capability map. |
| frontend/…/useSessionValid.js | Shows product selection, organization selection, session enrichment, and feature setup. |
| frontend/…/useUserSession.js | Shows session checks and cleanup of user-local data and metrics cache after expiry. |
| frontend/…/RequireGuest.jsx | Shows guest routing and how a product hosted by another app leaves the SPA. |
| frontend/…/ExternalRedirect.jsx | Shows the safe browser navigation boundary for destinations outside the local router. |
| frontend/…/TopNavBar.jsx | Shows product branding, organization display and switching, account actions, and optional product controls. |
| frontend/…/TopNavBar.css | Shows the top navigation interaction targets, theme-aware identity styles, and menu-row layout. |
| frontend/…/TopNavBar.test.jsx | Shows the pointer and keyboard contracts for organization switching and current-organization display. |
| frontend/…/useAxiosPrivate.js | Shows authenticated v0 API behavior and session-expiry handling. |
| frontend/…/useLogout.js | Shows v0 local session cleanup and backend logout navigation. |
| frontend/…/config.js | Shows runtime configuration precedence and browser-facing configuration values. |
| frontend/vite.config.js | Shows development API and WebSocket proxying. |
| frontend/…/Agency.jsx | Shows workflow setup, connector-dependent deployment choices, execution actions, and live workflow feedback. |
| frontend/…/MetricsDashboard.jsx | Shows organization metrics, date ranges, refresh behavior, empty state, and optional cloud views. |
| frontend/…/metricsCache.js | Shows the session-scoped metrics cache and its expiry and cleanup rules. |
| frontend/…/AgentKvKeys.jsx | Shows the tenant-scoped Agent-KV key-management capability and its separation from extraction calls. |
| frontend/…/README.md | Defines the v1 boundary, data layer, styling rules, shared feedback, and version-switch contract. |
| frontend/…/index.ts | Defines the only public entry through which v0 may reach v1. |
| frontend/…/VersionSwitch.tsx | Shows URL-based v0/v1 resolution, old-version handling, lazy v1 loading, and chunk recovery. |
| frontend/…/V1App.tsx | Shows the v1 providers, query cache, route gate, plugin boundary, and notification surface. |
| frontend/…/V1ErrorBoundary.tsx | Shows page and chunk failure containment. |
| frontend/…/RouteGate.tsx | Shows v1 session loading, organization setup, access decisions, and cloud route gates. |
| frontend/…/guard.ts | Shows the pure guest, authenticated, organization, admin, and platform-admin decision rules. |
| frontend/…/entries.ts | Shows declared pages, go-live registration, route mappings, and development demo entries. |
| frontend/…/live.ts | Shows distribution filtering and development preview selection. |
| frontend/…/resolve.ts | Shows how the registry maps a browser URL to v0, v1, or a redirect. |
| frontend/…/validate.ts | Shows the route registry safety checks that prevent ambiguity and bad version mappings. |
| frontend/…/README.md | Defines the typed service contract, query-key scope, and failure presentation. |
| frontend/…/http.ts | Shows v1 organization paths, request IDs, CSRF handling, and session-expiry behavior. |
| frontend/…/session.ts | Shows session loading, organization selection, storage cleanup, and logout navigation. |
| frontend/…/organizations.ts | Shows organization listing, switching, identity-provider login, and refusal states. |
| frontend/…/capabilities.ts | Shows organization capability loading for v1 action access. |
| frontend/…/permissions.ts | Shows how ownership, administration, and organization capabilities shape available actions. |
| frontend/…/types.ts | Defines distribution-specific extension slots and route gates. |
| frontend/…/Slot.tsx | Shows plugin fallback, loading, failure, isolation, and retry behavior. |
| frontend/…/index.ts | Shows how build manifests become the active distribution's plugin registry. |
| frontend-v1-foundation.md | Provides the child-page view of the v1 boundary, theme foundation, document viewer foundation, shared UI capabilities, data layer, and extension points. |
| frontend-ui-architecture.md | Provides the child-page view of frontend source layout and UI feature boundaries. |