Story editor

The Story tab of a book is where you write. It shows the parts of the active branch from the beginning to the end.

The story editor
The story editor

This page describes the desktop layout. On a phone the story is one column with the outline in a drawer, see Using Marginalia on a phone.

Area  
Outline (left) One entry per part, #1, #2... with the part's database ID. Click an entry to scroll to the part (the parts before it are loaded first when it is not loaded yet). The header shows how many parts the branch has. A part that has a summary has a small document icon after its entry. The Chapter Marker extension shows chapter titles here.
Lorebook (left, next to the Outline) A look at the lore of the book, with a search box and a quick edit of the text of an entry, see The lorebook tab.
Annotations (left, next to the Outline) The notes on passages of the story, for the whole book.
Planner (left, next to the Outline) The scenes you plan to write, a list you fill by hand, see The planner tab.
Story (center) The text of each part, with its menu (☰) and its metadata on the right, and under it the bottom bar.
Bottom bar The Summaries button (list icon) and the settings menu (⚙) on the left, the command line, and the + button on the right.

This is how a new book looks. All of these are tabs you can arrange as you like, the story included, see Arranging the tabs. The divider between the sidebar and the story can be dragged, and Marginalia remembers where you left it (saved with the book) and returns to it when you open the book again.

The story always opens at the bottom, at the newest part. A long book is not drawn all at once: only the last parts are loaded, and the earlier ones are added above as you scroll up, without moving the part you are reading. The parts at the other end are dropped again, so no more than the Parts loaded at once in the story setting of your account stay loaded (empty loads all of them). If you scroll faster than the parts arrive, a Loading earlier parts (or later parts) mark at the edge says that there is more. Clicking a part in the outline, or finding one with the search, loads the parts around it, and starting a new part brings you back to the end of the story.

Searching the story

Above the outline there is a search field for the text of the branch you are on (the search of the story tree searches all branches). Because a long book is not loaded all at once, the search of the browser (Ctrl+F) cannot find text in the parts that are not loaded; this one can.

  • Type what you look for; the search starts when you stop typing. Several words must all be in the same part, a phrase goes in double quotes ("old key") and * stands for any characters (light*house). The case does not matter.

  • Every place where a word stands is a match, and they are numbered through the whole branch. Below the field you see Match 3 of 27, in part #5 and a bar with how far you are. The story scrolls to the match and loads the parts around it when they are not loaded.

  • The up and down buttons go to the previous and the next match (after the last one it goes round to the first). Enter in the field does the same as the down button, Shift+Enter as the up button.

  • All the matches in the loaded parts are highlighted in the text, the match you are at in a stronger colour. Clear the field to remove the highlight.

On the phone the search is in the outline drawer; the drawer closes when it shows a match, open it again for the next one.

The lorebook tab

