Introducing a new way to review your PRs.

Read the announcement

getnao / nao

👾 nao is the #1 open source agentic BI. (1) Create context with nao-core cli, (2) deploy nao chat interface for everyone

View on GitHub

23 documents · Updated Nov 23, 2026

docs / stories-and-visualization

Stories and visualization

Stories turn data and written insight into shareable, interactive pages. A story combines narrative text with visual blocks, query results, filters, tabs, and a paired theme for light and dark display modes. The same story model supports private work, shared viewing, embedded access, scheduled delivery, and downloadable applications.

Story model

The story model joins authored content to data and presentation rules. Story code describes the page structure and names the query data that supplies each visual block. A theme pair then gives the page a shared visual language across the application and delivered forms.

References: apps/…/story-app.ts• L92-117 apps/…/story-theme.ts• L192-235 apps/…/story-segments.ts• L78-84

Narrative structure

Narrative structure lets a story move between explanation and evidence. Markdown provides the written layer, while charts, tables, maps, filters, and grids provide the data layer. Tabs group related views into one story and let authors switch between focused views.

References: apps/…/story-segments.ts• L78-84 apps/…/story-tabs.ts• L14-18 apps/…/story-tabs.ts• L38-44

Visual blocks

Visual blocks turn query results into views that readers can inspect. Charts show measures and series, tables expose rows with optional formatting, and maps show geographic data. Grids arrange blocks into responsive columns so a story can present related views together. Map blocks can also use boundary sets from the story’s project so geographic data can render with project-specific shapes.

References: apps/…/story-segments.ts• L14-84 apps/…/story-rendering.tsx• L28-67 apps/…/story-rendering.tsx• L83-138 apps/…/story-map-boundary.ts• L8-45

Filters and interaction

Filters let readers change the data shown by compatible blocks without changing the story structure. A filter has an identity and type, and select-style filters use either fixed choices or values from a data source. The story keeps filter behavior separate from the visual block so one control can shape the page view. Option controls support search, single or multiple selection, custom values, and dependent selections whose child values follow the parent choice.

References: apps/…/story-segments.ts• L64-76 apps/…/story-segments.ts• L232-260 apps/…/story-validation.ts• L284-370 apps/…/story-filter-options-select.tsx• L14-73 apps/…/story-filter-options-select.tsx• L144-176

Themes and brand identity

Themes keep story presentation consistent across light and dark display modes. They cover surfaces, text, blocks, tables, chart colors, fonts, typography, and brand identity such as a logo or name in a bare header or colored band. The same theme rules are applied to the in-product view and to exported story documents.

References: apps/…/story-theme.ts• L181-235 apps/…/story-theme.ts• L257-351 apps/…/story-document.ts• L157-169

Theme generation

Theme generation turns brand sources into a story theme pair for project-wide use. An administrator can provide a website, image, PDF, ZIP, document, logo, white-label settings, or written guidance; the system combines the available evidence and records notes about the sources and any limits. It identifies the source’s light or dark mode, then derives the matching counterpart while keeping the brand’s main identity, fonts, and shapes.

The generated result is a starting point rather than a locked design. Administrators can preview it, edit the colors, type, layout, blocks, tables, and chart palette, then apply or reset the theme. A hand-uploaded logo remains part of the result when generation does not supply one.

References: apps/…/generate.ts• L87-140 apps/…/generate.ts• L264-391 apps/…/story-theme-settings.tsx• L192-240 apps/…/story-theme-settings.tsx• L270-540

Story organization

Stories are organized in project libraries through folders, visibility, and archive state. The library can show owned stories, shared stories, standalone stories, archived items, and stories that a user can reuse in project conversations.

Folder hierarchy

Folders group stories and subfolders into a project tree. Private folders support personal organization, public folders expose their stories at project level, and a virtual “Shared with me” folder collects stories granted to the current user. Folder moves keep folder visibility and project-level story sharing aligned, while archive and restore operations apply to the related folder contents and stories. The story service also supports bulk archive and restore for owned and authorized shared stories.

References: apps/…/story-folder.queries.ts• L50-112 apps/…/story-folder.queries.ts• L264-304 apps/…/story-folder.queries.ts• L306-422 apps/…/story.routes.ts• L234-301 apps/…/story.routes.ts• L1239-1315

Story lifecycle

