# File previews

File previews let you inspect the project's documents, data, code, figures, and
other outputs without leaving Scient. Files linked in chat open inside Scient
first. Project files keep their editable Files-panel behavior. Files elsewhere
in the connected environment open in a read-only side panel or, for HTML, the
integrated browser.

## Browse workspace files

The Files tree loads folders as you open them. Useful project material remains
visible whether it is Git-tracked, ignored, or named with a leading dot.
Low-level machinery such as version-control data, dependency stores, temporary
caches, and private Scient runtime state stays out of the ordinary view.

The bar above the tree searches file names and offers **New**, which creates a
Markdown or LaTeX document in the selected folder (or the folder of the selected
file). Right-click a folder for the same choice under **New document here**.
**Connect** lists the services a folder can keep in sync with. **Overleaf…** links
the selected folder to an Overleaf project, or brings one in as a new folder (see
[Overleaf](overleaf.md)); Google Drive, OneDrive and Dropbox are coming soon.
Right-click a folder for **Connect to ▸ Overleaf…**. Linked folders carry
Overleaf's leaf.
The **⋯** Files menu refreshes the tree, expands or collapses every loaded
folder, and sets file visibility. The tree does not watch the disk, so use
**Refresh files** after changing files outside Scient.

### Manage files and folders

Right-click a file or folder for **New File**, **New Folder**, **Cut**, **Copy ▸**
(the item itself, its **Path**, **Relative Path** or **Mention**), **Paste**,
**Duplicate**, **Rename…** and **Move to Trash**. A new file or folder appears
with its name ready to type. With several items selected, the menu acts on all
of them and says how many. Drag files or folders onto a folder to move them
into it, or onto a file at the top of the tree to move them to the project's
top; hold `Option` (`Alt`) to copy instead. With the tree focused, `mod+c`,
`mod+x`, `mod+v`, `mod+backspace` or `Delete`, `mod+shift+n` (new folder) and
`F2` (rename) work as in Finder or Explorer.

To bring in files from elsewhere on your computer, drag them from Finder or
Explorer onto a folder in the tree, or right-click and choose **Add Files…** or
**Add Folder…**. Scient copies them in and leaves the originals where they
were. This works when the project is on the computer you are using; for a
remote project, copy files there with that computer's own tools.

**Open with** lists every app your Mac offers for the item, its default first,
then the code editors Scient found. On Windows, **Other App…** opens Windows'
own Open With window. Linux has no app chooser shared by its desktops, so Open
with lists the code editors only.

When a name is taken, Scient asks: **Replace** moves the existing item to the
Trash, and **Keep Both** gives the new one a numbered name. Nothing is deleted
for good: **Move to Trash** uses the computer's own Trash (the Recycle Bin on
Windows), so items can also be put back from there.
`mod+z` in the tree undoes the last change made from Files, and a Trash
notice offers **Undo** for a few seconds; on Windows, restore from the Recycle
Bin instead. Open editors are saved before their files move, and open tabs
follow a renamed or moved file. Scient's own records and tool folders, such as
`.scient` and `.git`, stay as they are.

The same file list can sit beside other side-panel tabs too, such as a browser
page, Sources, or a Scientific computing session. Use the folder button at the
end of the tab strip, or `mod+alt+e`. One switch covers every tab, project files
and PDFs included. Clicking a file opens it in its own tab. Diff keeps its own
file list, and a panel too narrow for both shows the page alone.

Files and file tabs keep a short history. **Back** and **Forward** sit at the
start of the tab's header and light up once there is somewhere to go: after
Files opens a file, after a path crumb opens a folder, or after a file opens
from another tab, including a tab that was already open.
While the keyboard is in the tab, `mod+[` and `mod+]` do the same. The history
lasts while Scient is open.

The Files menu offers two visibility levels:

- **Project files** is the default. It includes durable managed source files,
  records, receipts, and history below `.scient/sources`.
- **All workspace internals** also shows technical machinery such as
  version-control data, dependency stores, caches, source operations, and
  staging.

The choice lasts for the current workspace session. Managed and tool-owned
files open read-only in Files; use their owning Scient surface when you need to
change them.

Filename search filters the existing tree. Scient uses the project index to
discover matches in unopened folders and loads only their ancestor folders.
Ignored paths that have not been browsed may not appear in search.

