Skip to main content

Pages

A page is a small HTML page in your workspace that LocalAI shows as part of its UI. The assistant writes one when you ask (“make me a task board”), or you write it yourself. A page keeps its data in files next to it, so the assistant can read and change the same data in a chat.

A page runs in a sandboxed frame. It cannot reach the network, the rest of LocalAI, your other files or your other chats. It talks to LocalAI only through a small bridge, window.localai.

Note

Pages need the chats feature and the pages feature. An administrator always has pages. For other users it is off until an administrator switches it on in the user’s permissions (Users, then Pages (HTML pages in the workspace)). When authentication is off, the single user has it. The files of the chats must be on (see Chats).

Where a page lives

A page is a folder of your home:

pages/
  tasks/
    index.html     the page (required, at most 1 MiB)
    page.json      title, icon, description and widget (optional)
    tasks.json     data files of the page, any name, any subfolder
  • The folder name is the page name: lowercase letters, digits and dashes, 1 to 64 characters, starting with a letter or a digit (^[a-z0-9][a-z0-9-]{0,63}$). A folder with another name, or without index.html, is not a page.

  • page.json is optional:

    { "title": "Tasks board", "icon": "list-checks", "description": "What I do this week" }

    A missing or broken page.json does not stop the page; the folder name is then the title.

  • A widget block in page.json lets the page be a tile on Home (see A page on Home):

    { "title": "Clock", "widget": { "size": "small", "title": "Now" } }

In the UI

  • Pages in the sidebar opens the list of your pages. The entry shows only when you have at least one page, and the first time it appears it carries a small New label, until you open it or for a week (switch it off with Notes about new things in Account). Pinned pages show under it.
  • The list groups your pages under Yours. Each row shows the title, the description, the folder and when the page changed last and who wrote it (you or the assistant), with Open, a pin toggle (Pin to sidebar) and a menu: Open in dock (a new chat with the page beside it, see The dock), Ask the assistant to change this (a new chat with the page’s path in the message box), Show its files (the folder in Files), Rename (moves the folder) and Delete page (moves the folder to the Trash, where Files can restore it). Above eight pages, a filter field shows over the list. Ask for a new page opens a chat with “Make me a page that " in the message box.
  • With no pages, the screen offers Ask for a page, and Start from a task board or Start from a reading list, which copy a starter page into pages/task-board/ or pages/reading-list/. The copy is yours; ask the assistant to change it. Two starter pages ship with LocalAI: a task board (task-board, data in tasks.json) and a reading list (reading-list, data in reading.json). Home offers both under Or start from a ready page.
  • Open a page to see it at /app/pages/<name>. The strip above it says that the page runs as you, when and by whom it was last updated, and has Reload and Ask the assistant to change this. When the assistant changes index.html, the page reloads. When only a data file changes, the page gets a files.changed event and stays as it is. Switching between the light and dark theme reloads the page too: it gets the theme as data-theme on its <html> element.
  • Pins are kept in LocalAI/ui.json of your home, under pinnedPages (a list of page names). A pin or unpin keeps every other key of the file.
  • The first pinned page is your start page: the sidebar marks it with a Start page label (see A start page).

How the assistant makes a page

Ask in a chat, for example “Make me a page with a reading list in pages/reading/”. The assistant writes pages/reading/index.html and a data file with its file tools. The page shows up under Pages as soon as the change is saved. To change a page, open it and use Ask the assistant to change this.

One index.html with inline script and style is the simplest page. A page can also keep its script, style sheets, modules, small images and data in files next to it (see Files next to the page). A form cannot be submitted in the sandbox, so a page handles the click of a button and the Enter key itself.

The bridge

Inside the frame, window.localai has these calls. Each returns a promise. A path is relative to the page’s own folder.

CallResult
localai.files.read(path){path, content, version, size}. Text files only (UTF-8), at most 1 MiB. A failed call rejects with an error that has status (404 for a missing file, 413, 415).
localai.files.write(path, content, {base}){path, version, size, conflict_of}. Creates missing folders. Without base the file is replaced. With base (the version you read), a file that changed since is kept and your content goes to a conflict copy, named in conflict_of.
localai.files.list(dir)[{path, kind, size, version}]. dir is optional; the default is the page’s folder.
localai.chat.send(text){sent: true, chat_id} or {sent: false}. See below.
localai.on('files.changed', fn)Calls fn({paths}) when files of the page’s folder change. paths are relative to the folder. When LocalAI cannot tell what changed (for example after the window was in the background), fn gets {paths: [], resync: true}: read again what you show. Returns a function that removes the listener.
localai.on('visibility', fn)Calls fn({visible}) when the page goes out of sight (the tab is hidden, or its tile on Home scrolled away) and when it comes back. Pause timers and animations while visible is false.
localai.on('mode', fn)Calls fn({mode, size}) when a tile changes size without a reload: a tile in a slot that opens as a card, and back. localai.page and the data-mode and data-size attributes of <html> change first.
localai.page.resize(height)Asks for a height in pixels. Only the page area of Home uses it (see the page area); elsewhere it resolves to {height: null}. Without height, the bridge measures the document (the box of <html>). Resolves to {height}, the height after the limits.
localai.page{name, title, mode, size} of the page. mode is page in the full view and in the dock, widget in a tile, and area in the page area of Home; size is the tile’s size (compact, small, medium, large), empty in the full view, the dock and the page area. The page cannot set them.

Example: a counter that keeps its value in count.json.

<!doctype html>
<button id="b">Count</button>
<script>
  let count = 0
  const b = document.getElementById('b')
  const show = () => { b.textContent = 'Count: ' + count }
  localai.files.read('count.json')
    .then(f => { count = JSON.parse(f.content).count })
    .catch(() => {})   // no file yet
    .finally(show)
  b.onclick = () => {
    count++
    show()
    localai.files.write('count.json', JSON.stringify({ count }))
  }
  localai.on('files.changed', ev => {
    if (ev.paths.includes('count.json')) {
      localai.files.read('count.json').then(f => { count = JSON.parse(f.content).count; show() })
    }
  })
</script>

Your own writes also come back as files.changed. Compare the version you got from write with the one read gives to skip them.

chat.send