A story moves from authored structure to a rendered view, then to one or more delivery forms. Query results and generated narratives supply current content, while the story structure and theme determine how that content appears. The lifecycle is shared by owned, shared, standalone, and downloaded views.

This diagram shows how story content moves from authoring through data binding to reader-facing forms.

flowchart LR
    A[Story structure] --> B[Validate and parse]
    B --> C[Bind query data and narratives]
    C --> D[Render text and visual blocks]
    D --> E[Private view]
    D --> F[Shared or embedded view]
    D --> G[Download or scheduled delivery]

Authoring state

Authors work with a story in preview, rich edit, or code view. The page can show a normal narrative or a tabbed editor, and the preview uses the same story blocks that readers see. Authors can add, rename, remove, reorder, and move blocks between tabs while keeping each view focused. Version selection separates the current published view from earlier saved states.

Editing uses a time-bound lock for each story and editing session. This prevents overlapping manual or agent changes from silently replacing one another. Custom stories use the same editing boundary for block changes, file saves, and version restoration. See Story authoring and library management for authoring state, library organization, and version work.

References: apps/…/story-page-body.tsx• L23-91 apps/…/owned-story-page.tsx• L62-75 apps/…/story-tabs-bar.tsx• L12-32 apps/…/story-tabs-bar.tsx• L74-162 apps/…/story-validation.ts• L31-48 apps/…/story.routes.ts• L330-348 apps/…/story.routes.ts• L749-908 apps/…/story.routes.ts• L968-1033 apps/…/story-edit-lock.queries.ts• L7-42 apps/…/story-edit-lock.queries.ts• L45-84

Data binding and refresh

Each visual block points to query data by an identifier. A story can use cached results for stable viewing or request fresh results for live views. Story query definitions can be retained with a story so custom and standalone views can rerun eligible queries; when only saved rows remain, the story continues to show those rows. Filtered views run with the viewer’s choices and do not replace the shared story cache. Refresh state is visible to viewers, and stale stories can retry refresh so the page can return to current data.

Custom story viewers can also run a query with viewer-selected inputs. These runs use the viewer’s access and only the queries referenced by the selected story version. Custom story SQL is read-only warehouse SQL, and it is available only when the project allows that data path. Manual refresh clears viewer-specific cached data so later views use the new story result.

References: apps/…/story-segments.ts• L121-207 apps/…/owned-story-page.tsx• L39-55 apps/…/owned-story-page.tsx• L270-305 apps/…/story-query.queries.ts• L7-68 apps/…/custom-story.ts• L135-173 apps/…/custom-story.ts• L213-265 apps/…/custom-story.ts• L321-377 apps/…/custom-story-sql.ts• L24-67 apps/…/story.routes.ts• L1108-1154 apps/…/story.routes.ts• L1156-1229 apps/…/shared-story.routes.ts• L234-308 apps/…/custom-story-viewer.routes.ts• L89-130

Viewer surfaces

The product presents the same story through distinct access surfaces. Owners can edit and manage a story, shared viewers receive a read-only view with permissions, and standalone viewers can open a story outside its source chat. These surfaces preserve the story’s narrative, blocks, filters, theme, and available refresh actions while changing what the viewer may do.

Custom stories also keep access tied to the version and data that the story references. Shared and editor views can request only the queries used by that version, while standalone views use saved results or saved query definitions and do not expose unrelated chat data. Shared-chat viewers and permitted chat replays use the custom story viewer surface, which also supplies viewer state, narratives, chart plugins, and map boundaries.

References: apps/…/owned-story-page.tsx• L31-68 apps/…/shared-story-page.tsx• L29-66 apps/…/standalone-story-page.tsx• L21-71 apps/…/story.routes.ts• L303-328 apps/…/story.routes.ts• L380-423 apps/…/custom-story.ts• L418-585 apps/…/custom-story-viewer.routes.ts• L42-207 apps/…/shared-story.routes.ts• L201-353 apps/…/standalone-custom-story.routes.ts• L36-183

Story previews

Story previews give libraries and viewers a quick visual view without waiting for the full page to open. Stored previews use saved story data and both theme modes. A viewer-scoped preview uses that viewer’s data snapshot instead, so access rules and row-level visibility do not leak through an owner’s image.

Preview freshness follows the inputs that affect the rendered page. A theme change, live data refresh, shared app state change, chart plugin change, or map boundary change can mark the stored image stale and start a background render. A failed render keeps the last usable image while retry limits prevent repeated work.

