Web application
The web application is the main user interface for work in nao. It connects route-based pages to agent conversations, stories, project context, setup, settings, and embedded views while keeping shared server data and short-lived page state aligned. See Agent and chat, Stories and visualization, and Context Hub and repository workflows for deeper views of the related product areas.
Application shell
The application shell provides the shared frame around each page. It establishes identity, project scope, data access, display settings, navigation, and cross-page controls before it renders the route selected by the URL.
Runtime providers
The runtime providers give pages a common session, server-data cache, typed request boundary, theme, analytics, tooltip, and MCP app context. This keeps route pages focused on user work while shared services handle cross-cutting behavior.
References: apps/…/main.tsx• L46-115
Authentication boundary
The root route separates public and authenticated experiences. Embedded views use an embed link instead of the normal session gate, while the main application waits for a session and applies password-reset and two-factor checks before it shows the authenticated shell.
References: apps/…/__root.tsx• L19-68
Sidebar workspace
The sidebar workspace is the shared frame for the main product. It keeps navigation, project switching, command search, keyboard shortcuts, feed activity, billing notices, group-impersonation status, and route content in one layout.
The menu can use server-provided entries when the deployment allows customization. Admins can rename, hide, reorder, or add entries for a story, a filtered Stories page, or an external link. The client falls back to the standard menu when that data is unavailable, and it hides Context Hub, Skills, automations, or advanced settings when the current role or feature state does not allow them.
References: apps/…/_sidebar-layout.tsx• L20-71 apps/…/_sidebar-layout.tsx• L75-98 apps/…/group-impersonation.tsx• L13-67 apps/…/sidebar-menu-settings.tsx• L44-139 apps/…/use-sidebar-menu.ts• L7-25
Stale chunk recovery
Stale chunk recovery keeps an open browser tab usable after a deployment replaces hashed files. When a lazy-loaded chunk is no longer available, the browser reloads once within a guarded time window so it can fetch the new application entry point.
References: apps/…/stale-chunk-reload.ts• L1-23
Route-driven experiences
Routes turn a URL into a focused product experience. Parent routes supply shared layout and providers, while child routes choose the data and controls for chat, stories, onboarding, settings, context work, or an embedded view.
Chat experience
The chat experience is the primary work surface for asking questions and reviewing agent results. The chat route loads a conversation, places messages and input in the main column, and opens stories or query tools beside the conversation when the answer produces them. The chat layout selects default, example, or onboarding behavior before it renders the child route. See Agent and chat for the agent lifecycle and message state.
When the user opens a chat, the application follows this path:
flowchart TD
A[Chat URL] --> B[Chat route]
B --> C[Conversation and agent context]
C --> D[Messages and composer]
D --> E[Stories, files, queries, or side panels]
E --> F[Share, replay, or return to chat]
The composer joins the conversation to the project context available to the user. It supports model choice, attachments, voice input, citations, database and story references, skills, story creation modes, and an admin mode when permissions allow it. Budget, credit, allowance, setup, and story-edit checks can stop a send without losing the draft.
While the agent runs, a later message can wait in a queue or steer the running work when it is plain text. The queue can be reordered, edited, submitted early, removed, or marked as steering. This lets the user control the conversation without losing the active answer.
The conversation library groups produced stories, mentioned stories, shared files, and query results. It docks beside the chat when there is room and becomes a compact menu when there is not. A selected query can reveal its producing tool call. A selected citation can reopen its story element, file lines, or SQL lineage.
Messages also support review actions. Users can edit or resend their own messages, move between message versions, copy content, rate an answer, export a chat, and save a suitable answer as a context test.
References: apps/…/_sidebar-layout._chat-layout.tsx• L15-41 apps/…/chat-input.tsx• L189-221 apps/…/chat-input.tsx• L519-597 apps/…/chat-input-prompt.tsx• L114-247 apps/…/chat-input-message-queue.tsx• L24-91 apps/…/chat-input-message-queue.tsx• L234-269 apps/…/chat-artifacts-menu.tsx• L36-86 apps/…/chat-artifacts-menu.tsx• L148-209 apps/…/chat-messages.tsx• L53-109 apps/…/assistant-message-actions.tsx• L42-124 apps/…/user-message.tsx• L192-291 apps/…/citation-popover.tsx• L21-69
Story experience
The story experience turns saved analysis into a browsable library and a focused viewer. Stories can be opened from a route, a chat artifact library, a quick question, or a side panel. The viewer chooses the access and source mode that match the story, so shared and replay views can remain read-only while permitted owners can edit.
Stories can contain tabs, parameters, filters, charts, tables, maps, and custom data-app blocks. The same content model supports full-page views, side-panel views, previews, feed cards, and embedded views. A story element can become a citation for a related question, and a cited element can guide the viewer back to the source.
Custom stories support app and file views, saved versions, live data refresh, sharing, download, and follow-up questions. Owners and permitted editors can change blocks or table formatting on the latest editable version. Each accepted edit becomes a new version. A cached result remains usable when a live refresh fails.
Story editing uses one active edit session for a story. The viewer tracks the current version, edit access, unsaved changes, tab selection, and agent output together. It can block navigation until the user saves or discards local work, and it refreshes the visible story after another change is saved.
References: apps/…/story-viewer.tsx• L74-130 apps/…/story-viewer.tsx• L201-239 apps/…/story-viewer.tsx• L483-605 apps/…/story-tabbed-editor.tsx• L39-91 apps/…/story-tabbed-editor.tsx• L106-169 apps/…/custom-story-page.tsx• L53-83 apps/…/custom-story-page.tsx• L119-201 apps/…/custom-story-page.tsx• L243-363 apps/…/story-tabbed-content.tsx• L47-150 apps/…/story-ask-bar.tsx• L16-74 apps/…/use-story-viewer-agent-state.ts• L14-47
Side-panel experience
The side panel keeps the main work surface visible while a story, attachment, query, citation, or editor occupies a second view. It can be resized on large screens and becomes a full-screen view on mobile. Escape closes it when focus is not in an editable control.
The panel follows the identity of the current chat and story. Opening another asset replaces the current panel session, while route changes clear content that belongs to the old workspace. This prevents a story or query from one conversation from appearing in another.
References: apps/…/side-panel.tsx• L26-73 apps/…/side-panel-header.tsx• L12-34 apps/…/open-story-in-side-panel.tsx• L5-13 apps/…/use-story-viewer-switch-story.ts• L9-21
Onboarding experience
Onboarding is a guided chat that helps a user connect or import a project and prepare its data source. The route keeps setup separate from normal chat, shows the active path and progress, and watches for project and warehouse readiness. On completion, it activates the new project and offers a path into regular chat.
The setup path can import a repository, collect environment values, connect a warehouse, or generate a deployment key. The progress view prevents a restart while the setup agent is working. Project and warehouse state are checked until the new workspace is ready, then the active project and related cached data are refreshed.
References: apps/…/_sidebar-layout.onboarding.tsx• L55-93 apps/…/_sidebar-layout.onboarding.tsx• L96-180 apps/…/_sidebar-layout.onboarding.tsx• L184-242 apps/…/onboarding-progress.tsx• L16-84 apps/…/onboarding-command.tsx• L11-67
Settings experience
Settings provide the control surface for account, project, organization, access, integrations, usage, and administration. The settings parent supplies a common page frame, while child routes use role, license, deployment, and feature state to decide which controls a user can see.
Account settings cover identity, session cleanup, preferences, theme, memories, newsletter updates, and two-factor authentication. Project settings cover agent models and tools, database and context access, user groups, sensitive data rules, story themes, maps, and test schedules. Organization settings cover members, roles, identity, and shared account controls.
The access model can be checked through user groups and effective user access. Administrators can define feature access, context access, MCP tool access, and data protection rules. On self-hosted deployments, administrators can impersonate selected groups to view the application with those effective permissions.
Integrations include internal and external MCP access. The nao MCP page explains endpoint setup, available tool groups, client connection methods, OAuth clients, bearer-token rotation, and recent calls. The tool list makes mode and role limits visible instead of presenting every tool as always available.
Settings also provide shared story-theme previews, custom map boundaries, and searchable route entry points. A theme preview shows how headers, tabs, filters, charts, and tables will look. A boundary preview validates GeoJSON before an administrator adds it to the map library.
References: apps/…/_sidebar-layout.settings.account.tsx• L30-81 apps/…/_sidebar-layout.settings.account.tsx• L83-148 apps/…/org-members.tsx• L21-101 apps/…/user-groups-table.tsx• L49-184 apps/…/group-impersonation.tsx• L56-124 apps/…/_sidebar-layout.settings.project.integrations.index.tsx• L23-79 apps/…/mcp-endpoint.tsx• L41-75 apps/…/mcp-endpoint.tsx• L118-160 apps/…/mcp-tools.tsx• L120-187 apps/…/display-map.tsx• L46-84 apps/…/display-map.tsx• L87-174 apps/…/story-theme-preview.tsx• L136-165 apps/…/story-theme-preview.tsx• L208-325 apps/…/sidebar-menu-settings.tsx• L44-139
Context Hub
Context Hub is the place to understand and change the project guidance that shapes agent work. It can open from the main application or settings. Users with context access see tables, rules, docs, metrics, skills, tests, files, and changes in one review space. Other users can still reach the personal-skills view when their permissions allow it.
The documentation view starts with an overview and groups context by purpose. It provides search, recent changes, files often read by the agent, recommendations, and a clear path into the main rules. The navigator can open a file, test, project skill, personal skill, or share request without changing the larger workspace.
Skills have two scopes. Personal skills are stored in nao and are available to their author. Project skills are context files that reach the team through the normal review and publish flow. A personal skill can be edited, deleted, or offered for sharing. A share request lets a context administrator review and add the skill to their changes.
The editing view supports preview, source, and split reading modes. It keeps file and test identity in the URL, tracks unsaved edits, and asks before navigation that would discard them. The changes view separates a private nao draft from repository work, so a user can review, test, publish, or keep changes private according to the available workflow.
Context Hub also has a focused edit chat. It resumes the latest edit conversation, sends the page currently shown as context, and returns proposed changes to the current page. A failed first send restores the message so the user can try again.
References: apps/…/_sidebar-layout.context-hub.tsx• L10-25 apps/…/context-hub.tsx• L8-28 apps/…/context-doc-view.tsx• L57-104 apps/…/context-doc-view.tsx• L106-154 apps/…/context-doc-view.tsx• L158-329 apps/…/context-hub-overview.tsx• L47-107 apps/…/context-hub-navigator.tsx• L56-175 apps/…/context-hub-skill-page.tsx• L20-67 apps/…/context-hub-skill-page.tsx• L70-119 apps/…/personal-skills.tsx• L63-171 apps/…/personal-skills.tsx• L174-222 apps/…/personal-skills.tsx• L332-461 apps/…/personal-skills.tsx• L516-605 apps/…/context-hub-chat-panel.tsx• L49-106 apps/…/discard-changes-dialog.tsx• L12-45
Embedded views
Embedded views present a story, chart, or map in a small host page outside the full authenticated shell. Each view uses a link token to request permitted content, renders the result with the shared data states, and reports its size so the host application can fit it.
Invalid or expired links produce a bounded error state instead of the main workspace. Story content keeps the same loading, empty, unavailable, restricted, and refresh states as the full viewer, but it does not expose the full workspace controls.
References: apps/…/embed.tsx• L1-21 apps/…/embed.story.$storyId.tsx• L14-63 apps/…/embed.chart.$chartEmbedId.tsx• L12-61 apps/…/embed.map.$mapEmbedId.tsx• L12-79 apps/…/story-embeds.tsx• L18-83 apps/…/story-embeds.tsx• L85-291
Data access and state
The frontend separates durable server data from local interaction state. Typed requests and a shared query cache provide a consistent view of chats, stories, projects, settings, context, tests, sharing, and embed access. Routes, browser storage, and small stores hold choices that belong to a URL, page, or browser.
Typed server access
Server access uses the backend request contract as the source of request and response types. Pages use queries for reads and mutations for changes, so chat loading, story access, settings, Context Hub, tests, MCP, and embeds use the same request boundary and active organization or project scope.
References: apps/…/main.tsx• L66-95 apps/…/use-chat-query.ts• L1-35 apps/…/_sidebar-layout.settings.mcp-endpoint.tsx• L8-19 apps/…/embed.story.$storyId.tsx• L21-29
Query cache
The query cache keeps server data available across related views and reduces repeated reads. Streaming chat changes, active runs, live story data, context edits, access changes, and settings mutations refresh the related records so a page does not keep showing an old result after a change.
References: apps/…/main.tsx• L46-59 apps/…/context-hub-chat-panel.tsx• L95-106 apps/…/mcp-endpoint.tsx• L87-108 apps/…/display-map.tsx• L91-99 apps/…/display-chart.tsx• L92-109 apps/…/display-map.tsx• L90-115
Active project context
The active project is a browser-level choice that scopes much of the user's work. The application stores it locally, sends it with requests, and refreshes route data when another tab changes it. Onboarding activates a created project only after the setup state identifies it as ready.
References: apps/…/active-project.ts• L1-68 apps/…/main.tsx• L56-85 apps/…/_sidebar-layout.onboarding.tsx• L221-242
Agent conversation state
The agent provider gives chat, onboarding, quick-question, story, and editor-chat pages one conversation model. It exposes messages, send and edit actions, run status, cancellation, model choice, message selection, and local message subscriptions.
Conversation artifacts build on the current messages rather than copying them into separate page records. This lets stories, files, queries, citations, tool calls, and story drafts remain linked to the message that produced them while the answer streams.
References: apps/…/agent.provider.tsx• L10-115 apps/…/ask-bar.tsx• L217-230 apps/…/chat-artifacts-menu.tsx• L43-86 apps/…/use-story-viewer-agent-state.ts• L25-60 apps/…/editor-chat-panel.tsx• L192-221
Route and local interface state
The URL carries state that should survive navigation or be linkable, such as the current story tab, settings tab, monitoring range, onboarding chat, Context Hub file, test target, and MCP section. Short-lived choices stay local to the page, such as dialogs, side-panel contents, editor drafts, pending citations, sharing drafts, and queued messages.
References: apps/…/_sidebar-layout.settings.project.integrations.index.tsx• L23-79 apps/…/_sidebar-layout.onboarding.tsx• L48-77 apps/…/context-doc-view.tsx• L69-104 apps/…/chat-input-message-queue.tsx• L33-57 apps/…/custom-story-page.tsx• L68-83
Editor chat state
Editor chat is a reusable conversation beside a page that can change. It resumes the latest page-specific chat when one exists, creates a new one when the user sends the first message, and passes the page's current state with each request. Page-specific effects apply the agent's accepted changes to the editor and refresh its related data.
References: apps/…/editor-chat-panel.tsx• L43-71 apps/…/editor-chat-panel.tsx• L117-152 apps/…/context-hub-chat-panel.tsx• L49-92 apps/…/custom-story-page.tsx• L105-114
Agent result presentation
The frontend turns streamed agent output into readable text, grouped work, query results, and visual results. This presentation layer lets a user inspect the work behind an answer without making every tool call part of the main reading flow.
Message groups
Messages are grouped into user requests and assistant responses. Assistant content can include text, reasoning, grouped tool work, query work, story status, citations, and interrupted or steered messages. The view shows progress while work streams and exposes actions after the response settles.
References: apps/…/chat-messages.tsx• L53-109 apps/…/assistant-message.tsx• L34-92 apps/…/assistant-message.tsx• L96-146 apps/…/index.tsx• L41-113 apps/…/tool-calls-group.tsx• L19-64
Query and visualization results
SQL and semantic-query results can show data, the query definition, compiled SQL, exports, conditional formatting, and a side-panel editor. Charts, tables, and maps can show their data or source query, support suitable edits, and add supported results to a story.
Story embeds resolve data from saved results, live queries, or a source query. They distinguish loading, empty, unavailable, incomplete, restricted, and refresh states so missing data is not presented as a valid result.
References: apps/…/execute-sql.tsx• L23-143 apps/…/execute-semantic-query.tsx• L25-165 apps/…/display-chart.tsx• L74-179 apps/…/display-chart-table.tsx• L32-69 apps/…/display-map.tsx• L60-127 apps/…/story-embeds.tsx• L57-83 apps/…/story-embeds.tsx• L85-231 apps/…/story-embeds.tsx• L233-291
Citations and lineage
Citations connect visible answer text to the story element, source file, query, or database column that supports it. A citation can be carried into a follow-up question, reopened in the source view, or expanded into SQL, tables, and column lineage.
References: apps/…/citation-popover.tsx• L21-69 apps/…/citation-popover.tsx• L127-192 apps/…/chat-input.tsx• L519-581 apps/…/user-message.tsx• L113-124
User access flows
Public entry routes establish identity before the authenticated shell takes over. The flow supports credentials, configured social or OAuth paths, organization SSO, email verification, two-factor authentication, safe redirects, and deployment feature flags.
Sign-in and sign-up flows
Sign-in checks public configuration before it submits credentials. A successful sign-in returns the user to a safe requested path or the home route. Unverified email and two-factor protection add their required steps before the user enters the application. Sign-up is available only when enabled and can pause after account creation while the user verifies the email address.
References: apps/…/login.tsx• L22-65 apps/…/login.tsx• L67-167 apps/…/signup.tsx• L13-118
Permission model
The frontend derives page and action access from project and organization roles, group features, license state, and deployment mode. The same access result controls whether a user can chat, share, replay, manage tests, use Context Hub, manage skills, use MCP tools, edit settings, manage automations, or view monitoring.
References: apps/…/use-permissions.ts• L7-35 apps/…/user-group-feature-card.tsx• L24-79 apps/…/user-groups-table.tsx• L95-184 apps/…/mcp-tools.tsx• L174-187 apps/…/_sidebar-layout.context-hub.tsx• L10-25
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to request headers or active project selection must preserve the scope used by chat, stories, settings, Context Hub, tests, sharing, MCP, and embeds.
- Changes to parent route providers must preserve the contexts required by child chat, story, onboarding, settings, Context Hub, and embedded routes.
- Changes to chat streaming, message grouping, or queue actions must preserve the link between agent state, visible messages, side panels, citations, tool reveals, and queued or steered sends.
- Changes to chat input mentions must preserve the distinction between context references, story references, citations, skills, and story-creation modes.
- Changes to quick-question session creation must preserve the pending first message, citations, source page, and destination chat.
- Changes to story versions, tabs, filters, edit locks, or live refresh must preserve the link between the visible version, editable state, side-panel state, and story chat.
- Changes to result data resolution must preserve the shared loading, empty, unavailable, restricted, and refresh states across chat, stories, previews, and embeds.
- Changes to Context Hub navigation or search must preserve URL targets for files, diffs, tests, skills, and browser back and forward behavior.
- Changes to context editing or project skills must preserve unsaved-draft guards, conflict checks, private changes, repository review, and personal or team skill scope.
- Changes to settings search entries, tabs, or MCP sections must preserve their route parameters and visibility conditions.
- Changes to user-group or impersonation state must refresh effective permissions before protected pages and controls are rendered.
- Changes to MCP modes, tools, clients, or bearer tokens must preserve endpoint scope, role limits, one-time secrets, and external client connection behavior.
- Changes to custom map boundaries or story themes must preserve validation, preview state, saved versions, and the data used by rendered stories.
- Changes to onboarding project detection or warehouse readiness must preserve active-project activation and setup-completion refreshes.
- Changes to embed tokens or response shapes must preserve permitted-content checks, sizing reports, download behavior, and bounded error states.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A request uses stale organization or project context | The page can show missing data or data from the wrong scope | The request boundary tracks active context and stale project responses clear invalid scope |
| A chat send bypasses the story-change guard | The agent can work against story content the user has not reviewed | Direct and queued sends use the same pre-send check |
| A plain-text steering message is treated as a normal queued message | The running agent does not receive the user's intended correction at the right point | The composer limits steering to steerable drafts and exposes the queue state |
| A citation loses its story, file, query, or range identity | A follow-up question cannot return to the quoted source | Citation data keeps source identity and reveal targets |
| A story mutation does not refresh related data | The viewer or library shows an old version, placement, or result | Story actions invalidate the related version, list, and result queries |
| Unsaved Context Hub or skill edits are left during navigation | The user can lose local changes or overwrite another change | Dirty state blocks navigation and the discard dialog requires a choice |
| A personal skill is treated as a project skill | A private instruction can reach users who were not meant to receive it | Skill scope remains explicit in creation, editing, and sharing flows |
| A user-group change refreshes only the visible table | Other pages continue to show old effective access | Permission and effective-access queries refresh together |
| An MCP bearer token is rotated without updating clients | External MCP clients stop working | Rotation warns that the old token is invalid and shows the new token through the connection flow |
| A map boundary lacks the configured join property | A choropleth renders no matching regions | GeoJSON is validated and the join property is selected from loaded properties |
| A live story refresh fails and removes cached content | The user loses the last usable story view | The viewer keeps cached content and shows the refresh failure |
| An embed token is missing or expired | The host sees no permitted story, chart, or map | Embed routes return a bounded error state instead of the main shell |
| Onboarding activates a project before setup is ready | Subsequent pages use incomplete project data | Project and warehouse readiness are checked before activation |
| A deployed lazy chunk is unavailable and reload recovery is unbounded | The tab can remain in a reload loop | Stale-chunk recovery limits reload attempts within a time window |
Key files
| File | Why to read it |
|---|---|
| apps/…/main.tsx | Application entry point, providers, router, cache, and request scope |
| apps/…/__root.tsx | Public and authenticated route boundary |
| apps/…/_sidebar-layout.tsx | Shared workspace, navigation, global controls, and impersonation banner |
| apps/…/sidebar-menu-settings.tsx | Custom sidebar menu behavior and saved navigation choices |
| apps/…/_sidebar-layout._chat-layout.tsx | Chat provider composition and conversation mode selection |
| apps/…/chat-input.tsx | Composer context, send checks, attachments, citations, and steering or queueing |
| apps/…/chat-input-prompt.tsx | Context, story, citation, and skill mention model |
| apps/…/chat-input-message-queue.tsx | Queued follow-ups and steering behavior |
| apps/…/chat-messages.tsx | Message grouping and streaming presentation |
| apps/…/assistant-message-actions.tsx | Feedback, exports, and save-as-test actions |
| apps/…/chat-artifacts-menu.tsx | Conversation library for stories, files, and queries |
| apps/…/side-panel.tsx | Responsive side-panel behavior and close handling |
| apps/…/story-viewer.tsx | Story access, versions, preview, editing, citations, and live state |
| apps/…/custom-story-page.tsx | Custom, standalone, and shared story page experiences |
| apps/…/story-tabbed-content.tsx | Shared story tabs, filters, parameters, and rendered blocks |
| apps/…/story-embeds.tsx | Shared chart, table, and map data resolution and display states |
| apps/…/_sidebar-layout.onboarding.tsx | Guided setup, project activation, and readiness flow |
| apps/…/onboarding-progress.tsx | Setup paths and progress rules |
| apps/…/context-hub.tsx | Context Hub access and view selection |
| apps/…/context-doc-view.tsx | Context navigation, file targets, tests, changes, and edit guards |
| apps/…/context-hub-skill-page.tsx | Skill library, personal skills, and share requests |
| apps/…/personal-skills.tsx | Skill creation, editing, sharing, and scope behavior |
| apps/…/context-hub-chat-panel.tsx | Context-aware edit chat and refresh behavior |
| apps/…/editor-chat-panel.tsx | Reusable chat beside an editor or review page |
| apps/…/_sidebar-layout.settings.account.tsx | Account controls, preferences, and session cleanup |
| apps/…/user-groups-table.tsx | Group access, data protection, and effective project access |
| apps/…/mcp-endpoint.tsx | MCP setup, connection, client, token, and activity experience |
| apps/…/mcp-tools.tsx | MCP tool availability by mode and role |
| apps/…/display-map.tsx | Map capability and custom boundary library |
| apps/…/story-theme-preview.tsx | Shared story-theme preview and version selection |
| apps/…/index.tsx | Mapping from agent tool output to user-facing result views |
| apps/…/display-chart.tsx | Interactive chart result, editing, export, and story actions |
| apps/…/display-map.tsx | Interactive map result, boundary use, export, and story actions |
| apps/…/execute-sql.tsx | SQL result inspection, export, formatting, and side-panel editing |
| apps/…/execute-semantic-query.tsx | Semantic result inspection and compiled-query views |
| apps/…/citation-popover.tsx | SQL, database origin, and column-lineage source view |
| apps/…/active-project.ts | Browser project scope and cross-tab behavior |
| apps/…/use-chat-query.ts | Shared chat query contract and streaming-aware reads |
| apps/…/agent.provider.tsx | Conversation actions and message subscription model |
| apps/…/stale-chunk-reload.ts | Recovery from deployment-time lazy chunk failures |