The Lorebook tab of the sidebar shows the lore of the book's lorebook without leaving the story, so you do not have to swap tabs to check what an entry says, or to fix a word in it. It is read again every time you come back to the Story tab, so changes you made in the book's Lorebook tab show at once.

  • The search box at the top shows only the entries that have the text in their name, content, note or filter (the case does not matter).

  • The pen of an entry opens a small window with its name, whether it is used, the filter and how it is looked for, the content and the note; Save writes them (the tags, the order and the activation settings are changed in the book's Lorebook tab). Nothing can be changed while an agent works on the lorebook.

  • The expand button (⤢) opens the full-screen lorebook editor (desktop only): the one next to the search box on the lorebook, the one of an entry on that entry, the one of a sub lorebook (with Include sub lorebooks) on that lorebook. The tab is loaded again when you close the editor.

  • Every entry is a row with its name and the pen; the arrow opens it to show its content (rendered as Markdown) and the text that activates it (the Filtering Text/Pattern, with a note when it is a regular expression).

  • Include sub lorebooks shows the lorebook and each of its sub lorebooks (and theirs, however deep) as rows of their own, with their entries under them; click the arrow of a lorebook to hide its entries. Without it only the entries of the book's lorebook are listed.

  • Entries and lorebooks that are switched off (they are not used for the story) are shown dimmed.

  • A book without a lorebook shows a note instead.

The Lorebook tab with two entries opened
The Lorebook tab with two entries opened

Like every tab of the editor it can be dragged out into a panel of its own, see below.

The planner tab

The Planner tab is a list of the scenes you want the story to go through, in the order you want them. Each scene is the details of a turn that writes it: a title for the list, the scene setting, the POV character, the present characters and the instructions, the same four fields as the new turn form.

The Planner tab with four scenes, the first one written
The Planner tab with four scenes, the first one written
  • Add scene opens a form for a new scene; it goes to the end of the list. The pen edits a scene, the arrows move it up or down, the trash can deletes it.

  • The + in the row of a scene inserts a new scene right under it, between that scene and the next one.

  • The merge button of a scene merges it with the next one: a form opens with the details of both already joined (the two titles, the scene settings and the instructions under each other, the present characters of both, the POV character of the first; when the second scene has another one the form says which). Change what does not fit and press Merge (or Ctrl/Cmd+Enter): the two scenes become one, in the place of the first. It is done only when both were.

  • Import from the branch adds a scene for every part of the branch the book is on (from the first part to the newest) that has turn details: its scene setting, POV character, present characters and instructions, with the first line of the instructions as the title. Parts without turn details are left out, and the scenes come after the ones you have, not done. Use it to plan a rewrite of a story you have written: import, merge the turns that belong together, insert what is missing, then write the scenes on a new branch or in a copy of the book.

  • The box in front of a scene says it is done (written): the title is struck through and the scene is dimmed. Nothing checks it for you, tick it when you have written the scene. The line above the list counts how many are done.

  • Click a scene to put its details into the new turn form (the form opens, with the scene setting, POV, present characters and instructions of the scene in it; what was there is replaced) and press Generate when you are happy with it. On the phone the drawer closes first.

  • The scenes are saved with the book, so they are in its backups and copies. A model can add scenes too: the plot wizard of the Arc Outline extension and an agent can read and change the planner with commands; the list shows what they added at once.

The form for a new scene
The form for a new scene
A click on a scene fills the new turn form with its details
A click on a scene fills the new turn form with its details

Like every tab of the editor it can be dragged out into a panel of its own, see below.

Arranging the tabs

The editor is a set of tabs: the Story itself (the parts and the bottom bar under them), the Outline, the Lorebook, and the tabs extensions add (Characters, Arcs, Side Query...). Drag a tab by its header to rearrange them (desktop only, the phone keeps one column with the outline in a drawer). A new book has the Outline and the Lorebook in a panel on the left and the Story in a column of its own on the right; you can put the story anywhere, for example in the middle with the outline on one side and the lore on the other, or above the outline:

  • Drop it on one of the dashed strips that appear above, between and under the panels of a column to detach it into a panel of its own in that column; the panels of a column are stacked under each other.

  • Drop it on one of the tall strips at the left, right or between the columns to detach it to the side: it gets a column of its own, next to the others. Widen the editor with the dividers to make room for more columns.

The panels and the columns are separated by splitters: drag them to give each panel the room you need. The sizes are saved with the arrangement.

The sidebar with Characters in a column of its own and Side Query under it
The sidebar with Characters in a column of its own and Side Query under it
  • Drop it on the tab header or on the body of another panel to join that panel (dropping on a tab puts it before that tab, dropping on the body puts it last). A panel that loses its last tab disappears, and so does a column without panels.

The arrangement and the sizes are saved with the book, so it is the same the next time you open it and in every browser, and so is the tab each panel shows. A tab of an extension that is not loaded keeps its place for when the extension is back.

The story is always somewhere: its tab can't be closed, and a tab that lives in a panel together with other tabs is hidden while another one is selected. Whatever shows a part brings the story back: clicking an entry of the outline, a hit of the search, choosing a branch in the story tree, and starting a generation select the Story tab first. While a generation prepares its prompt (usually a few seconds) the other tabs are disabled; once the model writes, they are usable again, see below.

Minimizing tabs

Every tab but the story has a small ⌄ (chevron) button next to its name. It minimizes the tab: the tab leaves its panel (a panel whose tabs are all minimized disappears for the time being) and a round icon of it, a colored circle with a drawing (a list for the outline, a book for the lorebook, a speech bubble for the annotations, a magnifier for Side Query, and so on; a tab of an extension that has no drawing gets one or two letters), shows up in a bar at the edge of the editor. Hover over the icon to see which tab it is. Nothing is closed, the tab keeps what it was showing. Click the icon and the tab comes back to the panel and the place among the tabs where it was, and is shown.

The bar is there while some tab is minimized. The button at its top (the circling arrows) sends the bar to the next side of the editor, clockwise: left, top, right, bottom. The story can't be minimized, so there is always something on the screen.

Minimized tabs in the bar at the edge of the editor
Minimized tabs in the bar at the edge of the editor

The icons are in the alphabetical order of the names of the tabs until you change it: drag an icon onto another one and it takes the place of that one. Which tabs are minimized, where the bar is and the order of the icons are saved with the book, together with the arrangement and the sizes.

The default arrangement

A new book opens with the standard arrangement (the outline, the lorebook and the annotations on the left, the story on the right). To make your own arrangement the standard one, set the tabs as you like them (panels, sizes, minimized tabs, the side of the bar) and choose Save layout as my default in the settings menu (⚙) of the story. Every book that has no arrangement of its own (a book you have not rearranged) then opens with it; a book you have arranged keeps its arrangement. The default is kept in your user settings.

To go back to the default arrangement, choose Restore default layout in the settings menu (⚙) of the story and confirm. This is the one you saved, or the standard one when you saved none. It only moves the tabs back (and forgets the sizes and what is minimized): your texts, the tab each panel shows and the tabs of extensions stay, the latter in the first panel.

Writing the next part

  1. Click + in the bottom right corner. The New Turn Instructions panel opens.
  2. Fill in the fields. All of them are optional, but the model needs at least some direction:

    Field  
    Scene Setting Where and when the part takes place, e.g. The lighthouse, a stormy night in late autumn.
    POV Character Whose point of view the part is written from.
    Present Characters Who is in the scene, and in what state.
    Instructions What should happen in this part.

    Scene Setting, POV Character and Present Characters are filled in from the last part, so you only change what is different. Instructions starts empty each time.

  3. Click Generate.
The New Turn Instructions panel
The New Turn Instructions panel

The new part appears at the end and fills in as the model writes it. For reasoning models the reasoning appears first under View Reasoning.

While a part is being generated, the + button turns into a red Stop button. Stopping keeps the text written so far as the part.

While a part is generated

For the first few seconds, while the prompt is put together from the book, the whole book window waits. As soon as the model starts writing, only the new part and the parts before it are held:

  • The new part can't be touched until it is finished: no edit, no menu.

  • The parts before it stay where they are: you can edit, annotate and redraft them, but not delete, merge or branch them, and the story stays on its branch (no swipe, no switch of the branch). A change to an earlier part, or to the lore, does not reach the part being written: its prompt was put together already. It counts for what comes after.

  • Everything else is free: the lore, the book's settings and prompt, the tabs of the left bar (side query, arc outline, notes...), the command bar. A request to the model waits for a free connection of the model if the generation has the only one.

  • Waiting: a second turn, search and replace, an import into the book and the mass delete. The tree and backup tabs also wait.

What the window greys out is also refused when a command, an agent or an extension asks for it: Marginalia names what is in the way (This is in use: …).

Leaving the book stops the generation. The exit button asks first; Yes is the same as Stop: what arrived is kept. Closing the browser tab does the same, and the browser asks before the tab is closed or reloaded while a part is generated. A short loss of the network, or a laptop closed for a minute, is not leaving: the page comes back and shows what arrived meanwhile.

When the model returns an error (server not reachable, wrong API key, context too long...), the error is shown. If no text arrived yet, the story stays as it was: a new part or swipe is removed and a regenerated part gets its previous text back. Text that already arrived before the error is kept, like with Stop. Fix the problem and generate again.

How the fields get into the prompt is set by the book's User Prompt. With the default user prompt, the model gets them as Current Location & Time, Point of View Character, Characters Currently Present / State and Plot Specifications for the Next Part.

Drafting the instructions

Do not know what should happen next? Draft Instructions under the Instructions field of the panel lets the model write the instructions in your place, the way you would. A window opens with:

   
Guidance What the part should be about: a rough idea, a direction ("she confronts him about the letter"), or nothing at all, and the model continues the story where it leads. It starts as what you already typed into Instructions.
Plan of the Story Only when something gives one. The Arc Outline does, with the data of the current chapter. Read only; the model follows it.

Draft Instructions starts the model and streams the answer into Drafted Instructions, which you can change or empty before you go on; Draft Again tries once more, Stop keeps what has arrived. Nothing is changed until you click Use as Instructions: the text then replaces the Instructions of the panel (the other fields are not touched) and the panel opens again, ready for Generate.

The model gets the story so far (the older story as summaries, as in a generation), the scene setting, POV and present characters that are in the panel, the lore of the last part, your latest instructions as examples of how you write them, your guidance and the plan. It does not see your lorebook entries that a new turn would activate. The request is the impersonate prompt. The model is the one of the book; drafting costs tokens like any request.

Drafting the instructions of the next turn
Drafting the instructions of the next turn

The same is the command /impersonate, which returns the text. Agents do not get it, they write the story with instructions of their own.

The settings menu

The settings menu (⚙) in the bottom bar groups what acts on the whole story. Search and replace is at the top; the rest is in sub menus (on a phone too, except the desktop-only items):

Sub menu Items
Appearance Change Styles For Text, Highlight Generated Text and Annotations in the margin (desktop only, the last one)
Analysis Annotate a range of parts with AI, Create summaries, Take lore notes with an agent, Automatic annotation, Phrase watch list, Branch Tokens, Lore Usage, Statistics
Import & export Import, Export story (and the items of extensions that import or export, such as Export instructions)
Cleanup Clear history of the book, Empty trash of the history, Mass delete
Layout (desktop only) Save layout as my default, Restore default layout

Items that extensions bring are in the sub menu that fits them, or at the end of the menu. The keys of the items are in Settings → Keyboard shortcuts, where an item is named with its sub menu (Analysis › Statistics). The sections below say where each item is.

The part menu

Every part has a menu (☰) in its top right corner. Edit, Discard Changes, Regenerate, Swipe, Redraft, History and Images are in the menu itself, Delete is its last item, and the rest is in four sub menus: Annotations (Annotate part, Annotate with AI), Summary (Generate summary / View summary, Delete summary), Inspect (Show Prompt, Compare Prompt, Token Usage, Lore Usage) and Branch & merge (Branch Story, Merge into previous part). A sub menu with nothing in it for the part is not shown. The Reviewer adds its Review sub menu after Summary. The items:

Item  
Edit Turns the text into an editable field. Save (the same menu item) saves it. Starting a generation or leaving the tab saves open edits too.
Discard Changes Only while the text is edited: closes the field without saving, the part keeps the text it was last saved with. If you changed the text, you are asked first.
Regenerate Writes the last part again, replacing its text. Only on the last part.
Swipe Writes another version of the last part and keeps the old one as a separate branch. Only on the last part. See Branches & story tree.
Redraft Lets the model write this part again from your instructions, on any part, see below. Not while the text is edited.
History (n) The versions of the text of the part, with the number of versions: compare them, put one back, name one. Not while the text is edited.
Annotate part Makes a note about the whole part. To annotate words, select them and right click (Annotate selection).
Annotate with AI Lets a model review the part and propose notes. Not while the text is edited. For several parts at once use Annotate a range of parts with AI in the settings menu (⚙), and for every new part Automatic annotation (see Annotations).
Branch Story Starts a new branch from this part, see Branches & story tree.
Merge into previous part Adds the text of this part to the part before it, see below. Not on the first part.
Show Prompt Shows the exact prompt that was sent to the model for this part.
Token Usage Shows how the context of the model was used for this part: a chart of the sections of the prompt (instructions of the model, lore, summaries, story so far, your instructions, room kept for the response) and the size of each message sent to the model. If part of the story did not fit, it says how many parts were left out. Parts written before this was recorded have no chart.
Lore Usage Lists the lorebook entries that went into the prompt of this part, with the tokens each one cost and what found it (the prompt, or the content of another entry when the lorebook scans deeper). Parts that were typed by hand, written before this was recorded, or written for a book without a lorebook say that nothing was recorded. For the whole book use Lore Usage in the settings menu (⚙), see below.
Images Attaches pictures to the part, see Images.
Generate summary / View summary Summarizes the story up to this part, or shows the summary, see Summaries.
Delete summary Removes the summary of this part. For a meta summary it asks whether to unwind it or delete it completely.
Delete Deletes the part, see below.

Regenerate and Swipe use the turn details of the last part (see below). To change what should happen, edit them first.

The menu of a part, with the Inspect sub menu opened
The menu of a part, with the Inspect sub menu opened
Token Usage of a part
Token Usage of a part

Part metadata

Next to each part:

   
Order #n | DB ID: m The position of the part in the branch, and its ID in the database.
Model The inference provider that wrote the part.
Tokens: x (y) x tokens of text in the part, y tokens in the prompt that produced it.
Words Words in the part.
Turn Details The instructions the part was written from.

Turn details

Turn Details opens the Scene Setting, POV Character, Present Characters and Instructions the part was written from. For the last part they can be changed (changes are saved right away) and are used by Regenerate and Swipe. For earlier parts they are read-only.

Turn details of a part
Turn details of a part

Editing the text

Generated text is yours to change. Choose Edit in the part menu, change the text, and choose Save. Edited parts are sent to the model as you edited them.

Editing a part that a summary covers makes that summary outdated; Marginalia notices it at the next generation and drops the summary. So that this doesn't happen by surprise, Save checks the new text first: when it would make summaries outdated, a window says how many and offers Back to editing (nothing is saved, the editor stays open with your text), Save anyway (the summaries become outdated) and Save and revalidate summaries (the text is saved and the summaries stay valid, for a change that doesn't alter what they say, like a typo). The check is made for Save (the menu, the shortcut and the editor button); the automatic saves, for example when you start a generation with the editor open, don't ask.