References: apps/…/custom-story-thumbnail.ts• L94-127 apps/…/custom-story-thumbnail.ts• L130-224 apps/…/custom-story-thumbnail.ts• L234-313 apps/…/custom-story-thumbnail.ts• L355-420

Story actions

Story actions manage how a story is reused and assessed around its main view. Owners can duplicate a selected version, mark a story as a favorite, and share it; administrators can certify a story, authorized users can transfer ownership, and viewers can send a positive or negative assessment with an optional explanation.

References: apps/…/story-header-actions.tsx• L24-54 apps/…/story-header-actions.tsx• L57-93 apps/…/story-header-actions.tsx• L122-172 apps/…/story.routes.ts• L921-965

Story references

Story references make accessible stories available for reuse in project conversations and story discovery. The reference list favors pinned and certified stories, then recent stories, while access checks keep private, archived, and restricted stories out of the result. The product can also identify chats that created or visibly reference a story.

References: apps/…/story-reference.queries.ts• L25-53 apps/…/story-reference.queries.ts• L68-117 apps/…/story-reference.queries.ts• L148-170 apps/…/story.routes.ts• L288-301 apps/…/story.routes.ts• L355-367

Story delivery

Delivery turns a story into a result that other people or systems can consume. Sharing controls access to a live story, embedding places it in another page, and scheduled delivery sends it to selected recipients on a recurring schedule. Delivery depends on the story’s current share and refresh state, so access and freshness remain linked. See Story delivery, sharing, and rendering for the delivery workflows and rendered outputs.

Shared and embedded access

Shared stories provide controlled read access to a story without giving every viewer author rights. Embedded stories use a viewer surface designed for placement in another context, while the story still receives its data, theme, chart plugins, and map boundaries through the story runtime. Removing a share also removes its delivery path before the story becomes private again.

References: apps/…/shared-story-page.tsx• L29-59 apps/…/shared-story-page.tsx• L120-187 apps/…/shared-story.service.ts• L9-27 apps/…/custom-story-viewer.routes.ts• L179-207 apps/…/shared-story.routes.ts• L351-381 apps/…/shared-story.routes.ts• L473-517

Scheduled delivery

Scheduled delivery sends a story on a recurring schedule to a defined audience. The schedule is valid only when its recipients and time rule are valid, and it does not create a second schedule when it matches the story’s own live refresh schedule. Disabling or tearing down delivery removes the recurring job and its recipient state.

Story owners manage delivery separately from live data settings. Live settings control whether story data or text refreshes and how often cached data updates; delivery settings control whether notifications run, which channels they use, and which users or groups receive them.

References: apps/…/story-delivery.service.ts• L11-27 apps/…/story-delivery.service.ts• L29-70 apps/…/story.routes.ts• L1035-1106 apps/…/story.routes.ts• L1232-1237

Downloadable applications

Downloads package the story bundle, runtime, theme, query results, narratives, and map boundaries into a self-contained document. The result can run without the host application and keeps interactive chart and deck behavior. Owners and permitted shared or standalone viewers can request PDF or HTML output, including a selected story version; custom stories can provide their own rendered download. The document supports both React stories and HTML stories, with a controlled set of scripts, styles, fonts, and map assets.

Custom story downloads include only the query results referenced by the selected version. They also include the saved narrative, viewer-independent state, chart plugins, and map boundaries needed by that app. A live story can still show its saved data when a refresh is not available, while a selected older version is delivered as that saved version rather than being silently replaced by the latest one.

References: apps/…/story-document.ts• L13-73 apps/…/story-document.ts• L83-97 apps/…/story-app.ts• L23-37 apps/…/custom-story-export.ts• L32-98 apps/…/custom-story-viewer.routes.ts• L180-208 apps/…/shared-story.routes.ts• L355-381 apps/…/story.routes.ts• L749-787 apps/…/story.routes.ts• L1317-1430 apps/…/story-download.tsx• L19-31 apps/…/story-download.tsx• L46-77 apps/…/story-download.tsx• L101-127

Custom story applications

Custom stories extend the block model with a full browser application when the standard narrative format is not enough. The product builds the supplied source into a story app, supplies approved runtime packages, and mounts it in the same story environment as standard content. This lets custom views use story data, theme, state, chart plugins, map boundaries, and export behavior without granting unrestricted access to the host.

