# AI in Your Documents

> Summarize, proofread, restyle, and write — the AI features that live in the page itself rather than the chat panel.

Source: https://docs.docgraph.app/ai/in-your-documents/

Most of DocGraph's AI lives in the [chat panel](https://docs.docgraph.app/ai/chat/). But a second set of features works directly on the page you're looking at: one **✦ AI** menu in the document toolbar, an AI group in the `/` menu, an AI action on any text you select, and — if you turn it on — a greyed suggestion that appears as you type.

All of it runs on the model you chose in [setup](https://docs.docgraph.app/ai/setup/) — by default one on your own computer — and all of it is invisible until you [turn AI on](https://docs.docgraph.app/ai/setup/). When AI is off, these controls aren't disabled — they simply aren't there.

## Getting there

Open any note. The **✦ AI** button sits in the document toolbar at the top right (its tooltip reads *AI — summarize, check spelling, beautify*). Click it for a menu:

| Menu row | What it does |
|---|---|
| **Summarize this file** | A summary in a popover — never written to the file |
| **Check spelling** | Misspellings, with a one-click **Fix** each |
| **Beautify** | Restyles or rebuilds the page, with Keep / Revert. **HTML pages only**, and hidden in `<>Source` |

On a `.md` note the menu has Summarize and Check spelling only. If the window is narrow, the AI button collapses into the `⋯` overflow menu.

Everything on this page needs AI enabled. Summarize and Proofread additionally need a model configured — they'll appear without one and then tell you *"No model is configured. Pick one in Settings → AI."*

## Core tasks

### Summarize the open file [!both]

Open the **✦ AI** menu → **Summarize this file**. The summary appears in a popover with a **Regenerate** button:

*[Screenshot: The Summarize popover open over a project note, showing a paragraph-long AI summary and the footer "AI-generated · not saved to the file".]*

The footer is the important part: **"AI-generated · not saved to the file"**. Summarize never edits your document. The result is cached against the file's content, so reopening it is instant — and that cache is what feeds the TL;DR bar shown above a page in reading view.

This one works on every format the app can read, including [PDFs, spreadsheets and Word documents](https://docs.docgraph.app/formats/overview/).

### Check spelling [!both]

Open the **✦ AI** menu → **Check spelling**. Misspelled words get a red wavy underline in the page, and the popover lists each one as *wrong → suggestion*:

*[Screenshot: The Spelling popover listing four misspellings — Recieve, seperate, Definately, feild — each with its correction and a Fix button, with the same words underlined in red in the document behind it.]*

- **Fix** applies the correction. Unlike Summarize, this *does* write to your file — and it replaces **every** occurrence of that word in the document, not just the one you're looking at, matching the original's capitalisation. It's an ordinary edit, so ⌘Z undoes it.
- **✕** ignores a suggestion and drops it from the list.
- Clicking the word itself scrolls the page to it.
- **Re-check** runs the check again.

Fix only appears when the file is open for editing. On a read-only document you get the list without the buttons, and the footer changes to *"AI-generated · open this file in Edit to apply fixes"*.

:::caution[Spelling quality depends heavily on your model]
This is a language model, not a dictionary. Testing this page with a **1.7B** model on a paragraph containing *Recieve*, *seperate*, *Definately* and *feild*, it found **none** of them and instead flagged the correctly-spelled word "nobody". The same paragraph with a **14B** model found all four and corrected each one exactly. If Proofread seems useless, the model is almost certainly the reason — set a larger **utility model** in **Settings → AI → Chat & index**, which is the model this feature uses.
:::

### Restyle a page [!html]

Beautify rewrites a page's HTML and CSS, so it works on **`.html` pages only** — the menu row doesn't appear on Markdown, PDFs or spreadsheets, or in `<>Source`.

Open the **✦ AI** menu → **Beautify** to open **Beautify with AI**:

*[Screenshot: The Beautify with AI modal: a choice between "Style only" and "Full redesign", four style presets (Clean, Editorial, Docs, Elegant), and an optional free-text instruction field.]*

- **Style only** rewrites the CSS and keeps your exact text, links and structure.
- **Full redesign** rebuilds the layout. More dramatic, and the result is checked — if the redesign drops more than a quarter of your words it is refused rather than saved, with a message telling you to use Style only.
- The four presets (**Clean**, **Editorial**, **Docs**, **Elegant**) set the direction; the optional instruction field tunes it (*"warm color palette; larger headings"*).
- **Run on** picks the model (see [Choosing the model](#choosing-the-model-run-on)).

You can also open it with `/beautify` in the page.

Beautify **saves immediately** and reloads the page. A review bar appears at the top so you can decide afterwards:

*[Screenshot: The restyled page with a bar across the top reading "Restyled · Clean — keep it?" and Revert and Keep buttons.]*

**Revert** restores the previous version of the page byte-for-byte. **Keep** just dismisses the bar. If a full redesign rewrote lines that carried [block properties](https://docs.docgraph.app/editing/blocks/) or link targets, the bar says how many were lost (*"2 lines lost their properties"*) — Revert gets them back.

:::danger[Revert is your only undo, and only until you navigate away]
⌘Z does **not** undo a Beautify — the rewrite is a whole-file write, so the editor's undo history for that file is discarded rather than extended. The review bar disappears when you switch files or restart the app, and once it's gone there is no in-app way back. If the page matters, [save a version](https://docs.docgraph.app/formats/version-history/) before you beautify it.
:::

### Write with AI [!html]

Type `/` in a page and the menu's **AI** group offers five commands:

*[Screenshot: The slash menu filtered to its AI group: Write with AI, Ask AI, Beautify page, Summarize, and Continue writing, each with a one-line description.]*

**Write with AI** asks what you want, then inserts the result as a *draft* rather than committing it straight into the page:

*[Screenshot: The "Write with AI" modal with an instruction typed into it and a Generate button.]*

The generated block arrives with a floating toolbar attached:

*[Screenshot: Generated bullets inserted into the note, with a floating toolbar above them labelled "AI draft" offering Regenerate, Delete and Accept.]*

- **Regenerate** re-runs the same instruction.
- **Delete** removes the block.
- **Accept** unwraps the draft, turning its contents into ordinary blocks you can edit like anything else.

**Continue writing** drafts one to three paragraphs following on from the page, and **Summarize** inserts the AI's summary into the page as a blockquote. Both write directly — there's no draft toolbar for those two. **Ask AI** answers a question from your notes and inserts the answer as a draft — the same Regenerate / Delete / Accept toolbar as **Write with AI** — with the notes it used as links. **Ask in Chat instead** opens the chat panel with the current note as context.

:::caution
An accepted or deleted draft is not covered by ⌘Z either — like Beautify, `/write` writes the whole file. And if you leave the page before deciding, the toolbar doesn't come back: the draft's content stays in your note as ordinary text, which is usually fine, but the invisible wrapper around it can then only be removed from `<>Source`.
:::

### Draft a new page from a prompt [!html]

You don't have to create the page first. When AI is on, the **New HTML file** dialog carries an extra collapsed row — **✨ Write with AI (optional)**. Open it, describe what the page should contain, and DocGraph creates the file *and* drafts the content into it.

*[Screenshot: The New HTML file dialog with a vault-relative path typed in and the "Write with AI (optional)" section expanded, holding the instruction "A packing checklist for a weekend camping trip, grouped by category, with a short intro paragraph."]*

The row is collapsed by default, so creating an ordinary empty page is unchanged — one field, Enter, done. Inside the textarea, **Enter makes a newline** (the instruction is prose) and **⌘Enter** submits; the **Create** button works either way. Collapsing the row again before you press Create discards the instruction.

Every way of creating an HTML file offers it: `⌘N`, the **+** in the title bar, and **New HTML file…** from the file tree's right-click menu — the first two ask for a vault-relative path, the menu asks for a name inside the folder you clicked.

**Creating never waits for the model.** The file is written and the tab opens immediately, with a *Writing with AI…* placeholder where the content will land:

*[Screenshot: The newly created camping-checklist.html open in a tab, showing the italic placeholder line "Writing with AI…" under the title while the model runs.]*

When the model finishes, the result arrives as the same **AI draft** as `/write` above — with Regenerate, Delete and Accept:

*[Screenshot: The finished draft in the page: a Camping Checklist heading, an introduction, and sections of gear as live checkboxes, with the floating AI draft toolbar above offering Regenerate, Delete and Accept.]*

### Drafts use DocGraph's own building blocks [!html]

Whether it comes from `/write` or the new-file dialog, a draft isn't limited to plain prose — the generator is taught the page features DocGraph already has, and the same conversions run on any Markdown you paste:

*[Screenshot: A generated launch-readiness page: a warning callout card at the top, a Tasks section of live checkboxes, and links to other vault notes — with the same items listed in the Todo panel on the right.]*

- **Checklists arrive as real checkboxes.** Ask for a checklist, packing list, or action items and you get the same task items you'd make by typing `- [ ]` — clickable in the page and counted in the vault-wide [Todo panel](https://docs.docgraph.app/panels/overview/) immediately.
- **Tables arrive editable.** A generated table is the same first-class table the `/table` command makes — row and column handles, sorting, chartable.
- **Asides arrive as callouts.** Notes, tips and warnings come as the styled [callout blocks](https://docs.docgraph.app/editing/blocks/) from the `/` menu, not bare paragraphs.
- **Diagram requests can arrive as Mermaid.** Ask for a flowchart or process map and the draft may carry a live-rendered diagram you can click to edit.
- **Links point at notes that exist.** The generator is offered a short list of real vault notes related to your instruction, and may link only to those. If the model invents a path anyway, the link is stripped to plain text before it reaches the page — an AI draft never adds broken links to your [graph](https://docs.docgraph.app/graph/overview/).


So the file exists from the moment you press Create, whatever the model does next: if generation fails you get an error and an ordinary empty page, and if you don't like the draft, **Delete** leaves you with the same empty page.

:::note[HTML only]
The AI row appears on **New HTML file…** and nowhere else. New Markdown files and new whiteboards get the plain name dialog — as does every new file when AI is off, or on without a model configured.
:::

### Rewrite a selection [!both]

Select text in a page and the formatting toolbar appears. Its ✨ button opens three AI actions:

*[Screenshot: Text selected in a note, with the selection toolbar above it and its AI menu open showing Rewrite, Shorten and Fix grammar.]*

**Rewrite** (clearer, more polished), **Shorten** (more concise), and **Fix grammar** (spelling & punctuation). Each proposes a replacement for just the selected text in a preview window, showing the change as a **Diff** or as plain **Text**. Nothing is written until you click **Apply**; **Cancel** leaves the page as it was.

The page's right-click menu has more selection actions that hand the passage to the [chat panel](https://docs.docgraph.app/ai/chat/) — **Ask about this**, **Explain this**, **Rewrite this** and **Make tasks from this**. They fill in the chat box; you press Send.

### Suggestions while you type [!html]

**Off by default.** Turn on **"Suggest completions while editing"** in **Settings → AI → Chat & index** (it needs AI on and a chat model set).

With it on, pause for half a second while writing at the end of a paragraph and the model proposes a continuation in grey after your cursor. **Tab** accepts it and it becomes normal text; **Esc**, or simply typing on, dismisses it. Nothing is written to the file unless you accept.

Suggestions are deliberately narrow: they only appear at the end of a paragraph or heading, and never inside a list, a quote, a code block, or a table.

### Work on a whole folder [!both]

Right-click a **folder** in the file tree for two AI items, which read several notes at once. They appear only when AI is enabled, and never on the vault root.

**Synthesize notes…** builds a **Map of Content** for the folder:

1. Right-click the folder and choose **Synthesize notes…**. The item needs at least two notes in the folder, counting its subfolders.
2. A dialog reads the notes — up to the first 12, and the first part of each — and shows an overview, a themed outline with a line per note, and a short *How they connect* section. Every note it mentions is cited by path. The summary runs on your utility model, or the chat model if none is set.
3. Nothing is written yet. Click **Create note from this** to save it as an HTML page named `map-of-content.html` inside the folder (`map-of-content-2.html` and so on if the name is taken), which then opens. Close the dialog to discard it.

**Extract to table…** pulls structured rows out of the folder's notes:

1. Right-click the folder and choose **Extract to table…**. It needs a chat model chosen and at least one text note in the folder.
2. Pick a preset — **Action items**, **Decisions** or **People** — or **Custom…** and type what to extract and its comma-separated columns, then click **Extract**.
3. Review the preview grid. **Re-extract** runs it again; **Create table** writes a managed table and a page that embeds it.

Extract reads up to 12 notes and returns at most 100 rows. How the resulting table behaves — editing, queries, charts — is covered under [tables and charts](https://docs.docgraph.app/tables-charts/overview/).

### Choosing the model (Run on)

**Write with AI**, **Ask AI** and **Beautify** have a **Run on** choice in their dialogs, and the Summarize and Spelling popovers offer it for **Regenerate** and **Re-check**. The choice appears only once you've set up and allowed a [cloud provider](https://docs.docgraph.app/ai/cloud-providers/); it always starts on your local model, and picking a cloud model says, right under the choice, that the document will be sent to that provider. On the local model these actions use your **utility model** (or the chat model if none is set).

### More AI shortcuts

- **TL;DR bar.** With **Auto-surface TL;DR summaries** on (**Settings → AI → Chat & index**, on by default), a page that already has a cached summary shows it in a bar above the content. It marks itself when the page has changed since, and can be refreshed or dismissed.
- **File menu.** Right-click a file in the tree for **Summarize** (in a window), **Suggest tags** (click a suggested chip to add it as a tag; it is stored in DocGraph's tag index, not written into the file), and **Ask AI about this** (opens the chat about that file).
- **⌘K (command palette).** **Brief me on my day** opens today's daily note, and **Insert answer into the open note** puts a short briefing in it — what's due, what's scheduled, who you'll deal with; **What changed this week** summarizes the last seven days of saved versions.
- **Quick switcher (⌃⌥K).** Start with `?` to send the rest straight to the chat as a question (**Ask DocGraph's assistant**).

## Reference

### What writes to your file

| Feature | Writes? | Undo |
|---|---|---|
| Summarize (toolbar) | No | — |
| Proofread → Fix | Yes | ⌘Z |
| Suggestion → Tab | Yes | ⌘Z |
| Rewrite / Shorten / Fix grammar | Only on **Apply** | ⌘Z |
| `/write` → Accept or Delete | Yes | **No** |
| New file → Write with AI | Yes | **No** (same draft as `/write`) |
| Beautify | Yes, immediately | **Revert only** |
| `/summarize`, `/continue` | Yes | ⌘Z |
| Ask AI | Yes, as a draft (on Accept or Delete) | **No** (same draft as `/write`) |
| Synthesize notes… (folder) | Only on **Create note from this** — a new file | Delete the new note |
| Extract to table… (folder) | Only on **Create table** — a new table and page | Delete the table and page |

### Markdown support

The document-surface AI features are mostly **HTML-only**. On a `.md` file:

| Feature | Markdown |
|---|---|
| Summarize (toolbar) | Works |
| Proofread, including Fix | Works |
| Selection AI (Rewrite / Shorten / Fix grammar) | Works |
| The whole AI group in the `/` menu | **Absent** — no AI slash commands at all |
| Write with AI on a new file | **Absent** — the create dialog offers it for HTML only |
| Suggestions while typing | **Not implemented** |
| Beautify | **Absent** — the rewrite is HTML and CSS, so the menu row is hidden on Markdown |

## Limits & troubleshooting

**The ✦ AI menu isn't there.** AI is off. These controls are hidden rather than greyed out — check the bottom status bar, which reads *"AI off"* and opens the right settings pane when clicked.

**"Ollama is unreachable. Is it running?"** You chose Ollama and it isn't up. Start it, or switch to the built-in runtime or Apple's model. See [Local AI Setup](https://docs.docgraph.app/ai/setup/).

**A popover says there's no readable text.** Summarize and Proofread need extractable text. An empty page, or a [scanned PDF with no text layer](https://docs.docgraph.app/formats/overview/), has none.

**`/summarize` and `/continue` fail with a system alert box.** Those two report failures through a native dialog rather than in-app UI, so an error there looks jarring but means the same thing as any other AI error — usually the model or the daemon.

**Beautify on a large page is refused.** There's a size ceiling; the message tells you the file's size and the limit. Beautify a shorter page, or split it.