What appears in Files does not change what an agent can access and does not add
file contents to a conversation. Those boundaries are enforced separately when
an action reads or shares a file.

In a project file's header, select the project name or any parent folder to
browse that folder, drill into its subfolders, and open a nearby file. The final
file name identifies the current file and is not a navigation control.

Right-click a file tab to copy either its project-relative path or its full path.
For a remote project, the full path belongs to the connected environment rather
than the computer displaying Scient.

Workspace and chat-linked host-file previews follow changes made on disk. The
compact reload action in the file header remains available for an immediate
retry or manual refresh; it turns once when clicked. If automatic updates pause, that action is highlighted
and its tooltip explains that reloading will retry them. A failed read keeps the
last available preview visible while reporting the problem.

The Files tree, Git status, and working diff also refresh after the agent
finishes a file-changing tool or command. Unsaved source edits remain protected.

To rename an open project file, click its name at the end of the file header.
The name is selected without its extension, so typing a new name keeps the file
type; a path such as `drafts/notes` also moves it. Renaming waits while unsaved
edits are being saved, and never replaces an existing file. Renaming a LaTeX
file that another document includes says so: update the line that includes it.
Links to the file from other documents are not updated.

Current limitation: automatic refresh follows the exact known path. If the file
is renamed or moved outside Scient, reopen it from its new location; Scient does
not yet relocate an already open file automatically.

- Markdown files open as rendered documents. Writable project Markdown is
  directly editable in that rendered surface; formatting controls appear
  without replacing it with a second preview. Use the source/rendered control
  in the file header when exact Markdown text is needed; Scient remembers that
  preference. A link to a specific Markdown line opens source so the requested
  line can be shown. Relative image paths resolve from the Markdown file's
  folder, including nested folders; inline sizes and alignment are preserved.
- In an editable table cell, **Enter** starts a new line in the same cell without
  paragraph spacing. **Tab** and **Shift-Tab** move between cells. While the
  caret is in a table, the footer shows the table actions (add row, add column,
  column alignment) and a **More table actions** menu, which includes **Select
  whole table**.
- A thin footer stays under an editable Markdown document. On the right it
  shows where the caret is, for example "Heading 2" or "Table · row 3,
  column 2", and the word count: "1,284 words", or "12 of 1,284 words" while
  text is selected.
- In the formatting tools, **Insert** lists what a Markdown file can hold. The last menu, **Document**, holds
  **Find & Replace**, which opens a bar under the formatting tools, and
  **Keyboard shortcuts**, which opens the list of writing shortcuts.
- Code blocks and HTML/YAML/TOML source boxes stay directly editable and offer
  **Wrap lines** and **Copy code** in their headers, matching chat. Wrapping
  follows **Settings → Word wrap**, which defaults on. A block's wrap button
  changes only that block; changing the setting applies the new preference to
  open blocks. Copy includes the current code without adding Markdown fences.
  Code headers use the same colored language icons or filename titles as chat.
  HTML tags and attributes, operators, and punctuation are highlighted in the
  editor. Code boxes have a subtle border and the same thin scrollbar as math.
- Standalone Markdown images expose floating viewing controls. Use **Edit
  details** for the image source and alternative text; **Apply** saves one
  change and **Cancel** leaves the document unchanged. Click an image to place
  the caret in its caption, or click the caption to choose a text position.
  One outline surrounds the image and caption while editing. Captions save as
  you type; Enter or Escape leaves the caption, and Undo remains available.
  An image without a caption shows an empty field when clicked or after
  **Add caption**; leaving it empty does not change the document.
  Typing before or after a standalone image creates a separate paragraph, so
  text stays above or below the image and its caption. **Add caption** on an
  image mixed with prose places that image in its own paragraph and opens its
  caption without discarding surrounding text. Linked badges and table images
  keep their compact presentation and link behavior.
- Images, Mermaid diagrams, Plotly, and Vega-Lite share quiet **Expand** and
  **More** controls. Copy, downloads, and source/details actions live in More.
  **Move controls** exposes a handle; drag it or use arrow keys, then press
  Enter or Escape to finish. **Reset controls position** restores placement.
  Plotly exploration tools remain directly accessible. Vega-Lite keeps its
  authored interactions and a direct reset control; expanded viewers retain
  zoom, fit, and exploration controls.