Keyboard shortcuts

On a computer (the phone layout has none) the writing loop works with the keyboard:

Key  
+ Opens the New Turn Instructions panel with the cursor in Instructions.
Ctrl+Enter Generates from the open panel. Esc closes it; the keyboard goes back to the story.
Ctrl+. Stops the generation that runs.
s / r Swipe / Regenerate the last part.
e Opens the editor of the part that is the most visible on the screen (the last part when none is).
Ctrl+S Saves the part that is being edited (also while the cursor is in its text).
/ Puts the cursor into the command bar (the story tab is shown first).
Ctrl+Shift+F Opens the Outline tab and puts the cursor into the search of the branch (Enter / Shift+Enter go to the next / previous match).
Ctrl+Shift+H Opens the Search and replace window of the book.
a Annotate selection: makes a note about the text selected in a part.
Alt+PageDown / Alt+PageUp Shows the next / previous tab, going through the tabs of all sheets in the order of the layout and round again.

A key without Ctrl, Alt or Meta (such as +, s, r, e, a, /) works only when no text field has the focus, so it never gets in the way of typing. The shortcuts work in the story tab of the open book and not while another window is open above it. The buttons show their key in the tooltip, and the menu of the last part shows it after Edit, Regenerate and Swipe. On a Mac Cmd works where a key says Ctrl (unless you gave that Cmd key to another action). You can change every key in Settings → Keyboard shortcuts.