Custom applications can request only the query data and files allowed by the selected story version. Their viewer surfaces can also expose supported model or SQL actions, viewer state, narratives, chart plugins, and map boundaries when the access context permits them. Standalone applications keep their own saved data and do not depend on a source chat.

Build boundary

The build boundary turns source files into one browser bundle before the story can run. It requires a valid entry point, limits imports to supported packages, blocks unsupported remote style loads, and rejects bundles that exceed the product size limit. These rules make custom applications portable and keep their dependencies within the story runtime.

References: apps/…/story-app-build.ts• L39-74 apps/…/story-app-build.ts• L80-120 apps/…/story.routes.ts• L783-881

Runtime boundary

The runtime boundary connects a story frame to the host through a small message channel. The channel carries query results, narratives, theme changes, editing state, table actions, map boundary data, and story state without exposing the host page as the application surface. The standalone runtime uses the same boot model for downloaded stories.

References: apps/…/story-app.ts• L208-242 apps/…/story-app.ts• L244-260 apps/…/custom-story-sql.ts• L31-90 apps/…/story-map-boundary.ts• L23-45 apps/…/custom-story-export.ts• L44-88 apps/…/custom-story-viewer.routes.ts• L89-178 apps/…/story-document.ts• L111-150

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to visual block attributes must stay aligned across parsing, validation, rendering, and authoring edits.
  • Changes to query identifiers, stored query definitions, or result shape must preserve the binding used by charts, tables, maps, filters, custom apps, thumbnails, and exports.
  • Changes to live refresh or viewer-selected inputs must keep shared cached results separate from a viewer’s filtered result.
  • Changes to custom story SQL must preserve read-only warehouse execution and viewer access checks.
  • Changes to theme tokens, brand headers, or light/dark derivation must work in the in-product frame, shared views, thumbnails, and downloaded documents.
  • Changes to theme generation sources or precedence must keep generated notes and the editable preview consistent with the saved theme pair.
  • Changes to tab movement or drop behavior must preserve block ownership and the active view when blocks move between tabs.
  • Changes to filter option loading or dependent selections must preserve single-select, multi-select, custom-value, and parent-child filter behavior.
  • Changes to project map boundary sources or join properties must keep interactive maps, server renders, thumbnails, and downloads aligned.
  • Changes to folder visibility, archive state, or story placement must keep library visibility and project-level sharing synchronized.
  • Changes to edit-lock ownership, expiry, or session identity must preserve the boundary between manual edits and agent edits.
  • Changes to share removal must keep delivery jobs and recipient state from outliving access to the story.
  • Changes to download access or format handling must keep owner, shared, standalone, and custom-story paths aligned with the selected story version.
  • Changes to custom app query, SQL, model, or map data access must preserve the rule that a version can request only its referenced data.
  • Changes to the custom app message contract must update both frame-to-host and host-to-frame behavior.
  • Changes to thumbnail freshness inputs or retry rules must keep viewer images tied to the viewer’s data snapshot.
  • Changes to chat-story and standalone-story route inputs must preserve equivalent refresh, archive, version, delivery, filter, and download behavior across both entry paths.

Important failure modes