- Reference-style images share their source and title with a Markdown definition.
  **Edit shared reference** opens that definition; **Make independent** explicitly
  separates this occurrence. Alternative text remains local to the image.
  **Replace image** keeps the original until upload succeeds, and **Remove from
  document** never deletes the file. Copy, expand, background, and retry actions
  do not edit Markdown.
- Text files larger than the preview limit open read-only. In rendered
  Markdown, task checkboxes are also non-interactive so a partial preview can
  never replace the complete file.
- HTML files open in the integrated browser. To edit the HTML, right-click the
  file in the file tree and choose **Open source**.
- If the integrated browser is unavailable or an HTML preview fails, Scient
  opens the source instead.

Word (`.docx`) and PowerPoint (`.pptx`) files open in a reader with the PDF reader's
controls: the page number and steps, zoom (buttons, pinch, the PDF reader's zoom keys,
**Fit width** and actual size), a sidebar of pages, and search (**⌘F**), which marks every
match. Their text can be
selected, copied and quoted (see [Message Scient](composer.md#quote-a-word-page-or-slide)).
A very long document shows its first 1,000 pages, a paragraph or table too long to lay
out quickly ends the preview there, and a header or footer that long is left out; each
says **Preview limited**. Open the file in Word or PowerPoint for the rest. An open file
reloads only when the file itself changes, not each time the agent runs a command, and a
file opened again returns to the page and zoom it was left at. The last two PDF, Word or
PowerPoint files you left in the file panel stay open in the background, so switching back to
one shows it exactly as you left it, without drawing it again. Scient keeps them within a memory
budget that follows your computer's memory; a very long document may be opened afresh instead.
A file changed while you were away shows its new version when you come back.

To save a project Markdown file as a PDF, expand the editor's formatting tools
and choose **More actions → Export → PDF**. Scient saves your latest edits,
exports exactly that saved version with its project images, and asks where to
save the PDF; choose **Open** on the notice to read it in Scient's reader. Front
matter at the top of the file is not printed; its `title`, if any, titles the
PDF. Missing, remote, or unreadable images appear as labelled placeholders and
are listed under **Export notes** at the end of the PDF. On Windows, the PDF
leaves out the file's project images for now and lists them in the notes. PDF
export needs the Scient desktop app; in a browser the menu item explains that
it is unavailable. An agent can do the same for a file you name with an explicit
output path, except on Windows.

Choose **More actions → Export → Word** instead for an editable `.docx` of the
saved file (Word export needs Pandoc; the first export offers to install it).
Images that cannot be embedded appear as labelled placeholders and are listed in
the **Exported with notes** notice. On Windows, as with PDF, Word leaves out the
file's project images, and any bibliography file its front matter names, for now
and lists them there; the rest of the document exports.

In a project conversation, an agent can also turn an existing project HTML file
into a PDF. Scient builds it with local project assets, opens the generated PDF
in its reader, and preserves the HTML as the editable source. Remote assets are
not loaded during this controlled build, so keep required styles, fonts, data,
and images inside the project. A compatible Scient Desktop must be connected
while Scient performs this Chromium build.

Direct files outside the current project support:

- images, including SVG, with pan and zoom;
- PDFs in the full Scient reader, including remembered reading state;
- rendered Markdown, including math, Mermaid diagrams, and Vega-Lite charts;
- syntax-highlighted source and text, including TSX, Python, MATLAB, R, JSON,
  CSV, and LaTeX source;
- browser-supported audio and video; and
- a stable file-information view for formats that do not yet have a rich
  preview. On the primary desktop environment, the header can still open the
  file in a preferred editor.

Text previews are read-only and limited to 2 MiB. Large files show that limit
explicitly. An optional line target is revealed once after the source view is
ready.

HTML runs normally in Scient's integrated browser, including JavaScript,
network requests, navigation, and relative local CSS, scripts, fonts, data,
images, and media. A packaged site that assumes it is hosted at a web-server
root (for example, references `/assets/app.js`) should be opened through its
development or static server; a standalone local document should use relative
asset paths.

"In the connected environment" is important for remote sessions: an absolute
path refers to the remote host, not the desktop Mac or PC. Remote files can be
previewed through Scient, but desktop-only editor actions are not shown.