chat.send(text) never starts the assistant by itself. LocalAI shows the message above the page with a choice of chat: the page’s own chat (created on first use, titled “Page:”) or one of your recent chats. Nothing is sent until you choose <strong>Send</strong>. The message is then added to the chat as your message, starting with <code>From the page "<title>" (pages/<name>):</code>, so you can see it in the chat before the assistant answers. <strong>Dismiss</strong> resolves the promise with <code>{sent: false}</code>.</p> <p>The page’s own chat is marked as started by a page. Like a chat that a trigger starts, it gets no tool that acts at once and cannot create triggers, because its first message was written by a page and not by you.</p> <p>Tool calls through the bridge are not available.</p> <h2 id="when-a-page-does-not-work">When a page does not work<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>A page that throws an error in its script, or leaves a promise unhandled, shows nothing about it: the assistant cannot run JavaScript, so it could not see the error. LocalAI now keeps the error for it.</p> <ul> <li>The frame of the page catches <code>window.onerror</code> and unhandled rejections and hands them to LocalAI over the bridge. Nothing shows in the page, no badge or button is added, and nothing goes into a chat.</li> <li>When you say a page does not work, the assistant calls its read-only tool <code>page_errors</code> with the page name. The tool gives the message, the line and column when known (the line counts from the top of your <code>index.html</code>), how often it happened and when it last happened. Without a name it lists the pages that have recent errors, newest first. The built-in <code>localai-apps</code> skill tells the assistant to read the error and fix it before it rewrites the page.</li> <li>A page that throws no error but looks wrong has nothing to read. The assistant then asks you what you see.</li> </ul> <p>What is kept:</p> <table> <thead> <tr> <th>Rule</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td>Where</td> <td>On the server, per user and per page name, outside your files. A tile of the page on Home uses the same page name. With a database the errors are in the table <code>studio_page_errors</code>, which every frontend shares; without one, in <code>chats/pages/page-errors.json</code> under the data path.</td> </tr> <tr> <td>Who records</td> <td>Only you, when you view your own page or its tile. A viewer of a shared page records nothing.</td> </tr> <tr> <td>Same error</td> <td>Counted once: same message at the same file, line and column.</td> </tr> <tr> <td>How many</td> <td>The 10 newest different errors of a page.</td> </tr> <tr> <td>Length</td> <td>A message is cut at 500 bytes and a stack at 1500.</td> </tr> <tr> <td>Noise</td> <td>The browser’s own errors, such as <code>ResizeObserver loop</code> and <code>Script error.</code>, are dropped.</td> </tr> <tr> <td>Rate</td> <td>The frame sends an error once and counts repeats, so a throw in a 60 frames per second loop costs a message every few seconds. The server also limits a page to a burst of 20 reports, then one every 2 seconds.</td> </tr> <tr> <td>Cleared</td> <td>When any file of the page changes (a data file the page saves counts too), so the assistant never reads the error of code that is gone.</td> </tr> </tbody> </table> <p>An error message can quote data of your page. The server never writes it to a log. The assistant reads it only when it calls <code>page_errors</code>, and the tool result says that the text is data and not instructions.</p> <p>The sandbox is as before: the frame has no network and no new right. A page cannot read the errors back, and it cannot stop the capture.</p> <h2 id="files-next-to-the-page">Files next to the page<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>A page can name the files of its own folder with relative URLs, as a web page does. Before the page runs, LocalAI reads them with your rights and puts them into the page; while it runs, <code>fetch</code> and <code>XMLHttpRequest</code> read the folder.</p> <table> <thead> <tr> <th>In the page</th> <th>What happens</th> </tr> </thead> <tbody> <tr> <td><code>fetch('data.json')</code>, <code>fetch('./data/x.json?v=2')</code></td> <td>Reads the file with <code>files.read</code>. The answer is a real <code>Response</code>: <code>200</code> with the text and a <code>content-type</code> from the extension, or <code>404</code> for a missing file (also <code>413</code> and <code>415</code>). <code>GET</code> and <code>HEAD</code> only.</td> </tr> <tr> <td><code>XMLHttpRequest</code></td> <td>The same, asynchronous only, <code>responseType</code> <code>''</code>, <code>text</code>, <code>json</code>, <code>arraybuffer</code> or <code>blob</code>.</td> </tr> <tr> <td><code><script src="app.js"></code></td> <td>The script goes into the page at the same place. With <code>defer</code> or <code>async</code>, it goes to the end of the body.</td> </tr> <tr> <td><code><link rel="stylesheet" href="style.css"></code></td> <td>Goes in as a <code><style></code>, with its relative <code>@import</code> and <code>url()</code>.</td> </tr> <tr> <td><code><script type="module" src="main.js"></code>, <code>import './lib/x.js'</code>, <code>import('./x.js')</code></td> <td>The modules of the folder load from <code>blob:</code> URLs behind an import map. Cycles work. Only string specifiers that start with <code>./</code> or <code>../</code>.</td> </tr> <tr> <td><code><img src="logo.png"></code>, <code><source></code>, <code><video poster></code>, CSS <code>url()</code></td> <td>Images (png, jpg, gif, webp, avif, bmp, ico, svg) go in as <code>data:</code> URLs.</td> </tr> </tbody> </table> <p>What does not work:</p> <ul> <li>The network: an <code>http:</code>, <code>https:</code> or <code>//host</code> URL. <code>fetch</code> rejects with <code>TypeError: network is off in pages; put the data in a file next to the page</code>; a script, style sheet or image with such a URL stays blocked by the policy.</li> <li>Files outside the page’s folder: <code>../</code>, an absolute path, <code>%2e%2e/</code>, a backslash. They are never read.</li> <li>Packages (<code>import 'react'</code>), fonts from files, audio and video files, and binary files through <code>fetch</code> (the bridge reads UTF-8 text only).</li> <li>Writes through <code>fetch</code>: save with <code>localai.files.write</code>.</li> </ul> <p>The files that go into the page are at most 4 MiB in all, and the images at most 2 MiB. A script, style sheet or module that does not load (missing, outside the folder, too large) shows a short notice at the bottom of the page and a message in the browser console; an image that does not load gives only the console message. When one of the files that went in changes, the page reloads, as it does when <code>index.html</code> changes. Data read with <code>fetch</code> does not reload the page: listen to <code>files.changed</code>.</p> <h2 id="links">Links<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>A page cannot open a window or leave its frame. A click on a link to an <code>http</code> or <code>https</code> address (also with Ctrl, Cmd or the middle button, or the Enter key) and <code>window.open(url)</code> ask LocalAI instead: a bar above the page shows the site, the whole address and <strong>Open</strong> and <strong>Cancel</strong>. <strong>Open</strong> opens the address in a new tab with <code>noopener</code> and <code>noreferrer</code>; <strong>Cancel</strong> does nothing. When the host is in punycode (letters of other alphabets, such as <code>xn--pple-43d.com</code>), the bar also says how it reads (<code>аpple.com</code>), since it may imitate another site.</p> <ul> <li>A link to <code>#id</code> scrolls the page to that element.</li> <li>A link to a file of the page (<code>other.html</code>) opens nothing; the console says why.</li> <li><code>javascript:</code>, <code>data:</code>, <code>file:</code>, <code>blob:</code> and <code>//host</code> links and addresses with a user name or password are refused, with a message in the console.</li> <li>The bar shows one link: a new one replaces it. A page asks at most 5 links at once, then one every 3 seconds.</li> </ul> <p><code>window.open</code> returns <code>null</code> in a page.</p> <h2 id="a-page-that-starts-a-run">A page that starts a run<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>A page cannot call the assistant on its own, but it can write files, and a <a href="/docs/features/chats-agents/index.html#triggers">file trigger</a> can watch a folder of the page. Each file the page writes there starts a run, which answers by writing a file the page reads back.</p> <ol> <li>The assistant makes the folder <code>pages/ask/requests/</code> (a trigger needs a folder that exists) and proposes a trigger: <code>{"when": {"file_arrives_in": "/pages/ask/requests"}, "prompt": "Read the request file named in this message, do what it asks, and write the answer to pages/ask/answers.json.", "writes": "pages/ask/answers.json"}</code>. You confirm it on its card.</li> <li>The page writes a request: <code>localai.files.write('requests/' + Date.now() + '.json', JSON.stringify({text}))</code>.</li> <li>The page listens for the answer: <code>localai.on('files.changed', (ev) => { if (ev.paths.includes('answers.json')) show() })</code>.</li> </ol> <p>Every request is one run, so it costs tokens. A page cannot start runs in a loop: a file waits until it has not changed for 30 seconds, a file that changes again after a run began waits for the trigger’s minimum gap (one minute by default), the run’s own writes start nothing, and the trigger has a daily limit (24 runs by default). The bridge also limits writes (below).</p> <h2 id="a-page-on-home">A page on Home<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>A page with a <code>widget</code> block in its <code>page.json</code> can also be a tile on Home. The tile runs the same page, in the same sandbox and with the same bridge, but in its compact mode: <code>localai.page.mode</code> is <code>widget</code>, and <code><html></code> has <code>data-mode="widget"</code> and <code>data-size="small|medium|large"</code>, so a style sheet can switch layout without script. The page decides how its tile looks; LocalAI does not shrink the full page.</p> <table> <thead> <tr> <th>Field</th> <th>Meaning</th> </tr> </thead> <tbody> <tr> <td><code>widget.size</code></td> <td>The size of the tile when <code>home.json</code> gives the widget no <code>size</code>: <code>small</code> (one column, one row unit: a line or a number), <code>medium</code> (two columns and rows: a short list) or <code>large</code> (the full row, three row units: a table or a chart). Any other value is <code>medium</code>.</td> </tr> <tr> <td><code>widget.title</code></td> <td>The title of the tile, when it should be shorter than the page’s.</td> </tr> <tr> <td><code>widget.compact</code></td> <td><code>true</code>, or <code>{"width": 160}</code>: the page also has a layout for a slot (see <a href="/docs/features/pages/index.html#a-page-in-a-slot">A page in a slot</a>). The width is in CSS pixels, 72 to 220 (120 by default); a value outside is clamped.</td> </tr> </tbody> </table> <p>A page without a <code>widget</code> block cannot be a tile. To put a page on Home, add the block and a widget <code>{"id": "clock", "type": "page", "page": "clock"}</code> to <code>LocalAI/home.json</code> (or pick the page in <strong>Customise Home</strong>, or ask the assistant to “put it on Home”). A page of a shared folder also has <code>"folder": <folder_id></code>. Home shows at most three page tiles.</p> <p>A small clock that is a full page in its own view and one line on Home:</p> <div class="highlight actionbar-wrapper wrap-code" dir="auto"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-html" data-lang="html"><span style="display:flex;"><span><span style="color:#75715e"><!doctype html></span> </span></span><span style="display:flex;"><span><<span style="color:#f92672">style</span>> </span></span><span style="display:flex;"><span> <span style="color:#f92672">body</span> { <span style="color:#66d9ef">font</span>: <span style="color:#ae81ff">15</span><span style="color:#66d9ef">px</span> system-ui, <span style="color:#66d9ef">sans-serif</span>; <span style="color:#66d9ef">margin</span>: <span style="color:#ae81ff">0</span>; <span style="color:#66d9ef">padding</span>: <span style="color:#ae81ff">24</span><span style="color:#66d9ef">px</span>; } </span></span><span style="display:flex;"><span> #time { <span style="color:#66d9ef">font-size</span>: <span style="color:#ae81ff">64</span><span style="color:#66d9ef">px</span>; } </span></span><span style="display:flex;"><span> :<span style="color:#a6e22e">root</span><span style="color:#f92672">[</span><span style="color:#f92672">data-mode</span><span style="color:#f92672">=</span><span style="color:#e6db74">"widget"</span><span style="color:#f92672">]</span> <span style="color:#f92672">body</span> { <span style="color:#66d9ef">padding</span>: <span style="color:#ae81ff">12</span><span style="color:#66d9ef">px</span> <span style="color:#ae81ff">16</span><span style="color:#66d9ef">px</span>; } </span></span><span style="display:flex;"><span> :<span style="color:#a6e22e">root</span><span style="color:#f92672">[</span><span style="color:#f92672">data-mode</span><span style="color:#f92672">=</span><span style="color:#e6db74">"widget"</span><span style="color:#f92672">]</span> #time { <span style="color:#66d9ef">font-size</span>: <span style="color:#ae81ff">28</span><span style="color:#66d9ef">px</span>; } </span></span><span style="display:flex;"><span> :<span style="color:#a6e22e">root</span><span style="color:#f92672">[</span><span style="color:#f92672">data-mode</span><span style="color:#f92672">=</span><span style="color:#e6db74">"widget"</span><span style="color:#f92672">]</span> .<span style="color:#a6e22e">more</span> { <span style="color:#66d9ef">display</span>: <span style="color:#66d9ef">none</span>; } </span></span><span style="display:flex;"><span></<span style="color:#f92672">style</span>> </span></span><span style="display:flex;"><span><<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">"time"</span>></<span style="color:#f92672">div</span>> </span></span><span style="display:flex;"><span><<span style="color:#f92672">p</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">"more"</span>>The time where you are. On Home, only the time shows.</<span style="color:#f92672">p</span>> </span></span><span style="display:flex;"><span><<span style="color:#f92672">script</span>> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">el</span> <span style="color:#f92672">=</span> document.<span style="color:#a6e22e">getElementById</span>(<span style="color:#e6db74">'time'</span>) </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">let</span> <span style="color:#a6e22e">timer</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">tick</span> <span style="color:#f92672">=</span> () => { <span style="color:#a6e22e">el</span>.<span style="color:#a6e22e">textContent</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> Date().<span style="color:#a6e22e">toLocaleTimeString</span>() } </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">start</span> <span style="color:#f92672">=</span> () => { <span style="color:#a6e22e">tick</span>(); <span style="color:#a6e22e">timer</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">setInterval</span>(<span style="color:#a6e22e">tick</span>, <span style="color:#ae81ff">1000</span>) } </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">start</span>() </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">localai</span>.<span style="color:#a6e22e">on</span>(<span style="color:#e6db74">'visibility'</span>, ({ <span style="color:#a6e22e">visible</span> }) => { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">clearInterval</span>(<span style="color:#a6e22e">timer</span>) </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">visible</span>) <span style="color:#a6e22e">start</span>() </span></span><span style="display:flex;"><span> }) </span></span><span style="display:flex;"><span></<span style="color:#f92672">script</span>></span></span></code></pre></div> <p>The tile has a bar with the page’s icon and title, <strong>Open page</strong> and a refresh button. Its frame is made only when the tile scrolls into view, and it is taken down when the tile is far off screen; nearer, or in a hidden tab, the page gets <code>visibility</code> <code>false</code> and should pause. A tile counts toward the eight live frames of the app (see <a href="/docs/features/pages/index.html#live-frames-and-the-budget-of-a-tile">Live frames and the budget of a tile</a>). The height of each tile is fixed by its size, so nothing moves when a page loads. A tile reads its data as the full page does, with <code>fetch</code> or <code>localai.files.read</code>, and <code>files.changed</code> keeps it live.</p> <p>In a tile, a link of the page asks before it opens, as in the full view. <code>chat.send</code> is refused: open the page to send a message. When a page is gone, cannot be read, or has no <code>widget</code> block, the tile says so with a link to <strong>Customise Home</strong>. A shared page needs your consent first: the tile shows <strong>Allow this page</strong>, which opens the trust sheet with <strong>Allow on Home, in slots and in the dock</strong> (see <a href="/docs/features/pages/index.html#shared-pages-in-a-slot-and-on-home">Shared pages in a slot and on Home</a>).</p> <h2 id="a-page-in-a-slot">A page in a slot<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>The slots of <code>LocalAI/ui.json</code> (the chat header, the sidebar footer and the composer toolbar, see <a href="/docs/features/make-localai-yours/index.html#slots">Make LocalAI yours</a>) show page tiles. A slot is a strip about 40 px high, so a page runs there only when its widget block has <code>compact</code>: <code><html></code> then has <code>data-size="compact"</code> and <code>localai.page.size</code> is <code>compact</code>. Draw one short line: a value and a word.</p> <div class="highlight actionbar-wrapper wrap-code" dir="auto"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{ <span style="color:#f92672">"title"</span>: <span style="color:#e6db74">"Weather"</span>, <span style="color:#f92672">"widget"</span>: { <span style="color:#f92672">"size"</span>: <span style="color:#e6db74">"medium"</span>, <span style="color:#f92672">"compact"</span>: { <span style="color:#f92672">"width"</span>: <span style="color:#ae81ff">140</span> } } }</span></span></code></pre></div> <div class="highlight actionbar-wrapper wrap-code" dir="auto"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-css" data-lang="css"><span style="display:flex;"><span>:<span style="color:#a6e22e">root</span><span style="color:#f92672">[</span><span style="color:#f92672">data-size</span><span style="color:#f92672">=</span><span style="color:#e6db74">"compact"</span><span style="color:#f92672">]</span> .<span style="color:#a6e22e">full</span> { <span style="color:#66d9ef">display</span>: <span style="color:#66d9ef">none</span>; } </span></span><span style="display:flex;"><span>:<span style="color:#a6e22e">root</span><span style="color:#f92672">[</span><span style="color:#f92672">data-size</span><span style="color:#f92672">=</span><span style="color:#e6db74">"compact"</span><span style="color:#f92672">]</span> .<span style="color:#a6e22e">strip</span> { <span style="color:#66d9ef">display</span>: <span style="color:#66d9ef">flex</span>; <span style="color:#66d9ef">height</span>: <span style="color:#ae81ff">32</span><span style="color:#66d9ef">px</span>; <span style="color:#66d9ef">align-items</span>: <span style="color:#66d9ef">center</span>; }</span></span></code></pre></div> <p>A click on the tile opens it as a card under the tile (above it in the sidebar and the message box), at the size of <code>widget.size</code>. The card is the same frame in a bigger box: the bridge sends <code>mode</code> with the new size and the page keeps its state; it is never reloaded. Escape, a click outside or the close button puts it back in the strip. The card has the page’s title, <strong>Open</strong>, and the line “Sandboxed, no network”. In the strip the page is shown, not used: a click opens the card. A page without <code>compact</code> is a button that opens the page: in the dock beside the chat while a chat is open (see <a href="/docs/features/pages/index.html#the-dock">The dock</a>), in the page view anywhere else. <strong>Open</strong> of a card does the same.</p> <p>A tile in a slot reads its data as the full page does, and <code>files.changed</code> keeps it live. <code>chat.send</code> is refused in a tile. A link asks before it opens.</p> <h3 id="live-frames-and-the-budget-of-a-tile">Live frames and the budget of a tile<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h3> <p>The app keeps at most eight page frames running at once, for the page area and the tiles on Home, the tiles in the slots and the page in front of the dock together. A tile that gets none shows as a card with <strong>Run</strong>; a click runs it and stops the frame that started first, which then shows as a card. When a tile goes away, the next waiting tile runs.</p> <p>A tile runs without a click, so it has a budget, and so does the page in the dock. Its bridge sends a beat about once a second with the time the page kept the browser busy since the last one (its long tasks, and how late the beat’s timer fired). LocalAI stops the frame and shows <strong>Reload</strong> when:</p> <table> <thead> <tr> <th>Reason</th> <th>Limit</th> </tr> </thead> <tbody> <tr> <td>The page keeps the browser busy</td> <td>more than 3 seconds of work within 10 seconds</td> </tr> <tr> <td>The page stops answering while it is in sight</td> <td>no beat for 5 seconds</td> </tr> <tr> <td>The page does not start</td> <td>no first beat within 10 seconds</td> </tr> </tbody> </table> <p>The page area of Home is watched the same way, but it must show its first beat within 5 seconds of its start, and a failure shows the tile of <a href="/docs/features/pages/index.html#when-the-page-does-not-load">the page area</a> instead of <strong>Reload</strong> in a card.</p> <p>A tile out of sight (a hidden tab, a tile scrolled away) is not watched, because the browser slows its timers. Reload is manual: there is no retry loop. The full page view has no budget. The browser decides how much a frame can do before LocalAI can stop it; a frame that blocks the browser completely is stopped only when it answers again.</p> <h3 id="shared-pages-in-a-slot-and-on-home">Shared pages in a slot and on Home<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h3> <p>A shared page on Home, in a slot or in the dock starts as soon as the screen shows, so allowing it to open is not enough: its tile shows <strong>Allow</strong> and the trust sheet offers <strong>Allow on Home, in slots and in the dock</strong>. That consent is kept against the hash of the page like <strong>Allow</strong>, so a change of its code asks again, and <strong>Stop allowing this page</strong> removes both. <strong>Allow once</strong> runs the tile for this visit only.</p> <h2 id="a-page-in-the-page-area-of-home">A page in the page area of Home<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p><code>LocalAI/home.json</code> can name one page that fills a full-width area on Home, below the greeting, the composer and the shortcut chips and above the widgets:</p> <div class="highlight actionbar-wrapper wrap-code" dir="auto"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{ <span style="color:#f92672">"pageArea"</span>: <span style="color:#e6db74">"today"</span> }</span></span></code></pre></div> <p><code>pageArea</code> is the name of one of your pages, <code>{"page": "today", "folder": 3}</code> for a page of a shared folder (<code>folder</code> is the <code>folder_id</code> of the shared pages list), or <code>null</code> (or no key) for no page area. Unlike a tile, the page needs no <code>widget</code> block. Pick it in <strong>Edit layout</strong> on Home, under <strong>Page area</strong>, or ask the assistant. The save is a normal change set, so it shows in the history and can be reverted.</p> <p>The page runs in the same sandbox, with the same bridge and the same budget as a tile. It hears <code>localai.page.mode</code> <code>area</code> (and <code><html data-mode="area"></code>) and has no <code>size</code>: the area is the full width of Home. It is 240 px high until the page says how high it is, and stays so for a page that never does; the page scrolls inside it. To fit the area to its content, the page calls <code>localai.page.resize()</code> when its content changes:</p> <div class="highlight actionbar-wrapper wrap-code" dir="auto"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#66d9ef">new</span> <span style="color:#a6e22e">ResizeObserver</span>(() => <span style="color:#a6e22e">localai</span>.<span style="color:#a6e22e">page</span>.<span style="color:#a6e22e">resize</span>()).<span style="color:#a6e22e">observe</span>(document.<span style="color:#a6e22e">body</span>)</span></span></code></pre></div> <p>The area follows, never lower than 160 px or higher than about 60% of the window: a longer page scrolls inside. LocalAI applies at most four heights a second (the last one asked), ignores a change of a few pixels and never reloads the frame for it. A page whose <code><html></code> or <code><body></code> fills the frame (<code>height: 100%</code>) measures the frame, not its content: pass the height of its content, <code>localai.page.resize(el.offsetHeight)</code>. The frame is clipped to the area, so a page cannot cover the strip, the composer or the widgets. <code>chat.send</code> is refused, because the composer is on the same screen. The area counts toward the eight live frames of the app. A shared page asks first, like a shared page on Home: the area shows <strong>Allow this page</strong> until you allow it.</p> <p>LocalAI draws a thin strip above the page: its name, who made it (<strong>Page by the assistant</strong>, <strong>Page by you</strong> or <strong>Page shared by</strong> an author), <strong>Runs as you</strong>, <strong>Reload</strong> and <strong>Edit</strong>, which opens a chat that asks the assistant to change the page. The page cannot change the strip.</p> <h3 id="when-the-page-does-not-load">When the page does not load<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h3> <p>Only the area is replaced: the composer and the widgets keep working. LocalAI shows <strong>This page did not load.</strong> with the reason when:</p> <table> <thead> <tr> <th>Reason</th> <th>What LocalAI saw</th> </tr> </thead> <tbody> <tr> <td>The page is missing</td> <td>the page was moved, deleted, or you cannot open it any more</td> </tr> <tr> <td>The value is not a page</td> <td><code>pageArea</code> in <code>home.json</code> is not a page name</td> </tr> <tr> <td>A script error</td> <td>the script threw before the page’s first beat</td> </tr> <tr> <td>No first paint</td> <td>no first beat from the page within 5 seconds</td> </tr> <tr> <td>It was stopped</td> <td>the budget of a tile (busy, no answer) or an attempt to leave its frame</td> </tr> </tbody> </table> <p>LocalAI decides from what it sees (the read of the page, the load of the frame, the beat of the bridge and a timer), never from what the page says about itself. The tile offers <strong>Revert</strong>, <strong>Open the file</strong> and <strong>Remove from Home</strong>. <strong>Revert</strong> undoes the last change of the page’s folder, or the last change of <code>home.json</code> when the value is not a page name; it is not offered for a shared page, which is not your file. <strong>Remove from Home</strong> writes <code>"pageArea": null</code>. Both are change sets, so the assistant sees them and you can undo them. There is no retry loop: <strong>Reload</strong> in the strip starts the page again.</p> <p>An administrator can switch the page area off for everyone (the <code>home_page_area_enabled</code> <a href="/docs/features/runtime-settings/">runtime setting</a>). The area then shows a note that says so, and the server leaves <code>pageArea</code> out of the <code>home.json</code> it serves (<code>GET /api/chats/wellknown/home</code> names it in <code>withheld</code>). The file keeps its value: a write of the whole file that does not name <code>pageArea</code> keeps it too, so the page comes back when the area is on again.</p> <h2 id="a-start-page">A start page<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>The first entry of <code>pinnedPages</code> in <code>LocalAI/ui.json</code> is your start page. It has its own screen, the page view at <code>/app/pages/<name></code>, and a <strong>Start page</strong> label in the sidebar. The Home route does not change. The strip of the page view has a switch, <strong>Make this my first pinned page</strong>: turning it on pins the page if needed and moves it to the top of the pinned list, and turning it off moves it behind the other pins, so the next pin becomes the start page. The change keeps the other pins, and every other key of the file.</p> <h2 id="the-dock">The dock<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>The dock is a panel beside a chat that shows one or more pages in tabs, so you can talk about a page while you see it. There is no dock until something opens one. A page gets into the dock in four ways:</p> <ul> <li><strong>Dock</strong> in the chat header, or Ctrl+\ (Cmd+\ on a Mac), shows and hides the dock. An empty dock, and the <strong>+</strong> of the tabs, list your pages and the shared pages to open. The <strong>+</strong> always opens that list for a new tab and puts the focus on its first page; a page of the list opens as a tab and closes the list, and Escape or the tab in front goes back to the page.</li> <li><strong>Open in dock</strong> on the Pages list starts a new chat with the page beside it.</li> <li>A page button in a slot, and <strong>Open</strong> of a compact tile’s card, open the page in the dock of the open chat.</li> <li>The assistant opens a page of your home with its <code>open_page</code> tool, for example after it wrote the page you asked for. It does not ask first: the page runs as you anyway when you open it. It refuses a page of a shared folder, which needs your consent in the dock first.</li> </ul> <p>The strip under the tabs says where the page comes from (<strong>Page by the assistant</strong>, <strong>Page by you</strong> or the shared folder) and that it <strong>Runs as you</strong>. <strong>Ask the assistant to change this</strong> puts a request that names the page in the message box; nothing is sent until you send it. The bar has <strong>Reload</strong>, a link to the full page and a button that hides the dock. The footer says <strong>Live: updates as files change</strong> and <strong>Sandboxed, no network</strong>.</p> <p>The dock and the Files pane of the chat share the right side, one at a time. <strong>Files</strong> and <strong>Dock</strong> are two buttons next to each other in the chat header: opening one hides the other, and a file the assistant writes never takes the side from an open dock (the count on <strong>Files</strong> still grows). In a window under 1280 px, while the dock is open, both buttons show only their icon.</p> <p>Each chat keeps its own dock: the open pages, the page in front, whether the dock shows and its width are stored with the chat on the server, so a reload, another browser and another LocalAI frontend of the same cluster show the same dock. A new chat keeps its dock until its first message creates the chat.</p> <p>Drag the left edge of the dock to change its width: at least 320 px and at most 60% of the window. A double click resets it to 452 px. With the edge focused, the arrow keys move it (Shift for bigger steps), Home and End go to the bounds and Enter resets it. The thread, the chat header and the message box narrow for the dock; it covers none of them. On a phone the dock is a bottom sheet that stops under the chat header: drag its handle up for full screen and down to close, or tap it to switch between the two heights.</p> <p>A docked page runs in the same sandbox as everywhere, with the same bridge and the same budget as a tile (see <a href="/docs/features/pages/index.html#live-frames-and-the-budget-of-a-tile">Live frames and the budget of a tile</a>). The page in front counts toward the eight live frames of the app. A page you open takes a frame at once and stops the frame that started first; a page that comes back with a reload waits for a free one and shows <strong>Run it here</strong> until then. <code>localai.page.mode</code> is <code>page</code>, as in the full view, with no <code>size</code>. <code>chat.send</code> from a docked page shows the message in the dock; it goes to this chat, as your message, only when you press <strong>Send</strong>. The message lies over the top of the page, so the page does not move, and <strong>Send</strong> works half a second after it shows. A page that asks more than 3 times at once waits, as in <a href="/docs/features/pages/index.html#limits">Limits</a>. A shared page runs in the dock only after you allowed it on Home, in the slots and in the dock (<strong>Allow on Home, in slots and in the dock</strong>), because the dock starts it again without a click after a reload.</p> <h2 id="limits">Limits<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <table> <thead> <tr> <th>Limit</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td><code>index.html</code></td> <td>1 MiB</td> </tr> <tr> <td>A file that the bridge reads or writes</td> <td>1 MiB, UTF-8 text</td> </tr> <tr> <td>Files put into the page (scripts, styles, modules, images)</td> <td>4 MiB in all, images 2 MiB</td> </tr> <tr> <td>Path</td> <td>256 bytes, 8 folders deep</td> </tr> <tr> <td>Writes</td> <td>20 at once, then one every 2 seconds, per page</td> </tr> <tr> <td><code>chat.send</code></td> <td>3 at once, then one every 20 seconds, per page; 4000 characters</td> </tr> <tr> <td>Pages in a listing</td> <td>200</td> </tr> </tbody> </table> <p>A page writes data files only. A write of a code or document file is refused with the error code <code>forbidden</code> and the message “a page can write data files only (such as .json or .txt); ask the assistant to change the code of the page”. That covers the extensions <code>.js</code>, <code>.mjs</code>, <code>.cjs</code>, <code>.css</code>, <code>.html</code>, <code>.htm</code>, <code>.svg</code>, <code>.xml</code>, <code>.xhtml</code> and <code>.wasm</code> (in any case, in the page’s folder and its subfolders), a file named <code>index</code> and <code>page.json</code>. Because a page loads its own scripts and styles, a page that could rewrite them would run new code on the next load. The server enforces this on the page’s bridge; you and the assistant write the same files through the Files page and the file tools. A shared page follows the same rule, and a consent is kept against the code you allowed, which a page cannot change. Debounce writes in a page that saves while the user types.</p> <p>The rate limits are kept by each frontend. With several frontends, a page gets one budget on each. They protect against a page that loops, not against a person.</p> <h2 id="the-sandbox">The sandbox<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <ul> <li> <p>The frame is <code><iframe sandbox="allow-scripts"></code> without <code>allow-same-origin</code>. The page has an opaque origin: it cannot read LocalAI’s cookies, storage or DOM, cannot navigate the LocalAI window, open pop-ups or submit forms.</p> </li> <li> <p>The page is loaded with this content security policy in front of its own markup:</p> <pre><code>default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; font-src data:; connect-src 'none'; frame-src 'none'; form-action 'none'; base-uri 'none'; object-src 'none'</code></pre> <p>The network is blocked for <code>fetch</code>, <code>XMLHttpRequest</code>, WebSocket, external scripts, styles, fonts and images, and nested frames. Images work as <code>data:</code> URLs. Links open only after you confirm them (see <a href="/docs/features/pages/index.html#links">Links</a>). A page with ES modules of its folder also has <code>blob:</code> in <code>script-src</code>: its modules load from <code>blob:</code> URLs that the frame makes itself, which reach no network. <code>fetch</code> and <code>XMLHttpRequest</code> of the page are replaced by the bridge reads of <a href="/docs/features/pages/index.html#files-next-to-the-page">Files next to the page</a>.</p> </li> <li> <p>A page can still navigate its own frame to another address. LocalAI sees the second load, closes the bridge and shows “The page tried to open another address” with <strong>Reload</strong>. The request of that navigation has left the browser by then, so do not run a page you do not trust with data you would not share.</p> </li> <li> <p>The bridge is a <code>MessageChannel</code> that LocalAI hands to the frame when it loads. Every call is checked by the server with your rights: a path that leaves the page’s folder (<code>..</code>, an absolute path, a backslash, a control character) is refused. The workspace has no symbolic links, so a link cannot lead out of the folder either.</p> </li> <li> <p>A page runs as you: what it writes is saved as your change, and shows in the file history as “Page <name>: save <file>”. Undo works as for any other change.</p> </li> </ul> <h2 id="shared-pages">Shared pages<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>A shared folder is a folder outside your home that an administrator gave you access to, read-only or read-write (a workspace grant). An administrator creates the shared folders and chooses their members in the <strong>Shared</strong> tab of <strong>Files</strong> or through the API (see <a href="/docs/features/chats/#shared-folders">Shared folders</a>). Its pages are the folders <code>pages/<name>/</code> with an <code>index.html</code>, as in your home. They show on the Pages screen under <strong>Shared with you</strong>, with their author (the account that last wrote <code>index.html</code>), the folder, and a badge: <strong>Not allowed yet</strong>, <strong>Changed since you allowed it</strong> or <strong>Allowed</strong>. A user without a grant on the folder sees nothing of it.</p> <p>A shared page runs as you, so it runs only after you allow it. Opening one the first time shows a sheet that says who wrote it, where it lives, what it can do (read and write files in its own folder, write a message into a chat that you see before the assistant answers), what it cannot do (read your other files or chats, reach the network, use tools or change your settings), and one limit of the sandbox in plain words: a page can load another address in its own frame, which sends one request out before the page stops. <strong>Cancel</strong> has the focus; Escape is Cancel. <strong>View source</strong> shows <code>index.html</code> as text.</p> <table> <thead> <tr> <th>Choice</th> <th>Result</th> </tr> </thead> <tbody> <tr> <td><strong>Allow</strong></td> <td>Kept for this version of this page. It runs now and each time you open it.</td> </tr> <tr> <td><strong>Allow once</strong></td> <td>It runs for this visit. You are asked again next time. A visit ends after 12 hours.</td> </tr> <tr> <td><strong>Allow on Home, in slots and in the dock</strong></td> <td>Shown by a tile on Home or in a slot, the page area and the dock. Kept for this version, and it also lets the page run there without a click.</td> </tr> <tr> <td><strong>Cancel</strong></td> <td>Nothing runs. The frame says “This page has not run”, with <strong>Review and allow</strong> and <strong>View source</strong>.</td> </tr> </tbody> </table> <p>A consent is kept against the page (the node of its folder, so a rename does not lose it and a page deleted and made again asks again) and the hash of its code: <code>index.html</code>, <code>page.json</code> and the files of code that LocalAI puts into the page: every <code><script src></code>, <code><link rel="stylesheet"></code>, relative CSS <code>@import</code> and ES module import of the folder, followed through the whole module graph (the <code>code_files</code> of the page in the API). A file of code that the page names and that is missing counts too, so adding it later also asks again. When the author changes any of them, the next open asks again and says what changed: the size of each file and the lines of <code>index.html</code>, or which files of code there are when only one of them changed. A page that is open when its author changes it keeps running the version you allowed, and its strip says that it changed, with <strong>Review</strong>; a file of code it then asks for is refused (<code>409</code>), so new code never runs under the old consent. The check ignores the case of the name, as the files do: <code>Index.html</code> or <code>JS/App.js</code> is the same file of code as <code>index.html</code> or <code>js/app.js</code>. The UI puts no text file into a shared page that is not in its <code>code_files</code>.</p> <p>The data files of a page are not in the hash: a page saves them all the time, and images are only pictures. A page whose code reads its data and runs it as code does what its data says; you trust its author for that when you allow it. The files go into the page only after you allow it, with the same consent check as the bridge. To find the files of code, the server reads the page’s markup and modules; each frontend keeps what it found per file content in a small cache, which only saves reads (the same content gives the same files on every frontend).</p> <p>A consent for one page never lets another page run, even one with the same code, and it is yours only. <strong>Stop allowing this page</strong> in the page’s menu revokes it. Every call of a shared page’s bridge checks the consent on the server, so a page that you stop allowing, in this tab or in another one, stops at its next call.</p> <p>A shared page uses the same bridge and limits as your own, with your own grant on the folder: in a folder you can only read, its writes are refused (“you can only read this shared folder”). It reads, writes and lists only its own folder. A message it sends goes to your chat and says which shared page it comes from.</p> <p>The consents are kept on the server, not in your files: the assistant, a page and a trigger run can all write your files, so a consent there could be written by the code it is meant to hold back. With a database (authentication on), they are in the tables <code>studio_page_consents</code> and <code>studio_page_consent_events</code>, which every frontend shares; without one, in <code>chats/pages/consents.json</code> under the data path. Each <strong>Allow</strong>, <strong>Allow once</strong> and revoke is also written to the consent audit (<code>studio_page_consent_events</code>: who, which page and folder, which hash, when) and to the log.</p> <p>An administrator can turn shared pages off at run time with <code>shared_pages_enabled</code> in the <a href="/docs/features/runtime-settings/index.html">runtime settings</a> (or start with <code>LOCALAI_DISABLE_SHARED_PAGES=true</code>). Then the list still shows the pages, dimmed, with “Shared pages are off on this server. An administrator turned them off.”; a page does not open; and the bridge refuses every call, so an open shared page stops at its next call. Revoking a consent still works. The files are kept.</p> <h2 id="api">API<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard" aria-label="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg" aria-hidden="true"></i></button></span></h2> <p>The UI uses these routes. They need the <code>chats</code> and <code>pages</code> features (the dock routes need only <code>chats</code>).</p> <table> <thead> <tr> <th>Route</th> <th>Use</th> </tr> </thead> <tbody> <tr> <td><code>GET /api/chats/pages</code></td> <td>List your pages, each with its <code>widget</code> block when it has one.</td> </tr> <tr> <td><code>GET /api/chats/pages/{name}</code></td> <td>A page with its <code>index.html</code> as <code>html</code>.</td> </tr> <tr> <td><code>GET /api/chats/pages/{name}/files?dir=</code></td> <td><code>files.list</code></td> </tr> <tr> <td><code>GET /api/chats/pages/{name}/file?path=</code></td> <td><code>files.read</code>. With <code>encoding=base64</code> the file must be an image (by extension) and <code>content</code> is its bytes in base64, with <code>media_type</code>. The UI uses it to put images into the page; the bridge reads text only.</td> </tr> <tr> <td><code>PUT /api/chats/pages/{name}/file</code></td> <td><code>files.write</code>, body <code>{path, content, base}</code></td> </tr> <tr> <td><code>POST /api/chats/pages/{name}/chat</code></td> <td><code>chat.send</code> after you chose Send, body <code>{text, chat_id, model}</code></td> </tr> <tr> <td><code>POST /api/chats/pages/{name}/errors</code></td> <td>An error that the script of your own page threw, body <code>{message, stack, file, line, column, count}</code>. The UI sends it; the assistant reads the errors with <code>page_errors</code>. <code>200</code> with <code>recorded</code> (false for browser noise), <code>429</code> when reported too fast. There is no route to read them back and none for shared pages.</td> </tr> <tr> <td><code>GET /api/chats/{id}/dock</code></td> <td>The dock of a chat: <code>{open, tabs: [{page, folder}], active, width}</code>, or <code>null</code>. The chat’s detail (<code>GET /api/chats/{id}</code>) carries it as <code>dock</code>.</td> </tr> <tr> <td><code>PUT /api/chats/{id}/dock</code></td> <td>Replace the dock of a chat: at most 6 tabs, each page once (<code>folder</code> is the <code>folder_id</code> of a shared page, absent for your own), <code>active</code> the index of the tab in front, <code>width</code> 0 (the default) or 320 to 4096. A dock with no tab clears it. <code>400</code> out of bounds, <code>409</code> for a sub-agent run. The chat’s event stream sends <code>dock</code> when it changes.</td> </tr> <tr> <td><code>GET /api/chats/page-starters</code></td> <td>The starter pages.</td> </tr> <tr> <td><code>POST /api/chats/page-starters/{id}/copy</code></td> <td>Copy a starter into <code>pages/</code>.</td> </tr> <tr> <td><code>GET /api/chats/shared-folders</code></td> <td>Your shared folders, with your <code>mode</code> and how many <code>pages</code> each has. <code>folder_id</code> of a shared page is the <code>id</code> of its folder.</td> </tr> <tr> <td><code>GET /api/chats/shared-pages</code></td> <td>The pages of your shared folders: <code>folder</code>, <code>folder_id</code>, <code>author_id</code>, <code>author_name</code>, <code>writable</code>, <code>hash</code>, <code>code_files</code>, <code>widget</code>, <code>consent</code> (<code>none</code>, <code>allowed</code>, <code>changed</code>), and <code>enabled</code>.</td> </tr> <tr> <td><code>GET /api/chats/shared-pages/{folder_id}/{name}</code></td> <td>A shared page with <code>html</code>, <code>lines</code> and <code>consent</code> (<code>state</code>, and for the version you allowed <code>allowed_at</code>, <code>size</code>, <code>meta_size</code>, <code>lines</code>, and <code>embed</code> when you allowed it on Home, in the slots and in the dock).</td> </tr> <tr> <td><code>PUT /api/chats/shared-pages/{folder_id}/{name}/consent</code></td> <td>Allow a version, body <code>{hash, once, embed}</code>. <code>409</code> when the page changed since you read it. A visit (<code>once</code>) answers with a <code>token</code>. <code>embed</code> also allows it on Home, in the slots and in the dock (a lasting consent, so not with <code>once</code>: <code>400</code>); a lasting consent to the same version keeps <code>embed</code>.</td> </tr> <tr> <td><code>DELETE /api/chats/shared-pages/{folder_id}/{name}/consent</code></td> <td>Stop allowing it.</td> </tr> <tr> <td><code>GET .../files</code>, <code>GET</code> and <code>PUT .../file</code>, <code>POST .../chat</code></td> <td>The bridge of a shared page, as above. Each call sends <code>X-LocalAI-Page-Hash</code> (the version that runs) and, for a visit, <code>X-LocalAI-Page-Visit</code>. Without a consent: <code>403 page_not_allowed</code>. A read of a file of code by a frame of an older version: <code>409</code>.</td> </tr> </tbody> </table> <p>With shared pages off, every shared-pages route but the list and the revoke answers <code>403 shared_pages_off</code>.</p> <div class="highlight actionbar-wrapper wrap-code" dir="auto"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>curl -s http://localhost:8080/api/chats/pages -H <span style="color:#e6db74">"Authorization: Bearer </span>$KEY<span style="color:#e6db74">"</span> </span></span><span style="display:flex;"><span><span style="color:#75715e"># {"pages":[{"name":"tasks","path":"/pages/tasks","title":"Tasks board",</span> </span></span><span style="display:flex;"><span><span style="color:#75715e"># "source":"own","author":"assistant","updated_at":"2026-10-29T09:00:00Z",</span> </span></span><span style="display:flex;"><span><span style="color:#75715e"># "updated_by":"you","rev":42,"size":5120}]}</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span>curl -s -X PUT http://localhost:8080/api/chats/pages/tasks/file <span style="color:#ae81ff">\ </span></span></span><span style="display:flex;"><span> -H <span style="color:#e6db74">"Authorization: Bearer </span>$KEY<span style="color:#e6db74">"</span> -H <span style="color:#e6db74">'Content-Type: application/json'</span> <span style="color:#ae81ff">\ </span></span></span><span style="display:flex;"><span> -d <span style="color:#e6db74">'{"path":"tasks.json","content":"[]"}'</span></span></span></code></pre></div> <p>The answers use the error types of the chats API: <code>400</code> for a bad name or path, <code>403</code> when the feature is off or a page tries to write code (anything but a data file), <code>404</code> for a page or file that does not exist (also another user’s), <code>413</code> for a file over 1 MiB, <code>415</code> for a file that is not text and <code>429</code> for too many writes or messages.</p> <footer class="footline"> <i class='fa-fw fas fa-user' aria-hidden="true"></i> <a href="mailto:mudler@localai.io">Ettore Di Giacinto</a> <i class='fa-fw fas fa-calendar-days' aria-hidden="true"></i> 12 Nov 2026 </footer> </article> </div> </main> </div> <script src="/docs/js/theme.min.96b966188f27166ddab5db2863a58101dd099db40ab5513f97556f286504ff8a.js" defer></script> <div id="toast-container" role="status" aria-live="polite" aria-atomic="false"></div> </body> </html>