Deleting a part

Delete removes the part from the story. The parts that followed it stay and continue from the part before it, so deleting a part in the middle of the story just takes it out. Deleting the last part makes the part before it the new end of the branch.

Deleting many parts at once

The settings menu (⚙) has Mass delete. Turning it on puts a check box at the left of every part and shows a bar under the story with the number of ticked parts and a Delete button. Tick the parts you want to get rid of (the ticks are kept while you scroll, the story loads only a window of the parts); Shift + click on a check box ticks (or clears) all the parts between it and the one you clicked before; a ticked part is tinted red. Then press Delete: after a confirmation the parts are deleted one by one behind a progress bar that can't be stopped. They are deleted as a single part is: the parts that followed a deleted part continue from the part before it, and the deleted parts go to the trash. Then the story is shown again and the mass delete is off. Cancel in the bar, or choosing Mass delete again, turns it off without deleting anything. Starting a generation also turns it off. A ticked part that a window or a translation works on is left in the story, and Marginalia says what has it.

Mass delete with some parts ticked
Mass delete with some parts ticked

Redrafting a part

Regenerate and Swipe work on the last part only and write it from scratch. Redraft works on any part, also an old one in the middle of the story, and keeps what you do not ask to change. Choose Redraft in the menu of the part:

  1. Write what should change in Instructions for the redraft: add more dialogue between the two, make the fight longer, remove the explanation of the map, keep the ending as it is. Empty instructions write the part again with the same events.

  2. Choose Length if the part should get Shorter or Longer (the default is Same length): a sentence that asks for it is added after your instructions (see Redraft Shorter Prompt and Redraft Longer Prompt). Choose Redraft. The text streams into Redrafted text; Stop ends it early. Choose Redraft again for another try, with other instructions if you like. Differences shows what changed against the part, word by word. When the part has open annotations, Deal with the open annotations of the part (checked at first) gives them to the model as well, and Apply marks them resolved.

  3. The redrafted text is a field you can still edit (its corner icon makes it grow to fit the whole text), and Differences follows your edits. Apply replaces the text of the part with it; Close throws it away. Nothing in the book changes before Apply.

The redraft window: the instructions, the new text and the differences
The redraft window: the instructions, the new text and the differences