TriggerConsequenceGuard
A chart, table, filter, or tab block has invalid structureThe block is rejected or the story cannot render the intended viewValidate story code before save and report source positions
A story refers to missing query dataA visual block has no usable result or shows stale contentKeep query identifiers aligned with the data set and refresh path
A viewer requests data not referenced by a custom story versionThe request is denied instead of exposing unrelated story or chat dataCheck every query against the selected version before serving it
Custom story SQL is not read-only, targets the local database, or uses a blocked passthrough callThe query is rejected before it can read or change dataRestrict execution to read-only warehouse SQL and apply viewer access rules
A standalone viewer tries to rerun a saved query without a retained query definitionThe request cannot run and the viewer must use saved rowsKeep saved results available and report the input limitation
A project boundary set is missing or has incompatible join dataA map cannot draw the intended geographic regionsResolve boundaries through the story’s project and return only valid boundary data
A parent filter changes while child options are still loadingChild selections can no longer match the available dataDrop invalid child values after the complete option set loads
A generated theme has poor contrast or an unreadable paired modeStory text, controls, or chart series become hard to read in one display modeApply contrast guards and derive each counterpart with visible surfaces, ink, and accent colors
A theme source cannot be read or the project has no modelGeneration falls back to available signals or fails with a source-specific explanationRecord source limits and allow administrators to edit or retry the theme
A logo or font source violates the supported format or size rulesThe theme cannot be saved or the intended identity does not loadValidate logo data and restrict font stylesheets to approved hosts
A folder move creates a cycle or changes visibility without its story share updateThe library tree becomes invalid or a story’s folder and access state disagreeReject cycles and update folder and project-share state in one transaction
Another editor holds the story lockA manual or agent change is rejected until the lock expires or is releasedUse the story and session holder identity with database-clock expiry
A delivery schedule has no required recipients or an invalid time ruleDelivery is rejected instead of creating a recurring jobValidate recipients and the next schedule tick before sync
A shared story is unshared without removing deliveryRecipients can receive a story that no longer has accessTear down delivery before deleting the share
A custom story imports an unsupported package or remote stylesheetThe app build fails or the browser blocks required assetsEnforce the import and asset boundary during build
A custom story download lacks its saved query, narrative, state, plugin, or boundary inputThe downloaded app differs from the story view or cannot renderBuild the export from the selected version and all required saved inputs
A stored preview uses an old theme, data snapshot, plugin, or boundary setA library or viewer preview differs from the current storyInclude all render inputs in freshness checks and render viewer previews from viewer data

Key files

FileWhy to read it
apps/…/story-segments.tsDefines the story’s narrative and visual block model.
apps/…/story-app.tsDefines custom app capabilities, runtime messages, state, and export data.
apps/…/story-theme.tsDefines the theme contract, paired display modes, brand identity, and rendering variables.
apps/…/story-theme-pair.tsDefines how one theme becomes a readable counterpart for the other color scheme.
apps/…/story-theme-brand-styles.tsDefines how theme roles shape story text, controls, tabs, headers, KPI tiles, and chart interaction.
apps/…/story-document.tsShows how a story becomes a self-contained downloadable document.
apps/…/story-rendering.tsxShows how parsed content becomes text, charts, tables, maps, and grids.
apps/…/story-tabs-bar.tsxShows how authors organize, reorder, and move content across story tabs.
apps/…/story-theme-settings.tsxShows how administrators generate, preview, edit, and apply project story themes.
apps/…/owned-story-page.tsxShows the owner view and its link to refresh, edit, share, and preview behavior.
apps/…/shared-story-page.tsxShows shared read access and its refresh and rendering path.
apps/…/story-header-actions.tsxShows story sharing, reuse, favorite, certification, and feedback actions.
apps/…/story-filter-options-select.tsxShows reader filter selection, search, custom values, and dependent option behavior.
apps/…/story-download.tsxShows download access and PDF or HTML delivery for story views.
apps/…/generate.tsDefines how brand sources become a theme pair and how generation limits are reported.
apps/…/story-app-build.tsDefines the build boundary for custom story applications.
apps/…/custom-story.tsDefines custom story versions, query access, saved data, refresh behavior, and viewer limits.
apps/…/custom-story-sql.tsDefines viewer-scoped, read-only SQL actions for custom stories.
apps/…/custom-story-export.tsDefines self-contained custom story documents and the data supplied to exports.
apps/…/custom-story-thumbnail.tsDefines stored and viewer-scoped preview rendering and freshness handling.
apps/…/story-map-boundary.tsDefines how project boundary sets reach interactive and server-rendered maps.
apps/…/story-query.queries.tsDefines the query definitions retained for a story and its versions.
apps/…/story-folder.queries.tsDefines folder trees, private and public placement, archive behavior, and sharing alignment.
apps/…/story-edit-lock.queries.tsDefines the time-bound ownership of a story editing session.
apps/…/story-reference.queries.tsDefines which stories users can reference and how those stories are ordered.
apps/…/story.routes.tsExposes story authoring, organization, refresh, delivery, version, reference, transfer, and download actions for chat and standalone stories.
apps/…/shared-story.routes.tsExposes shared story access, filtered data, custom app data, refresh, and download actions.
apps/…/custom-story-viewer.routes.tsExposes custom story viewing through shared-chat and replay access.
apps/…/standalone-custom-story.routes.tsExposes owner access to custom stories without a source chat.
apps/…/story-delivery.service.tsDefines recurring story delivery and schedule rules.
apps/…/shared-story.service.tsDefines the relationship between sharing, privacy, and delivery teardown.