The model gets the redraft prompts: the part, your instructions, the story before the part (the older story as summaries where there are valid ones, the rest as text, the newest part first when it does not all fit), as much of the story after the part as fits (up to a quarter of the room), the lore the lorebooks give that part now (worked out again for the part's turn, so an edit of an entry reaches the redraft; the lore the part was written with is used only when the book has no lorebook), the point of view, tense and style of the book, and the scene setting, point of view character, present characters and instructions of the turn the part came from. The story after the part is there so the new text still leads into it: events the following parts rely on should stay.

The part keeps its place, its summary, its pictures and how it was generated; the text, its words and tokens are replaced and the part counts as edited. Applying the redraft is an edit like Save in the editor, so summaries that describe the old text become outdated, and Marginalia tells how many. A summary on the part itself is one of them.

When a summary describes the part (the part has one, or a newer part of the branch does), the window has the checkbox Revalidate the summaries this redraft makes outdated, unchecked at first. Check it when the summaries still say the right thing (the redraft changed the wording, not what happens): Apply then works out their hash again and they stay valid. Leave it unchecked when the events changed, and make the summaries again.

The window does not block the story, see Working beside the window.

Working beside the redraft and annotation windows

On a computer the Redraft and Annotate with AI windows stand at the right of the story and leave it usable: you can read, scroll and edit the story while the model writes. Drag a window by its title to move it, or by its edge to resize it. The arrow (⌄) in the title folds a window into the panel of the runs at the bottom left of the page: the model goes on, Open (or a click on the entry) brings the window back and Stop stops the model (once it is done, Close closes the window). On a phone the windows still cover the story, but they fold the same way.

The redraft window beside the story while the model writes, and the run in the panel at the bottom left
The redraft window beside the story while the model writes, and the run in the panel at the bottom left

Close and Stop are two things. The window's own Stop stops the model and the window stays with what arrived. Close while the model works does not stop it: the window folds into the panel and the model goes on in its queue; its answer is in the window when you open it again. Close a window whose model is done, or Close it in the panel, and it is gone; closing the book or the browser tab stops a folded window too. The same holds for the other windows that wait for a model: a summary (and Create summaries, Rewrite all summaries), the Reviewer, the book description, the lore and outline generators, the image and manga generators, and the persona writer of Beta Readers. The audiobook's Studio and Convert windows do not block the page either; closing them never stopped the conversion.

While a window is open (or folded) on a part, the part shows what it is doing next to its menu (Redrafting · The book), and Regenerate, Swipe, Redraft, Annotate with AI, Merge into previous and Delete are off for that part, so the window does not lose its part. Editing the part stays possible. Closing the book closes its windows and stops their models. A part a translator is working on shows Translating the speech of the part... the same way, and two translators never work on one part at once: the second one says that the part is in use.

  • When you Apply a redraft of the whole part and the part was changed after the window was opened (you edited it meanwhile), Marginalia asks first: Differences then compares the part as it is now with the redraft, so you see what applying would replace; choose Apply anyway or Cancel. A redraft that applies itself does not do it when the part was changed: the window waits for you instead.

  • When the part was deleted before you Apply the redraft or add the annotations, the window says so, writes nothing and closes.

The panel of the runs

Everything that works on your books with a model right now is listed at the bottom left of every page: a generation, a redraft or an annotation, a translation by the Real Language or Conlang translator, a rewrite of the summaries, the Knowledge Tracker reading the story, an Audiobook conversion, a command of the command bar that takes a while (Draft instructions, a summary...: its window stands at the side and folds like the others), an agent at work. The windows in which you wait for an answer are listed too while the model answers: Impersonate, the help assistant, a quick translation, the Conlang designer, a chat of Side Query (and its naming of the tab), Beta Readers or the plot wizard. It lists your runs from all your open pages (another tab, the phone), not only the ones started on this page. Nothing running, nothing shown. The window of the Knowledge and State Trackers is an entry of the panel too: closed while the model works, it folds into it.

The panel of the runs opened: the redraft folded into it, with the end of the model's text, Open and Stop
The panel of the runs opened: the redraft folded into it, with the end of the model's text, Open and Stop
  • Closed it is a small bar: the first run, how many more (Translating the speech of the part... · 2 more) and a moving bar while a model works. Click it to open the list; it opens by itself when you fold a window into it.

  • Open, each run shows what it does, the book, how long it runs, what it waits for and the end of what the model writes:

    • Waiting for the model: 2 requests before this one when the model is busy with other requests (see Connections in Inference providers);

    • The model is thinking... or The model is writing..., with the end of its thinking or of its answer below;

    • Waits for you when the run waits for a decision of yours (a redraft to apply, a proposal of the Knowledge Tracker to review, the Prompt Inspector's question before a generation, a command of the plot wizard to allow).

  • Stop stops the run, wherever it was started. Open, or a click on the entry, shows a folded window again (only on the page it was opened on) or the run itself; it is Review when the run waits for you. A run of the Knowledge Tracker opens its book on this page (when no other book is open here; otherwise you are asked to close that one first), switches to the Knowledge tab and shows the review. The Stop of an agent pauses it. Close closes a window for good (and stops its model).

  • What ended stays in the list for two hours, below what runs, with how it went (Completed, Failed) and how long it took: a translation, summaries, what followed a part, an agent's session, an import, work that went on after you left its page. Close takes it out of the list. A generation of the story and the runs you stopped are not kept.

  • On a computer you can move the panel by its grip (⋮ at its left); it stays where you leave it in this browser. In the lower half of the page it grows upwards when you open it, as in its corner, and it is always kept inside the page. When it stands where the round button of the help assistant is (over a book both are in the bottom left corner), the button moves aside and comes back when the place is free.

When a run you started ends after its page was closed, another open page of yours sends its notification (for the runs that have one, such as the rewrite of the summaries).

What is refused while something runs. The next part is not generated while a redraft window of the book is open (close it, or apply it, first) or while a command of the command bar is about to generate. A part is not merged into the part before while a window or a translation works on that one, and search and replace leaves out the part a generation is writing (it is counted as skipped). An agent does not start on a book that is open in a window or that anything else works on. When several runs wait for one model, your next generation goes before the annotation, translation or audio of the part before it.

Redrafting only a passage

To rewrite a few sentences and leave the rest of the part alone, select them in the text of the part and right click (a long press on a phone): the menu has Redraft selection. (The menu ☰ of the part is not offered for this, opening it can lose the selection in some browsers.) The window works as above with two differences: it shows the Selected text, and the redraft is only the text that replaces it. The model gets the whole part with the selection marked, and the story and lore around it, so the new passage joins the sentences before and after it. Differences compares the selection with the redrafted text; Apply puts the redrafted text in the place of the selection and keeps the rest of the part, including the space or line break at the edges of the selection. With open annotations the check box offers only the ones whose passage overlaps the selection. If the part was changed after you selected the text (in another window), Apply refuses and you select it again. While the part is edited the selection in the editor is used, and the edit is saved first.

What follows a generated part

When a part you generated (from the page or the command bar) is complete, the book may do more with it by itself, in this order:

  1. Annotate: the automatic annotation reviews the part.
  2. Mark phrases: the phrase watch list annotates the phrases it finds (no model).
  3. Redraft: the part is written again to address the notes.
  4. Translate: the Real language and Conlang translators translate its speeches.
  5. Knowledge: the Knowledge Tracker reads it.
  6. Audio: the Audiobook makes it into audio.

Only the steps the book has switched on run. They run on the server, so the page can be closed, and they are one entry in the panel of the runs: After part 14: Annotate ✓ · Redraft … · Translate, with the model's text and one Stop. What changes the text comes first, so the tracker and the audio get the final text. A step that waits for you (notes or a redraft to choose) opens its window, and the entry has Review to open it in another page.

  • Stop, closing a window that waits for you, or a step that fails ends it there: what was done stays, the rest is not run, and a message names what is left, to do by hand (each step has its own action on the part).

  • While the redraft runs, the next part can't be generated (you'd be told by which run); while the other steps run, it can.

  • The part can't be deleted until its text is final; generating it again ends what followed its earlier version.

  • An agent does these steps by its own commands: nothing follows a part an agent generated.

Merging a part into the previous one

A model that stopped in the middle of a sentence (the response limit, a cut connection) cannot be told to "continue" the same text reliably. Write the next part instead (continue from where the last part stopped) and join the two with Merge into previous part in the menu of the second one. A review opens:

  • Join the texts with: an empty line, a line break, a space or nothing. It is preselected from the end of the previous text: a paragraph after a text that ended a sentence, a space after one that was cut.

  • The scene setting, POV character, present characters and instructions of both turns, combined in fields you can edit. What the two turns have in common at the start is kept once ("Write the duel. Keep it short" and "Write the duel. Add rain" give the first, and "Add rain" on the next line).

  • Data: what the two parts keep, value by value (for example the variables of the story and the data of extensions), with whether the value is the same, different or only on one of the parts. The merged part keeps the value of the later part (it is where the story stands now) unless you choose the value of the previous part for it, or leave the value out. Values that are the same are hidden unless you ask for them.

The review before a part is merged into the previous one
The review before a part is merged into the previous one

The previous part keeps its place, its summary and how it was generated (prompt, model, times); it gets the joined text, the joined reasoning and pictures, and its words and tokens are counted again. The part you merged is deleted (it is in the Trash) and what followed it continues from the previous part. Summaries that cover the two parts become outdated, as after an edit. The history of the part that was merged is removed, and the surviving part has the joined text as a Merged version. The part cannot be merged when it is the first part of the book, or when the part before it has other continuations (swipes of the part): delete them or make them a branch first.

Images

A part can have pictures: a map, a character portrait, an illustration. Choose Images in the part menu to open the list of the pictures of the part.

The Images dialog of a part
The Images dialog of a part
  • Add image (or drop a file on it) uploads a PNG, JPEG, GIF or WebP picture of up to 10 MB. WebP pictures are converted to PNG when they are uploaded, because Word and PDF files can't contain WebP.

  • Caption is shown under the picture. It can be empty.

  • Position in the part is a 3x3 grid. The column is the side of the text (left, center, right), the row is the place in it: the top is before the text, the middle is in the middle of it, the bottom is after it. Click a square to choose.

  • Text flows around the image lets the text run around the picture instead of above and below it. At the left or the right, the text runs beside the picture. In the middle column the text is on both sides of it: a few blocks of the text (about 400 characters, two blocks at least) at that row become two columns, the first part at the left of the picture and the rest at the right, so the text reads down the left column and goes on in the right one. Two pictures in the same place are one above the other between the columns. When the text has no room for two columns (one paragraph only, or the blocks are already taken by the band above), the picture is a block of its own, centered.

  • Width is the width of the picture as a percent of the width of the text. Automatic keeps the size of the picture (never wider than the text; a picture with text on both sides is 30 %). A picture the text flows beside is at most 60 %, and one with text on both sides at most 40 %, so the text keeps some room. The height follows the proportions of the picture.

  • The trash button removes the picture from the part.

The position of a picture: in the middle, with the text flowing around it
The position of a picture: in the middle, with the text flowing around it

Preview as in the viewer (a button of the dialog, and the same entry in the part menu when the part has pictures) shows the part the way the viewer shows it, with the text style of the book: the pictures where you put them, and a switch for a wide or a narrow (phone) screen. It uses the text in the editor as it is now, saved or not.

The preview: the text in two columns with the picture between them
The preview: the text in two columns with the picture between them

The story editor itself does not use the position: it shows the pictures under the text of the part, as a list. The position is used by the viewer and by the exports.

Where in the text a picture goes does not depend on numbers saved with it: the text is cut between its blocks (paragraphs, lists, quotes and code blocks are never cut), so the pictures stay where they belong when you edit the text. The middle is the place between blocks that is nearest to the middle of the text; a picture the text flows around at the bottom is put before the last block, so that at least that block runs beside it. Pictures in the same place stay in the order of the list; ones that are next to each other in the same place (and do not let the text flow around them) stand in a row when they fit. PDF and Word do that for pictures that have a width.

Pictures are not part of the text. The model never sees them, they are not in the prompt, they do not count as tokens and they do not change the summaries. They are also not Markdown: a ![](...) link written in the text is not a picture of the part, use Images instead.

Good to know:

  • Regenerate keeps the pictures of the part, also when the generation fails. Swipe writes a new part (a new version next to the old one), which starts without pictures. Branch Story copies the pictures to the new part.

  • Pictures belong to your account. In the viewer readers of a published book see them too, unless you uncheck Show the images to readers in the book's About tab.

  • A backup remembers which pictures a part has, but not the picture files. Restoring a backup into another account or another installation gives parts without their pictures.

  • Removing a picture from a part only takes it off the part. The file stays and is still listed in Resources, where you can download, replace or delete it. Deleting it there removes it from every part that uses it. The file itself stays in the data folder.

Summaries

The Summaries button in the bottom bar (left of the settings menu ⚙) opens the overview of the summaries of the branch, where they can be edited, deleted and merged into meta summaries. The tooltip of the button shows how many tokens the summaries in use take in the prompt. See Summaries.

How much of the context the story takes

The settings menu (⚙) has Branch Tokens. It shows, before you generate anything, what the story of the active branch takes of the prompt: a bar for the story without summaries (all the parts) and with summaries (the summaries and the parts after the newest one), and a table with the parts, the tokens and the share of the prompt budget (the context of the book's model minus the room for the response). Only summaries that still describe the story count; the ones that no longer match are named, they are dropped when a part is generated. The lore, the system template and the instructions of the turn take room from the same budget. Without a model with a context size the table has no shares.

Branch Tokens
Branch Tokens

Which lore entries were used

Lore Usage in the settings menu (⚙, Analysis) tells which entries of the book's lorebook the generations used and which never were, so a lorebook can be pruned by what it does and not by guessing. Every generation records which entries went into its prompt (and the tokens of each); the window adds that up over the parts:

  • Parts chooses what is counted: the Active branch, or All branches, every branch and every swipe of the book.

  • From part and To part limit the range, numbered as in the outline (the first part of a branch is 1, in all branches the number is how deep the part is in the tree); leave them empty for the start and the end.

  • Show keeps the entries that were Never used, Sometimes used or Always used in the counted parts.

The Lore Usage window
The Lore Usage window

The table has one line for every entry of the lorebooks of the book, the most used first: its lorebook, whether it was never, sometimes or always used, in how many parts (of the parts that have a record, with the percent), the tokens it cost in all of them and per use, and the first and last part that used it. Click a header to sort. An entry that was used earlier but is not in the lorebooks of the book now (deleted, moved, or its lorebook is switched off or not the book's any more) stays in the list marked not in the lorebook now; a deleted one has no name.

Only the parts that have a record are counted: a part typed by hand, written before Marginalia kept this record, or written when the book had no lorebook has none, and the window says how many. Always used entries could be constant entries, never used ones are candidates for removal or for a better filter; Preview activation in the lorebook editor shows why an entry does not fire now.

Text styles

The settings menu (⚙) in the bottom bar has Appearance → Change Styles For Text, a menu with one entry per style, sorted by name. For how to make a style, see the styling guide. A style decides how the text of the parts looks: font, size, colors, alignment, headings... The application brings two styles that can not be changed: Normal (the look of the application) and Book (a book-like reading style, the one the viewer uses), and you can make your own in Settings → Styles.

  • The first entry, Default (...), follows your default style (the one marked in Settings → Styles, Normal when you chose none). A new book has no style of its own and shows that.

  • Choosing another entry stores the style in the book, so it overrides the default for that book only; the ticked entry is the one the book has now. Default takes the choice back.

  • A style you delete falls back to your default in the books that used it.

Appearance, Change Styles For Text: the styles to choose from
Appearance, Change Styles For Text: the styles to choose from

In the Book style paragraphs are justified and long words are hyphenated automatically, using the dictionary of the book's Language (set on the About tab). Hyphenation is done by the browser; for a few rare languages it has no dictionary and the text is simply not hyphenated.

Books that had the old Change Styles For Text switch on keep showing the Book style until you choose another entry.

Highlighting generated text

The settings menu (⚙) also has the checkable Highlight Generated Text. While it is on, the words a model wrote are highlighted in every part, so what you added or rewrote stands out. Marginalia follows the text through the versions of the part: each version is laid over the one before it, and the words they have in common keep whoever wrote them, so a sentence you typed into a generated text stays yours however many times the model rewrites the rest. A part you never edited is highlighted whole; a part you wrote yourself has nothing highlighted. What an agent wrote counts as the model's. The switch is not saved: it is off again when the page is opened anew.

A part whose history is switched off has no versions to follow: it is compared with the text the model generated first. The highlight works on the phone too.

The same count gives the ratio: the Info tab of the book has Authorship of the branch with a Calculate button, which tells how many percent of the words of the active branch you wrote and how many a model generated, and the export can end the file with a statement of it.

Highlighted generated text and the settings menu
Highlighted generated text and the settings menu

Commands

Next to the menu below the story there is a command line: type / to see the commands, pick one and press Enter (or the play button) to run it. What a command returns is shown in a small window above the line. See Commands for how to write arguments, what the help shows and how to stop a command that takes a while. The command line is only in the story tab of the desktop layout so far.

Search and replace

The settings menu (⚙) also has Clear history of the book and Empty trash of the history, see Version history.

The settings menu (⚙) also has Search and replace, which changes a word, a name or a phrase in the whole story at once. The window has a Search for and a Replace with field and these options:

The settings menu with Search and replace
The settings menu with Search and replace
The Search and replace window with a search typed in
The Search and replace window with a search typed in
Option Default Meaning
Search by regex off The search text is a regular expression and the replacement can use its groups ($1). Otherwise the text is searched as typed.
Case sensitive on A text is found only in the case you typed it (John does not find john). Off: the case does not matter. Locked while Search by regex is on.
Search in summaries on The summaries are searched and changed too.
Search in all branches off All branches are searched, otherwise only the active one.
Revalidate all summaries on After the replace every summary of the book is valid again, see below.

With a regular expression the case is always taken as typed, start it with (?i) to ignore it. Press Search (the button on the right of the fields; on the phone below them). The progress bar shows how far it is and Stop next to it interrupts it. Nothing is changed by a search.

The table lists every part of the story and every summary that has a match, with its type and id. Open a row to see the matches in it: the text around the match as it is and as it will be after the replacement. A match or a replacement that is too long to show is written as [searched text] or [replace text].

The matches of a search, the first part opened
The matches of a search, the first part opened

Pressing Enter in the Search for or Replace with field does the same as Search.

When the search is done, the fields and options are locked and the Replace button is enabled. Search again forgets what was found and unlocks the window, so you can change the search. Replace changes the story: the window is frozen completely (even Stop does not work) until it is done, and then it is empty again. Replaced parts are marked as edited, as if you had edited them yourself.

A replace in the text a summary describes would make the summary outdated. With Revalidate all summaries on, Marginalia works out again the check value of every summary of the book (those of all branches too, those the replace did not touch, and those that were outdated before), so all of them are valid afterwards. That also turns an outdated summary valid without its text being looked at, so use it when you know the summaries still say the right thing.

With the option off only the summaries the search covers are brought up to date. Those it does not cover (summaries of branches that are not searched, which share their earlier parts with the active branch; or all of them when summaries are not searched) become outdated. If there are such summaries, Marginalia tells you how many and asks whether to go on. A summary that was outdated already stays so.

The warning about summaries that would become outdated
The warning about summaries that would become outdated

In the phone layout the same window has the fields and buttons below each other, and the table has one column that shows the type and id, and below them the match and the replacement.

The Summaries overview has the same window for the summaries only.

The same search and replace can be run from the command line with /search-replace-parts; it asks before it replaces.

Importing into the book

The settings menu (⚙) has Import (under Import & export). It is the window of the Books tab that makes a new book of a file (see Managing books), for the book you are in: the parts are added to the story instead. The Source is one of the zip archive of .md files, a document (Word, LibreOffice, RTF, Markdown, plain text, EPUB), the zip of an Obsidian vault or the zip of a Scrivener project; each has the same text and the same options as there (the words per part and the heading level of the chapters), and a line tells what the import will make. The chats of SillyTavern and LM Studio are not offered: they are a tree of branches, which has no place in the middle of a story.

Put the parts says where they go:

  • At the end of the story: after the last part of the active branch (the first part of an empty book).
  • Before a part or After a part: pick the part from the list (the numbers are the places in the active branch, with the start of the text). The parts are put between two parts: everything that followed the place, all its branches, follows the new parts, and no part is changed or made again. The end of the story stays where it was (the story is that many parts longer). The summaries that cover the place are outdated, as they describe the story without the new parts: the summaries window shows them and makes them again.
The import window of a book
The import window of a book

The parts of an archive are the files in the order of their names, numbers inside the names compared as numbers (2.md before 10.md), also in folders of the archive. Folders, hidden files (.name), the __MACOSX folder and files that are not .md are skipped. The file is the text of the part as it is, it is not sent to the model and not changed; all the parts count as written by you.

The import shows a progress bar with the number of parts done. Stop ends it after the part that is being stored: the parts that were already added stay in the story (the import is not undone), and a message tells how many were imported.

After an import

When the parts are in the book, a window Import finished offers the two things that make a long story easier to write on (a book that was just imported as a new one is opened first, and the window is in front of it). Both are also in the settings menu (⚙, Analysis), so they can be done later or again:

  • Create summaries... writes the summaries of what was imported, see Create summaries. Do it first: an agent locks the book while it works.

  • Take lore notes with an agent... starts an agent that reads the story and writes the characters, places, things and terms it finds as entries of the book's lorebook, see Lore notes.

Not now closes the window and does neither.

The window after an import
The window after an import

The same import into a lorebook is described in Import & export.

Exporting the story

The settings menu (⚙) also has Export story, which saves the active branch as a text, Markdown, HTML, Word, PDF or EPUB file. See Exporting a book.

What the model gets

For each new part Marginalia sends:

  1. The master template as the system message: role, lorebook entries, point of view, tense, style and summaries. The jailbreak prompt of the inference provider, if enabled, comes first.

  2. The previous parts of the active branch as the model's own earlier answers - as many as fit into the context limit, newest first. Older parts that don't fit are left out (unless a summary covers them).

  3. The user prompt with the instructions for the new part.

Show Prompt on any part shows exactly what was sent. See Book prompts for the templates.