251 Commits

Author SHA1 Message Date
claude 8b7da8296c fix: pass session token so anonymous users can install python packages
Build and Deploy Verso / deploy (push) Successful in 14m23s
Build and Deploy Verso (prod) / deploy (push) Successful in 3m55s
userCanInstallPython passed null as the token, so anonymous users
accessing via a share link got privilege level NONE from the WithoutUser
path and allowPythonInstall was always false for them.

Read the token from req.session.anonTokenAccess via
TokenAccessHandler.getRequestToken and forward it through
userCanInstallPython to getPrivilegeLevelForProject.  For TOKEN_BASED
projects this resolves the anonymous user's access level via
getPrivilegeLevelForProjectWithToken, enabling package installation.

Also update Quarto Slides badge color to #e4637c.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 09:17:30 +00:00
claude e6773c6baf fix: read stored project compiler for quartoFlavor update
Build and Deploy Verso / deploy (push) Successful in 20m28s
options.compiler is set from req.body.compiler which the frontend never
sends, so the condition was never true and quartoFlavor was never written.
Use ProjectGetter to read the stored compiler instead. Fire-and-forget so
it does not delay the compile response.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 08:48:25 +00:00
claude 2c8dad08f6 project-list: show plain 'Quarto' badge when quartoFlavor is unset
Build and Deploy Verso / deploy (push) Successful in 13m55s
Existing projects have no quartoFlavor value in the database (new field),
so defaulting to 'Quarto PDF' incorrectly labelled all of them. Show the
plain 'Quarto' label until the first compile sets the flavor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 08:30:34 +00:00
claude 7fecaf491a compile: allow python package install for all users who can access the project
Build and Deploy Verso / deploy (push) Successful in 9m23s
Previously userCanInstallPython used ignorePublicAccess: true, which
blocked token-link users (not-yet-joined) and logged-in readers of public
projects from installing packages. This caused Quarto presentations with
Python cells to fail for shared read-only users even when the required
packages were already listed in requirements.vrf.

The security model is: what gets installed is fully controlled by
requirements.vrf, which is only writable by members with write access.
There is therefore no security reason to block other readers from
triggering installation of already-approved packages.

Drop ignorePublicAccess so all users with any privilege level (direct,
token-based, or public-project) can trigger the venv install.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 08:20:46 +00:00
claude 9c7a10aa39 fix: correct import path and minor issues in quartoFlavor update
Build and Deploy Verso / deploy (push) Successful in 13m44s
- Fix wrong import path '../models/Project.mjs' → '../../models/Project.mjs'
  (from Features/Compile/, '..' is Features/, not src/; the server would
  crash on startup with ERR_MODULE_NOT_FOUND in Node.js ESM)
- Log MongoDB errors instead of silently swallowing them
- Remove null from Mongoose String enum (not a valid enum value for strings)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 08:06:00 +00:00
claude bbf532d282 project-list: distinguish Quarto PDF vs Quarto Slides in format badge
Build and Deploy Verso / deploy (push) Successful in 9m30s
Add a quartoFlavor field ('revealjs' | 'pdf') to the Project model.
After each successful Quarto compile, CompileController detects the output
type (output.html → revealjs, otherwise pdf) and persists it.
ProjectListController includes it in the projection and serialization so
it reaches the frontend without an extra round-trip.

Badge variants:
  - quartoFlavor unset (new/uncompiled) → "Quarto PDF" #447099
  - quartoFlavor 'pdf'                  → "Quarto PDF" #447099 (Quarto blue)
  - quartoFlavor 'revealjs'             → "Quarto Slides" #7e56c2 (purple)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 07:55:45 +00:00
claude eada1e9979 file-tree: show python packages button for all quarto projects
Build and Deploy Verso / deploy (push) Successful in 13m42s
The previous approach (pdfFile?.path === 'output.html') caused a
chicken-and-egg problem: the button only appeared after a successful
RevealJS compile, but you need to add packages before the first compile.

Use compiler === 'quarto' from ProjectSettingsContext instead — this is
set from project metadata and available immediately, before any compile.
Quarto supports Jupyter Python cells in all output formats (RevealJS HTML,
PDF via LaTeX, PDF via Typst), so showing the button for any Quarto project
is the correct behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 07:41:21 +00:00
claude 2f88ad124d ui: correct LaTeX badge to Overleaf button green #098842
Build and Deploy Verso / deploy (push) Successful in 13m47s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 07:05:08 +00:00
claude a398127522 ui: brand badge colors and hide python packages for non-revealjs
Build and Deploy Verso / deploy (push) Successful in 13m8s
- LaTeX badge: #13c965 (Overleaf brand green, from upstream overleaf/overleaf)
- Typst badge: #239dad (Typst brand blue/teal, from typst.app)
- Python packages toolbar button: only shown when the compiled output is
  output.html, i.e. a Quarto RevealJS presentation.  Uses the same
  pdfFile?.path === 'output.html' check as PresentationPreviewButton.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 06:51:30 +00:00
claude 083b195462 typst: support '+' binary operator in arg values
Build and Deploy Verso / deploy (push) Successful in 9m27s
stroke: 0.8pt + brand broke arg-list parsing because '+' was not a grammar
terminal. The parser exited CodeArgs via error recovery, so subsequent
named args (radius:, inset:, fill:) were never seen as CodeArgKey.

Add codeArgValue { codeValue | codeArgValue !add "+" codeValue } — a
left-recursive inline rule used only inside CodeArgs.  The !add cut point
gives the shift strict dominance over the reduce (prec add > 0 vs 0), so
a '+' after a value greedily extends the expression.  Because codeArgValue
only appears inside CodeArgs, the codeStatement* LALR-merging that caused
trouble for the earlier callSuffix* approach does not apply here.

Also add PLUS to codeIdentTokenizer's valid-predecessor list so identifiers
after '+' (the right-hand operand) are correctly tokenized as CodeIdent.
Add "+" to @tokens @precedence so it beats MarkupContent in merged states.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 06:07:32 +00:00
claude 0656ddfe52 fix(typst): highlight keywords/idents inside #{} code blocks
Build and Deploy Verso / deploy (push) Successful in 9m32s
Replace the opaque CodeBlockBody external tokenizer with grammar-parsed
codeStatement* so that keywords (show, let, set, …) and identifiers
inside #{ } code blocks receive proper Lezer nodes and are highlighted.

Key grammar changes:
- CodeBlock { "{" codeStatement* "}" } — structured, not opaque
- codeStatement uses two explicit alternatives for keyword lines:
    CodeKeyword !kw callOrValueAndBody  (grabs the subject eagerly)
    CodeKeyword keywordBody?            (bare keyword or body-only form)
  The !kw cut-point gives shift prec kw > 0 over the unannotated reduce,
  resolving the LALR merge ambiguity without @left/@right on kw.
- callOrValue { FuncExpr | CodeIdent | CodeString } — replaces CallExpr
  { CodeIdent !call callSuffix* }.  The * quantifier annotated both
  shift and reduce with !call, making them a same-prec tie that @right
  could not reliably resolve in merged states.  Using FuncExpr (required
  callSuffixes) + bare CodeIdent makes the tie strict (call > 0 for
  FuncExpr shift vs 0 for bare-ident reduce), then @right handles only
  the extension-of-callSuffixes case (shift = call<<2, FuncExpr reduce
  = call<<2 - 1 via @right encoding).
- KeywordExpr gets the same two-alternative structure as codeStatement
  so nested show/set/let inside a code block (e.g. show sel: set text)
  also parse without LALR state-merge conflicts.
- CallExpr removed; its role is split between FuncExpr (has args/chain)
  and bare CodeIdent (no args).  Styling updated: CodeExpr/CodeIdent
  replaces CallExpr/CodeIdent for bare #ident function-style highlights.
- codeKeywordTokenizer and codeIdentTokenizer already accept keywords /
  identifiers after { and ; (added in previous commit) — consistent with
  the new grammar.

Parse results:
  #{ show strong: link.with(url); body }
  → CodeKeyword "show", CodeIdent "strong", FuncExpr "link.with(url)",
    CodeIdent "body" — all properly highlighted, no ⚠ errors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 21:47:21 +00:00
claude 056d9a7f47 fix(typst): add CodeArray so tuple args don't break nested call parsing
Build and Deploy Verso / deploy (push) Successful in 9m44s
align: (left, center, left) is a Typst array literal.  Without a grammar
rule for it, the parser treated the ')' closing the tuple as the ')' closing
the enclosing function call, so everything after align: — all ContentBlock
args and any subsequent named keys like 'caption:' — fell outside the parsed
call tree and was highlighted as MarkupContent.

Add CodeArray { "(" codeArgList? ")" } as a codeValue alternative so
parenthesised arrays and dictionaries parse correctly.  Also regenerate
typst.mjs / typst.terms.mjs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 20:13:38 +00:00
claude 8ed44cc352 fix(typst): style CodeArgKey via HighlightStyle, not theme CSS
Build and Deploy Verso / deploy (push) Successful in 13m38s
The tok-attributeName CSS class relies on each theme defining it, but
26 of 41 themes never had it. Defining the colour directly in
typstHighlightStyle (like we do for heading/strong/emphasis) applies
it universally regardless of which theme is active.

Amber #c47900 is legible on both light and dark backgrounds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 19:56:20 +00:00
claude 52ebff6286 debug(typst): force arg keys bright red to confirm token pipeline
Build and Deploy Verso / deploy (push) Successful in 10m0s
Adds { tag: t.attributeName, color: '#cc0000', fontWeight: 'bold' } to
typstHighlightStyle so named arg keys are unmistakably red if the
CodeArgKey token is reaching the highlighter.  Will be removed once
the pipeline is confirmed working and replaced with per-theme colors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 19:41:57 +00:00
claude 7c0ec9dd39 fix(typst): commit compiled grammar so CI always uses current parser
Build and Deploy Verso / deploy (push) Successful in 13m45s
The webpack plugin that compiles typst.grammar may silently skip
recompilation when file mtimes are ambiguous in Docker BuildKit layers.
Committing typst.mjs and typst.terms.mjs guarantees the build always
ships the correct parser without depending on build-time generation.

To regenerate after grammar changes:
  node -e "const {buildParserFile}=require('/tmp/lezertest/...'); ..."
  (or: yarn run lezer-latex:generate from services/web)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 19:02:16 +00:00
claude e9a34a5bd8 fix(typst): exclude ] from MarkupContent so ContentBlock always closes
Build and Deploy Verso / deploy (push) Successful in 13m35s
The core bug: MarkupContent { ![...]+ } did not exclude ']', so inside
#figure(table([A],[B]), caption:[...]) the tokenizer consumed ']' as
MarkupContent, ContentBlocks never closed, and all remaining args like
'caption:' were swallowed as MarkupContent instead of CodeArgKey.

Fix mirrors the LaTeX grammar pattern (its Normal token excludes \] and
\[): add ']' to MarkupContent's exclusion set and provide ClosingSquare
{ "]" } as an item alternative for bare ']' in body text.  The grammar's
existing @precedence { "]" ClosingSquare } ensures "]" wins and closes
the ContentBlock; outside a ContentBlock only ClosingSquare is valid.

Also change URL style tag from t.url (tok-url, unstyled in all themes)
to t.string (tok-string, styled in every theme).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 18:33:20 +00:00
claude f9fc0d9905 typst: fix URL comment split and heading label highlighting
Build and Deploy Verso / deploy (push) Successful in 13m56s
- Add URL token (https://... / http://...) so '://' is never split into
  ':' + LineComment '//', preventing URLs from being styled as comments
- Stop headingTitleTokenizer before '<label>' patterns so labels at the
  end of headings get Label node styling instead of being consumed as
  heading title text
- Style URL nodes with t.url tag

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 17:38:32 +00:00
claude d7ca7b194d feat(typst): parse show-rule bodies, let-value bindings, and content-block call args
Build and Deploy Verso / deploy (push) Successful in 14m13s
Three grammar gaps caused large blocks of code to be unhighlighted:

1. KeywordExpr now accepts an exclusive keywordBody: '#show sel: body' is
   parsed via ':', and '#let name = value' via '='.  callOrValue extends
   the subject to include CodeString so '#import "pkg"' highlights the path.

2. ContentBlock added to callSuffix so '#func("arg")[content]' and
   '#next-step("url")[...]' parse their trailing content block as code
   rather than falling back to markup.

3. Tokenizer: COLON added as a valid predecessor so identifiers (e.g. 'blue'
   in 'fill: blue') and keywords (e.g. 'set' in '#show link: set text(...)')
   are recognised after ':'.  EQUALS already added in the previous commit.
   The ident-chain backward scan now also skips whitespace before testing for
   '#' or ':', enabling 'text' in 'set text' to trace back to '#' through the
   keyword gap.  @precedence updated with CodeString, '[', ':' to resolve
   overlapping-token conflicts with MarkupContent in merged states.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 14:57:21 +00:00
claude 47cf84f20b fix(typst): highlight named arg keys after complex nested calls
Build and Deploy Verso / deploy (push) Successful in 13m48s
canShift(CodeIdent) returns false in LALR-merged states that arise after
reducing a complex first argument (e.g. figure(table(...), caption: ...)).
The previous guard `!couldBeIdent && !canShift(CodeArgKey)` then caused
an early exit before the character-level scan ran, silently dropping the
CodeArgKey token for any named arg key that follows such a reduction.

Fix: run the backward character scan first and derive `couldBeArgKey`
from the raw predecessor char ('(' or ',') rather than from canShift.
The early-exit now reads `!couldBeIdent && !couldBeArgKey`, so arg-key
positions always proceed to the full scan regardless of parser state.
Also stop calling canShift(CodeArgKey) entirely — it is unreliable here.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 13:57:10 +00:00
claude 2d3e64da92 themes: add tok-attributeName color to 15 themes that were missing it
Build and Deploy Verso / deploy (push) Successful in 14m6s
The Typst grammar now emits CodeArgKey (mapped to tok-attributeName) for
named argument keys like 'columns:', 'align:', 'caption:'.  15 of 41
editor themes had no .tok-attributeName rule, so those keys appeared in
the default text color (black) despite the correct CSS class being set.

Chose colors that complement each theme's existing palette:
light themes → warm dark-orange family (#994409 / #7B3814 / #735C0F)
dark themes  → each theme's accent color (gold, warm red, lavender…)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 13:28:09 +00:00
claude 2db6e63162 typst: fix CodeArgKey detection using character-level context
Build and Deploy Verso / deploy (push) Successful in 9m31s
canShift(CodeArgKey) was consistently returning false because LALR
state merging folds the codeArgItem start state into others where
CodeArgKey is not in the valid set.  As a result, named arg keys like
'columns:', 'align:', 'caption:' were always falling through to
CodeIdent (black) instead of CodeArgKey (tok-attributeName).

Fix: detect named arg key position by inspecting the nearest
non-whitespace predecessor character instead of trusting canShift.
prev == '(' or ',' means we are inside a call argument list — the only
positions where a named arg key can appear.  prev == last char of a
keyword word (e.g. 'w' of 'show') correctly excludes '#show heading:'
from being treated as a named arg.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 12:38:05 +00:00
claude f2b7034b51 typst: distinguish function calls from value identifiers; fix math outline
Build and Deploy Verso / deploy (push) Successful in 9m49s
Named value identifiers like 'left', 'center', 'right' were being
highlighted as tok-function (blue) because codeValue used CallExpr
(callSuffix*), which styled any identifier in value position as a
function.  Fix: add FuncExpr { CodeIdent callSuffix+ } (requires at
least one argument list or method suffix) and use it in codeValue
instead of CallExpr.  Plain identifiers in value position now fall
through to CodeIdent → tok-variableName.  CallExpr (callSuffix*) is
kept for codeExprBody and KeywordExpr where zero-suffix idents are
valid.

Tokenizer safety: only acceptToken(CodeIdent) when canShift(CodeIdent)
is true, preventing emission in LALR-merged states where neither
CodeArgKey nor CodeIdent is expected.

Outline: track '$'-parity across lines so that lines inside a display
math block (e.g. '= b+c$') are not incorrectly reported as headings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 12:04:33 +00:00
claude 4c6032bce0 typst: fix named-arg key highlighting and multi-line math
Build and Deploy Verso / deploy (push) Successful in 13m41s
Named arg keys (columns:, align:, caption:) were appearing in black
because LALR state merging broke the CodeArgs/CodeIdent path for
multi-line expressions.  Fix: emit a dedicated CodeArgKey token from
codeIdentTokenizer (forward-peek for ':' to pre-disambiguate), declare
it in the grammar's codeArgItem rule, and map it to t.attributeName in
styleTags — bypassing LALR lookahead entirely.

Multi-line display math ($ ...\n... $) was consuming the rest of the
document as orange text when contextual:true caused a backward scan to
find a previous closing '$' and falsely set isDisplay=true.  Fix:
revert mathContentTokenizer to contextual:false with '\n' stop (each
MathContent token covers one line), and change InlineMath to
MathContent* so @skip consumes the newlines between lines.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 11:25:31 +00:00
claude 2fdb155547 fix(typst): support multi-line display math ($...$)
Build and Deploy Verso / deploy (push) Successful in 9m44s
mathContentTokenizer now detects inline vs display math by scanning back
to the opening '$': if @skip consumed whitespace between '$' and the
content the tokenizer removes the newline stop (display math), otherwise
it keeps it (inline math).  contextual: true prevents the tokenizer from
firing outside InlineMath entirely, avoiding the orange-body-text
regression seen when this was previously attempted without the guard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 10:52:29 +00:00
claude 75bc3bcc73 fix(typst): highlight idents after #keyword and wire tok-attributeName
Build and Deploy Verso / deploy (push) Successful in 9m34s
- codeIdentTokenizer: extend guard to scan back through the keyword word
  and accept when '#' immediately precedes it, so 'text' in '#set text(...)'
  and 'heading' in '#show heading:' are highlighted as function names
- classHighlighter: add tags.attributeName → tok-attributeName mapping;
  all 26 themes already define .tok-attributeName colours but the tag was
  never mapped to the class, leaving named arg keys (columns:, caption:)
  completely unstyled

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 09:18:31 +00:00
claude 1b773fdda0 fix(typst): add newlines to @skip so multi-line code args parse cleanly
Build and Deploy Verso / deploy (push) Successful in 9m31s
'\n' inside CodeArgs was an invalid token, triggering Lezer error recovery
and resetting parser state before codeIdentTokenizer could fire.  Heading
detection is unaffected — headingTokenizer uses raw input.peek(-1) char
reads which see the '\n' byte regardless of what @skip consumes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 08:47:47 +00:00
claude 019b4041a8 fix(typst): highlight function names across newlines in code args
Build and Deploy Verso / deploy (push) Successful in 9m35s
codeIdentTokenizer's backward scan stopped at \n, so identifiers at the
start of a new indented line inside multi-line arg lists (e.g. image(),
table() inside #figure(...)) never matched the '(' guard and stayed black.
Extend the whitespace skip to also cross newlines.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 07:28:43 +00:00
claude 4aca4aaac6 fix: make CodeIdent external and replace strongItem*/emphItem* with flat body tokens
Build and Deploy Verso / deploy (push) Successful in 13m36s
Two LALR state-merging bugs prevented Strong/Emphasis nodes from ever being
produced (confirmed: tok-strong/tok-emphasis count = 0 in browser diagnostic).

Bug 1 — _italic_ consumed as CodeIdent:
  CodeIdent was a @tokens rule with identHead = [A-Za-z_], so '_italic_' (the
  entire string including both underscores) matched as one CodeIdent token.
  LALR merging caused CodeIdent to be in item*'s valid set, and CodeIdent >
  "_" in @precedence, so the parser never opened Emphasis.

  Fix: move CodeIdent to an external tokenizer (codeIdentTokenizer) with a
  character-level guard — only fires when the preceding non-whitespace char
  is one of '#', '.', '(', ',' (genuine code-context positions).  In body
  text where peek-back finds a newline, space, or markup delimiter, the
  tokenizer returns without emitting, letting '"_"' open Emphasis correctly.

Bug 2 — StrongText never produced inside Strong:
  The strongItem* / emphItem* loops merged with item* states via Lezer's
  aggressive LALR merging.  In the merged state MarkupContent was in the
  valid set (from the item* side) and MarkupContent > StrongText in
  @precedence, so MarkupContent was always produced — not a valid strongItem,
  leading to error recovery with no StrongText in the tree.

  Fix: replace the recursive strongItem* / emphItem* loops with flat external
  tokens StrongBody / EmphBody (contextual: true).  These fire only inside
  Strong → "*" . StrongBody? "*" and Emphasis → "_" . EmphBody? "_", states
  specific enough that canShift is reliable.  They read everything up to the
  closing delimiter or newline in one token, bypassing the LALR merging
  entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 22:15:22 +00:00
claude f9d46aabeb fix: revert mathContentTokenizer regression (contextual + no-newline-stop)
Build and Deploy Verso / deploy (push) Successful in 9m43s
The previous change switched mathContentTokenizer to contextual:true with no
newline stop, intending to support multi-line Typst block math.  However,
LALR state merging causes canShift(MathContent) to spuriously return true in
body-text positions (e.g. after a RawInline backtick close), so the tokenizer
consumed everything until the next '$' — turning a full paragraph orange.

Revert to contextual:false with newline stop.  This correctly handles both
inline ($x^2$) and single-line block ($ integral ... $) math.  Multi-line
block math ($ formula\n continuation $) remains a separate issue for later.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 21:50:15 +00:00
claude 54ab282efc Fix Typst: support multi-line math blocks ($ ... multi-line ... $)
Build and Deploy Verso / deploy (push) Successful in 14m1s
mathContentTokenizer was stopping at newlines, causing a parse error for
Typst block math that spans multiple lines.  The parser then entered a bad
state that cascaded: the stale error-recovery left the item* parser in a
degraded mode, causing body text below the math block to be highlighted as
t.string (orange).

Fix: switch to contextual: true (only fires inside InlineMath where
MathContent is actually expected) and remove the newline restriction so
the tokenizer reads until the closing '$' regardless of line boundaries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 21:03:17 +00:00
claude f976c5ba92 Fix Typst: bold/italic rendering and keyword false-highlights in body text
Build and Deploy Verso / deploy (push) Successful in 14m15s
Add .tok-strong and .tok-emphasis CSS to the static editor theme so
bold/italic markup actually renders visually.

Move CodeKeyword from @tokens to an external tokenizer (codeKeywordTokenizer)
with a peek(-1)==='#' guard. LALR state-merging causes code-mode states to be
reachable in markup positions, making common English words like "in", "for",
"while", "return" trigger CodeKeyword highlighting in body text. The '#' guard
ensures keywords only fire immediately after the '#' sigil, never in prose.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 20:20:02 +00:00
claude f5a94c0ced fix(typst): guard RawBlockBody against LALR-merged body-text states
Build and Deploy Verso / deploy (push) Successful in 10m0s
canShift(RawBlockBody) returns true in states LALR-merged with the
post-RawBlockOpen state, causing the tokenizer to consume all remaining
body text as one giant RawBlockBody. Add a backward character scan:
require newline immediately before input.pos, then walk back past any
lang tag (A-Za-z0-9) and verify three backticks precede it. Body-text
positions never have backtick-backtick-backtick there, so the guard
rejects them.

This was the root cause of everything after the first heading being
black: RawBlockBody swallowed the entire document from the user-name
line onward, making headings, bold, italic and math invisible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 19:44:05 +00:00
claude 11d852fe18 Revert "chore: add browser diagnostic script for Typst highlighting"
Build and Deploy Verso / deploy (push) Successful in 1m15s
This reverts commit 8c9088d054.
2026-06-08 19:29:46 +00:00
claude cc0d97903c Revert "chore: fix CodeMirror view accessor in diagnostic script"
This reverts commit 5850ffcad7.
2026-06-08 19:29:46 +00:00
claude 5850ffcad7 chore: fix CodeMirror view accessor in diagnostic script
Build and Deploy Verso / deploy (push) Successful in 1m4s
2026-06-08 19:27:06 +00:00
claude 8c9088d054 chore: add browser diagnostic script for Typst highlighting
Build and Deploy Verso / deploy (push) Successful in 1m12s
2026-06-08 19:21:30 +00:00
claude 974a9c4fb3 fix(typst): restore HeadingMark+HeadingTitle with character-level bleed guard
Build and Deploy Verso / deploy (push) Successful in 10m0s
The single-HeadingLine token approach caused everything after the first
heading to be unparsed. Reverting to the two-token structure but adding a
backward character scan in headingTitleTokenizer: after canShift(), walk
backward past whitespace and require '=' immediately before the current
position. Body-text positions in LALR-merged states will have a letter or
closing bracket there instead, so the tokenizer returns without accepting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 18:17:17 +00:00
claude 34025dc084 fix(typst): use HeadingLine single token to fix inline element highlighting
Build and Deploy Verso / deploy (push) Successful in 9m35s
The two-token approach (HeadingMark + HeadingTitle) caused LALR state
merging: the parser state waiting for HeadingTitle after HeadingMark was
merged into body-text item* states. In those merged states the
headingTitleTokenizer fired for every paragraph line, swallowing bold,
italic, math and inline function tokens — leaving body text black.

Fix: collapse the heading into a single HeadingLine external token that
covers the entire heading line (= prefix + title). A single-token Heading
rule leaves no post-token parser state waiting for a second token, so no
LALR merging can occur. The ViewPlugin and all HeadingMark/HeadingTitle
infrastructure are removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 16:55:09 +00:00
claude 0099672015 fix(typst): restore HeadingTitle token to fix broken syntax highlighting
Build and Deploy Verso / deploy (push) Successful in 10m12s
Removing HeadingTitle from the grammar left HeadingTitle? undeclared,
causing the Lezer grammar compiler to fail and producing no parser
output — hence everything rendered as unstyled black text.

Dual approach to prevent heading style bleed:
- HeadingTitle exists in grammar with contextual: true + canShift guard
  (prevents it from matching in body-text LALR states)
- HeadingTitle is intentionally absent from styleTags so even spurious
  matches cannot apply heading colour to body text
- ViewPlugin styles heading titles by finding HeadingMark nodes and
  extending tok-heading decoration to end-of-line

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 15:38:38 +00:00
claude a5ca432396 Fix heading bleeding and smooth_pdf_transition translation
Build and Deploy Verso / deploy (push) Successful in 13m35s
Two fixes:

1. Heading style bleeding (Typst): the HeadingTitle external token approach
   was unreliable — even with contextual:true and canShift(), body text was
   being styled as headings. Remove HeadingTitle from the grammar entirely.
   Instead, a ViewPlugin (headingLinePlugin in languages/typst/index.ts)
   walks the syntax tree, finds HeadingMark nodes, and decorates the rest of
   the line with tok-heading class + bold. This is unconditionally correct
   because it is based on the syntax tree rather than the LR tokenizer state.

2. smooth_pdf_transition raw key shown in all locales: the key was in the
   JSON locale files but missing from extracted-translations.json, which is
   the allowlist the webpack translation loader uses to decide what to bundle.
   Add it there so all locales (including fr, es, de already added) resolve
   to their translated strings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 14:22:16 +00:00
claude f1abcaa4ce Hide LaTeX-only compile options for Typst/Quarto projects; add smooth_pdf_transition translations
Build and Deploy Verso / deploy (push) Successful in 9m35s
Draft compile mode and stop-on-first-error are LaTeX-only features not
supported by TypstRunner or QuartoRunner. Hide both sections from the
recompile dropdown for non-LaTeX projects. Also detect Quarto root files
(.qmd/.md/.Rmd) alongside Typst (.typ) to correctly set isLatexProject.

Add missing smooth_pdf_transition translations for French, Spanish, and
German (the English key already existed).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 13:45:02 +00:00
claude 1c323351a2 fix: parse Quarto schema YAML errors and stop heading style bleeding
Build and Deploy Verso / deploy (push) Successful in 9m46s
Two unrelated fixes:

1. quarto-log-parser: handle the two-line Quarto schema-validation
   error format:
     ERROR: In file main.qmd
     (line 6, columns 24--27) Field "section-numbering" has value …
   Previously neither the file name nor the line number were extracted,
   so the error appeared without a red highlight. Now the first line
   stores the filename in pendingLocation and the second line creates
   the log entry with the correct file and line so the editor can jump
   to and highlight it.

2. headingTitleTokenizer: change contextual: false → contextual: true
   and guard with stack.canShift(HeadingTitle). With contextual: false
   Lezer calls the tokenizer speculatively at positions beyond the strict
   post-HeadingMark state; in some LALR-merged states the resulting token
   was accepted for body-text lines, making them render as bold-blue
   heading text. The contextual guard ensures the tokenizer only fires
   in the one state where HeadingTitle is legitimately valid.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 13:31:26 +00:00
claude 55e8208892 chore: add TODO.md with next-alpha Typst experience ideas
Build and Deploy Verso / deploy (push) Successful in 13m41s
Two ideas borrowed from the Collabst project (a Typst-native
collaborative editor): typst.ts WASM in-browser preview and Tinymist
LSP integration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 12:26:07 +00:00
claude b8543c8bb9 fix: capture typst diagnostics emitted after the status line
Build and Deploy Verso / deploy (push) Has been cancelled
typst watch outputs the "[HH:MM:SS] compiled with errors" status line
FIRST, then the full diagnostic output (file:line:col, source snippets,
hints) AFTERWARDS. The previous code resolved the pending compile
promise as soon as COMPILE_DONE_RE fired, discarding all post-status
diagnostic lines. Those lines then got cleared by the next cycle's
COMPILE_START_RE, so output.log only ever contained the bare status
line — explaining the "zero verbosity" symptom.

Fix: introduce a two-phase buffering model. When COMPILE_DONE_RE fires,
enter "post-done" phase (storing doneResult) and keep accumulating into
currentLines. _finalizeCompile() is called either when the next
COMPILE_START_RE arrives (zero added latency) or after FLUSH_DELAY_MS
(150 ms fallback for the last compile). It concatenates pre-done and
post-done lines before resolving, so output.log now contains the full
diagnostic output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 12:25:43 +00:00
claude 7e6c8c30cc fix: cache typst compile result to eliminate race-condition failures
Build and Deploy Verso / deploy (push) Successful in 14m6s
When typst watch detects a file change and compiles before the CLSI
resolver is registered (ResourceWriter writes files → typst compiles →
runTypst is called), _resolveAllPending was discarding the result
because pendingResolvers was empty. This caused two symptoms:

1. output.log only contained "compiled with errors" (no diagnostics)
   because the result carrying the full stdout was thrown away.

2. Every other manual compile failed with "compilation already gone"
   because the missed result caused a timeout, which killed the watcher
   and triggered a watcher restart cycle (success → miss → timeout →
   kill → restart → success → miss → ...).

Fix: when _resolveAllPending fires with no pending resolvers, store the
result in entry.pendingResult. _waitForNextCompile checks this field
first and resolves immediately if a cached result is present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 11:48:46 +00:00
claude e0c717c131 fix: suppress interim compile errors while typing, show Typst error logs, dark-mode footer
Build and Deploy Verso / deploy (push) Successful in 1m43s
- local-compile-context: suppress failure/exited error state when
  changedAt > 0 (another compile is already queued), preventing the UI
  from flashing an error banner mid-typing that resolves moments later

- TypstRunner + CompileController: detect "compiled with errors" from
  typst watch and non-zero exit from typst compile, and signal
  status:'failure' to the frontend so the log panel opens automatically
  with the parsed error details (previously always returned 'success')

- footer.scss: add dark-mode overrides for footer.site-footer so the
  thin footer on project/marketing pages uses bg-dark-primary and
  content-primary-dark text in dark theme instead of hardcoded light bg

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:19:36 +00:00
claude 7a5218d472 typst: fix CodeIdent vs "_" token overlap after #keyword CallExpr?
Build and Deploy Verso / deploy (push) Failing after 8m41s
KeywordExpr { CodeKeyword CallExpr? } merges the post-keyword LR state
with document-level markup states, where "_" opens Emphasis.  CodeIdent
starts with identHead which includes "_", so the two tokens overlap.

Adding "_" after CodeIdent in @precedence resolves the conflict: CodeIdent
wins in the merged state (correct for '#set _name(...)'), and in pure markup
states CodeIdent is not in the valid set so "_" still opens Emphasis.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:16:35 +00:00
claude b16b096744 projection: visit overlay/mounted subtrees during tree iteration
Build and Deploy Verso / deploy (push) Successful in 22m39s
yamlFrontmatter() embeds the Markdown content as an overlay on the top-level
YAML-frontmatter tree.  The previous mode (IgnoreMounts | IgnoreOverlays)
skipped that overlay entirely, so ATXHeading nodes were never visited and the
Quarto (.qmd) file outline was always empty.

Dropping the mode flag lets the iterator descend into overlay and mounted
subtrees.  This is safe because every enterNode function already filters by
node name — visiting extra nodes from foreign-language mounts is a no-op.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:03:43 +00:00
claude e9cc63a261 typst: highlight function name after #set / #show keywords
Build and Deploy Verso / deploy (push) Has been cancelled
KeywordExpr now optionally includes a CallExpr, so '#set text(size: 12pt)'
parses 'text' as a CallExpr/CodeIdent and gets the function-name highlight
colour.  The optional CallExpr only shifts when the lookahead is CodeIdent,
so there is no shift/reduce conflict with other items.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 08:40:28 +00:00
claude 07c72cf7e5 typst: stop heading title at // or /* comment markers
Build and Deploy Verso / deploy (push) Successful in 9m24s
headingTitleTokenizer now stops reading when it encounters '//' or '/*',
so '= Heading // note' correctly produces a HeadingTitle token for 'Heading'
and a LineComment for the rest of the line.  Without this, the comment was
consumed into HeadingTitle, getting heading highlight and appearing verbatim
in the file outline.

Also strip trailing line comments from heading titles in the regex-based
document outline scanner, which reads raw text independently of the tree.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 08:27:02 +00:00
claude 4f98abbc5d classHighlighter: map function(variableName) to tok-function
Build and Deploy Verso / deploy (push) Has been cancelled
All cm6 themes define .tok-function but the classHighlighter had no entry
for tags.function(tags.variableName), so function-name tokens fell back to
tok-variableName (which themes leave unstyled).  This affected Typst function
calls (#func(...)) and would affect any future language that tags function
names with t.function(t.variableName).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 08:21:16 +00:00
claude 1dcd6e24f4 lezer-typst: convert LineCommentContent and MathContent to external tokenizers
Build and Deploy Verso / deploy (push) Successful in 10m10s
Both tokens are "read until delimiter" catchalls that match almost every
non-newline character, causing buildTokenGroups conflicts with every other
literal token in LALR-merged states.  Moving them to ExternalTokenizer (the
same pattern already used for HeadingTitle, RawBlockBody, etc.) makes them
context-isolated: the LR state machine only calls them when those tokens are
actually valid, so they never participate in the static token-group overlap
check.

Also exclude '<' from StrongText/EmphText so Label ('<' LabelName '>') is
recognised inside strong/emphasis spans rather than being consumed as plain
text.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 07:56:20 +00:00
claude e21f7cc0d5 fix(typst): resolve all overlapping-token errors via @precedence
Build and Deploy Verso / deploy (push) Has been cancelled
Lezer's buildTokenGroups rejects grammars with ambiguous token sets.
Eight overlaps existed:

  EscapeChar vs spaces       — EscapeChar { _ } matches \t; after '\'
                               it must win over the @skip spaces token.
  "(" / "." vs text tokens   — in the LALR-merged state after #CodeIdent,
                               callSuffix delimiters must beat
                               MarkupContent / StrongText / EmphText.
  "]" vs LineCommentContent  — inside #[...], the ContentBlock closer
                               must win even if it follows "//".

One extended @precedence declaration resolves all eight.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 07:41:03 +00:00
claude e4f5385e35 fix(typst): fix zero-length token error for LineCommentContent
Build and Deploy Verso / deploy (push) Has been cancelled
LineCommentContent { ![\n]* } matches the empty string, which Lezer
rejects as a zero-length token (infinite-loop risk). Change to ![\n]+
and mark it optional in the LineComment rule so empty // comments parse.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 06:54:56 +00:00
claude 2f3e3e7363 fix(typst): make HeadingTitle an external token to end LALR conflicts
Build and Deploy Verso / deploy (push) Has been cancelled
Any item shared between headingTitleItem and document-level item causes
a shift/reduce conflict: the LALR automaton merges the two contexts and
makes the shared token ambiguous. The only structural fix is to make
HeadingTitle a terminal (external tokenizer) that reads greedily to EOL,
giving the LR state machine a context-isolated token that can never
collide with document-level item tokens.

Removes headingTitleItem sub-rule, HeadingText token, and updates
styleTags to match HeadingTitle directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 21:14:18 +00:00
claude 94e8ff3503 fix(typst): eliminate LALR(1) conflict on heading title items
Build and Deploy Verso / deploy (push) Failing after 3h10m10s
Removing Strong and Emphasis from headingTitleItem eliminates the
conflict: both appear in document-level item, causing the LR automaton
to merge heading-title states with document-item states and make "*"
ambiguous (Strong opener vs. end of heading).

HeadingText is widened to ![\n$#`<@\\]+ so "*" and "_" inside headings
are consumed as plain text rather than producing error nodes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 20:58:05 +00:00
claude 26da1f6205 fix(editor): resolve HeadingTitle shift/reduce conflict in Typst grammar
Build and Deploy Verso / deploy (push) Has been cancelled
headingTitleItem* allowed an empty HeadingTitle, causing a shift/reduce
conflict: after HeadingMark, seeing "*" the LR parser couldn't decide
whether to shift it as a Strong inside the heading or reduce HeadingTitle
to empty and treat "*" as a document-level item.

Changing to headingTitleItem+ forces HeadingTitle to be non-empty, so
"*" after HeadingMark must be inside the heading. Empty headings are
handled by Lezer's error recovery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 20:35:42 +00:00
claude 5287ea6f00 fix(editor): break Strong/Emphasis mutual recursion in Typst grammar
Build and Deploy Verso / deploy (push) Has been cancelled
Strong{strongItem{Emphasis}} and Emphasis{emphItem{Strong}} created a
mutual-recursion cycle that caused Lezer's LR automaton builder to
produce exponentially many states and crash.

Remove each construct from the other's item list. StrongText already
includes '_' and EmphText already includes '*', so nested delimiters
render as plain text inside the opposite construct rather than errors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 20:14:33 +00:00
claude 045d458875 feat(editor): native Lezer grammar for Typst syntax highlighting
Build and Deploy Verso / deploy (push) Has been cancelled
Replace the StreamLanguage tokenizer with a full LR grammar compiled by
@lezer/generator, giving Typst the same parse-tree infrastructure that
LaTeX and BibTeX already use.

Grammar features:
- Headings (=, ==, …) via SOL-detecting external tokenizer
- Code expressions (#keyword, #func(args), #ident.method, #{…}, #[…])
- Named argument highlighting (key: value in function calls)
- Inline and display math ($…$)
- Strong (*…*) and emphasis (_…_) with bold/italic formatting
- Raw blocks (```lang…```) and inline raw (`…`)
- Nested block comments (/* /* */ */) via depth-tracking external tokenizer
- Labels (<name>) and references (@name)
- Backslash escapes

Infrastructure changes:
- lezer-typst/typst.grammar — new Lezer grammar
- lezer-typst/tokens.mjs — external tokenizers for context-sensitive lexing
- scripts/lezer-latex/generate.mjs — Typst added to grammars array so the
  existing lezer-latex:generate script (and Dockerfile step) compile it
- .gitignore — generated typst.mjs / typst.terms.mjs excluded from git

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 19:49:17 +00:00
claude 2c0f387cef feat(editor): use @codemirror/lang-yaml for Quarto YAML frontmatter
Build and Deploy Verso / deploy (push) Successful in 12m20s
Replace the custom regex-based ViewPlugin with the official
@codemirror/lang-yaml package. yamlFrontmatter({ content: mdLS })
wraps the Markdown language with a mixed parser: the leading ---/---
block is handed to the full Lezer YAML parser (proper key/value/scalar/
anchor/alias highlighting), while the document body continues to use
the Markdown parser. The manual Frontmatter extension import is also
removed since yamlFrontmatter handles frontmatter recognition itself.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 18:30:35 +00:00
claude f9788a1c69 feat(editor): improve syntax highlighting for Typst and Quarto documents
Build and Deploy Verso / deploy (push) Successful in 10m50s
Typst: heading tokenizer now colors the entire heading line (not just the
'=' prefix), and bold/italic markers (*/_) map to strong/emphasis tags
rather than the generic operator tag. A typstHighlightStyle applies
bold/italic formatting even when the active theme lacks .tok-heading.

Quarto: enable @lezer/markdown's Frontmatter extension so the YAML header
is no longer mis-parsed as Setext headings. A new ViewPlugin decorates
frontmatter lines with type-appropriate CSS classes: keys (tok-typeName),
string/bool/number values, comments, and the --- delimiter markers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 17:42:51 +00:00
claude 489bdb01ec feat(pdf): dark mode for Quarto RevealJS HTML output
Build and Deploy Verso / deploy (push) Successful in 10m36s
Apply the same CSS inversion filter to the HTML iframe as is already
applied to pdfjs PDF pages, so Quarto RevealJS presentations respect
the dark mode toggle. Also show the theme button for HTML outputs and
relax the darkModePdf condition to activate for iframes regardless of
the pdfViewer setting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 17:18:29 +00:00
claude 0b8897540d Fix Quarto RevealJS media missing on second compile
Build and Deploy Verso / deploy (push) Successful in 11m49s
When output.html exists, findOutputFiles includes project media files
(images, videos) in outputFiles via the MEDIA_REGEX exception so they
get served from the cache.  _removeExtraneousFiles then treated them
as extraneous and deleted them.  On the next incremental compile,
unchanged binary files are not re-synced, so the files were gone when
Quarto ran and when _appendMissingResourceWarnings checked for them.

Fix: skip deletion for any file that is a project input resource.
Those files appear in outputFiles to be served, not cleaned up.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 15:30:08 +00:00
claude 2ead377ebc Fix stale error lines bleeding into next Typst compile log
Build and Deploy Verso / deploy (push) Failing after 36m24s
When typst watch doesn't emit "compiled with errors" after a failed
compile, currentLines accumulates indefinitely. The next successful
compile then flushes the buffer including the stale error from the
prior cycle. Reset currentLines at the start of each compile cycle
("[HH:MM:SS] compiling ...") so each log only contains output from
one compile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 15:10:59 +00:00
claude 5a85e1b9d8 Add smooth PDF transition toggle to compile settings
Build and Deploy Verso / deploy (push) Successful in 11m53s
Per-project-type setting: Typst defaults to on, LaTeX defaults to off.
Toggle appears in the compile dropdown under "Smooth PDF transition".
The enableTransition flag is read via a ref so toggling does not
reload the current PDF.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 14:19:37 +00:00
claude 165219dcb1 fix(autocompile): prevent compile chaining — wait for previous compile before starting next
Build and Deploy Verso / deploy (push) Successful in 11m38s
The auto-compile effect was calling debouncedAutoCompile() on every changedAt
update (every keystroke), including while a compile was already running.  With
a 1000ms maxWait the debounce fired every second even mid-compile, chaining
compiles back-to-back and making the user wait for all of them to drain.

Fix: add `compiling` to the effect's dependency array.
- While compiling: the effect cancels the debounce immediately, preventing
  any new compile from being queued.
- When compile finishes (compiling → false): the effect re-runs; if changedAt
  is still > 0 (changes were made during the compile), it re-arms the debounce
  exactly once.  One follow-up compile, then idle.

Also remove the debouncedAutoCompile() re-queue from compiler.ts's
wasCompiling guard — the effect now owns that responsibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 13:38:43 +00:00
claude 71755e5cee fix(pdf): replace document.startViewTransition with non-blocking canvas fade
Build and Deploy Verso / deploy (push) Successful in 14m22s
document.startViewTransition with an async callback places a ::view-transition
overlay on top of the entire page, intercepting pointer events for the duration
of the callback (up to the 1s safety timeout + 250ms animation).  With rapid
auto-compiles this created interface freezes and overlapping transitions that
could leave the visual lock in a broken state, causing 'stuck on compiling'.

Replace with a canvas snapshot overlay + CSS opacity fade-out:
- pointer-events:none so the overlay never blocks input
- snapshot covers the canvas-clear from setDocument() (no white flash)
- on pagerendered: opacity transitions to 0 over 250ms, then overlay removed
- gives the same smooth visual crossfade, reliably, in all browsers

Chrome 126+ retains the element-level startViewTransition path which is
scoped to the PDF container and does not affect the rest of the page.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 13:09:18 +00:00
claude 453439e611 fix(pdf): suppress root view-transition animation to isolate fade to PDF pane only
Build and Deploy Verso / deploy (push) Successful in 11m47s
document.startViewTransition generates both a named pseudo-element for the PDF
container (ol-pdf-viewer) and a root-level pseudo-element that covers the entire
page, causing the editor to fade along with the PDF.

Inject a temporary <style> that sets animation:none on the root pseudo-elements
before starting the transition, then remove it in transition.finished.  Only the
named PDF container crossfades; the editor is unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 12:39:01 +00:00
claude d895e14e48 feat(pdf): restore smooth crossfade for Chrome 111+ using document.startViewTransition
Build and Deploy Verso / deploy (push) Successful in 11m24s
The original code used container.startViewTransition(setDocument) with a
synchronous callback, giving a 250ms CSS crossfade that looked smooth when
the PDF happened to re-render before the animation ended — but was a race.

Now there are three tiers:
- Chrome 126+: element-level startViewTransition, async, waits for pagerendered
- Chrome 111+ (Brave 138, Edge 111+): document-level startViewTransition with
  view-transition-name scoped to the PDF container, same async pattern
- Firefox / Safari / older Chromium: canvas snapshot overlay (no animation,
  but seamless — introduced in build #108)

The document-level path restores the smooth fade the user saw on Edge build
#93, now guaranteed to crossfade old→new rather than old→blank.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 12:22:46 +00:00
claude 4410a83146 fix: eliminate too-recently-compiled error and PDF flicker on fast Typst compiles
Build and Deploy Verso / deploy (push) Successful in 11m25s
Rate limit: auto-compile requests already have a client-side debounce; skip
the 1-second server-side recently-compiled gate for them to avoid spurious
'too-recently-compiled' rejections that were blocking ~1/3 of Typst compiles.

PDF flicker: add _snapshotCanvases() fallback for browsers without element-level
View Transitions (Chrome <126, Firefox, Safari).  Before setDocument() clears the
canvases it copies each rendered page to a positioned overlay; the overlay is
removed once the first page of the new document fires pagerendered, giving a
seamless old→new swap in all browsers.  Chrome 126+ continues to use the
startViewTransition async callback path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 12:00:01 +00:00
claude db162e54af fix(typst): correct auto-compile default and debounce detection for Typst projects
Build and Deploy Verso / deploy (push) Successful in 11m37s
The previous implementation used useState() to detect the project type, but the
file tree is loaded asynchronously after the WebSocket joinProject event, so
pathInFolder() always returns null on the initial render.

Use useEffect() instead — it re-runs when getRootDocInfo's reference changes
(i.e. when the file tree populates), correctly detecting .typ root docs.
Also adds updateAutoCompileDebounce() to DocumentCompiler so the tight
debounce can be applied at that point.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 11:37:28 +00:00
claude 228ad00075 feat(typst): auto-compile on by default with fast debounce + smoother PDF transitions
Build and Deploy Verso / deploy (push) Successful in 14m23s
- Typst projects default autocompile to enabled (300ms debounce / 1s max-wait
  instead of 2.5s/5s), so the PDF refreshes nearly as the user types.
- Make startViewTransition wait for the first page to render before completing
  the crossfade, eliminating the old-PDF→blank flash on Chrome 126+.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 10:40:10 +00:00
claude 7eaeaedcd8 Implement persistent typst watch for incremental compilation
Build and Deploy Verso / deploy (push) Successful in 59m27s
Instead of cold-starting 'typst compile' on every request, TypstRunner
now maintains a long-lived 'typst watch' process per project. Subsequent
compiles reuse the warm process, which caches fonts, packages, and the
compiled AST via Typst's comemo framework — dramatically faster.

Architecture:
- WatchTable: maps compileName → live watcher process + state
- _startWatcher: spawns 'typst watch input.typ output.pdf', registers
  stdout/close handlers, then immediately awaits the first compile result.
  The resolver is pushed to pendingResolvers synchronously inside the
  Promise constructor before any I/O event can fire — eliminating the
  race between file-write detection and resolver registration.
- _onWatcherData: parses stdout line-by-line, resolves pending callers
  on "compiled successfully/with warnings/with errors" (the three terminal
  lines typst watch emits at the end of each compile cycle).
- Graceful restart: watcher is restarted after MAX_COMPILES_BEFORE_RESTART
  (1000) cycles to stay clear of Typst's ~65k FileId limit, or immediately
  if the "ran out of file ids" message is detected in stdout.
- killTypst: tears down both the watcher and any cold-start fallback job;
  called by stopCompile (user-initiated) and clearProject/clearProjectWithListing
  (before compile-dir deletion).
- Docker fallback: Settings.clsi.dockerRunner=true falls back to the
  original cold-start 'typst compile' path unchanged.
- process.on('exit') kills all watcher process groups on CLSI shutdown.

CompileManager: call TypstRunner.promises.killTypst before deleting the
compile directory in both clearProject and clearProjectWithListing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 09:09:33 +00:00
claude 54c510c818 Revert Typst SyncTeX attempt; clean up diagnostic logging
Build and Deploy Verso / deploy (push) Has been cancelled
Typst has no --synctex CLI option (open feature request #289 since 2023).
Revert the frontend guard back to LaTeX-only and remove --synctex from
the Typst compile command. Also remove the temporary logger.warn calls
added for diagnosing the LaTeX synctex issue (now resolved).

The official Typst binary installation in Dockerfile-base is kept as it
is cleaner than using Quarto's modified fork for .typ compilation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 08:43:18 +00:00
claude 5796c0157c Install official Typst binary and use it for .typ compilation
Build and Deploy Verso / deploy (push) Has been cancelled
Quarto bundles a modified Typst fork that lacks --synctex, making
bidirectional sync impossible. Install the official Typst binary
(v0.13.1) from upstream and use it in TypstRunner instead.

This also means .typ projects now use the unmodified Typst compiler,
which is correct since TypstRunner handles plain .typ files (not .qmd).
QuartoRunner continues to use Quarto's bundled Typst internally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 08:40:48 +00:00
claude 3f68c147a4 Call Typst binary directly for compile and SyncTeX support
Build and Deploy Verso / deploy (push) Successful in 13m8s
Instead of going through 'quarto typst compile' (which intercepts
--synctex before it reaches Typst), call the Typst binary bundled in
the Quarto .deb directly at /opt/quarto/bin/tools/x86_64/typst.

This allows passing --synctex output.synctex.gz to generate the SyncTeX
file for bidirectional editor↔PDF sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 08:24:20 +00:00
claude 0780963bc7 Fix --synctex argument order for Typst compile
Build and Deploy Verso / deploy (push) Successful in 11m33s
Typst's CLI requires options before positional arguments (INPUT OUTPUT).
Placing --synctex after output.pdf caused it to be treated as an extra
positional arg and rejected with 'unexpected argument'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 08:09:52 +00:00
claude 43a622cd71 Add SyncTeX support for Typst projects
Build and Deploy Verso / deploy (push) Successful in 11m58s
- TypstRunner: add --synctex output.synctex.gz to quarto typst compile,
  generating a synctex file alongside the PDF (requires Typst 0.11+,
  bundled in Quarto 1.5+).
- use-synctex: extend the root-doc guard from LaTeX-only to also cover
  .typ files, enabling the Show in PDF / Show in code buttons for Typst.

The rest of the sync infrastructure (OutputCacheManager, synctex binary,
SynctexOutputParser, CLSI routes) is already format-agnostic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 21:52:05 +00:00
claude 9079b545f7 Switch TeX Live from scheme-basic to scheme-full
Build and Deploy Verso / deploy (push) Successful in 50m16s
Replaces the minimal scheme-basic install (plus explicit latexmk,
texcount, synctex additions) with scheme-full, giving users access
to the complete LaTeX package ecosystem without manual tlmgr installs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 20:55:06 +00:00
claude eb45ececf0 Install synctex binary via tlmgr for SyncTeX support
Build and Deploy Verso / deploy (push) Has been cancelled
The synctex binary was not included in scheme-basic and was not
explicitly installed, causing `spawn synctex ENOENT` on every
sync request. Add it alongside latexmk and texcount.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 20:53:28 +00:00
claude e6add1e6f0 Add diagnostic logging to synctex to identify failure cause
Build and Deploy Verso / deploy (push) Successful in 9m42s
Logs: request params, directory used, whether output.synctex.gz
is found, and the actual synctex binary output or error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 16:21:35 +00:00
claude 170818e6fc fix(synctex): gate sync buttons to LaTeX-only projects
Build and Deploy Verso / deploy (push) Successful in 11m0s
Verso added 'qmd' and 'typ' to validRootDocExtensions, which caused
isValidTeXFile() to return true for Typst/Quarto files — enabling
SyncTeX UI controls for projects that never produce output.synctex.gz.

Replace the open-doc extension check in canSyncToPdf with a
LaTeX-only regex on the project root document path (tex|ltx|Rtex|Rnw),
and add the same guard in _syncToCode so PDF-click sync never fires
an API request for non-LaTeX projects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 14:50:02 +00:00
claude 9ea904f78f Merge upstream Overleaf up to PR #34297 (68 commits)
Build and Deploy Verso / deploy (push) Successful in 11m30s
Conflicts resolved:
- fat-footer-website-redesign.pug: keep Verso footer (discard Overleaf marketing footer)
- MaterialSymbolsRoundedUnfilledPartialSlice.woff2: regenerated from merged
  unfilled-symbols.mjs (preserves Verso's deployed_code + adds upstream's spellcheck)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 13:39:32 +00:00
roo hutton 757735b075 Merge pull request #34297 from overleaf/rh-prev-plan-type-cancel
Update previous_plan_type on subscription expiry

GitOrigin-RevId: 19381e5516fdbfd2650a9a5b94b61791e0da909f
2026-06-05 08:07:27 +00:00
Mathias Jakobsen fa36cd508b Merge pull request #34310 from overleaf/mj-handle-lazy-errors-for-search-and-share
[web] Handle errors while loading full project search and share modal

GitOrigin-RevId: 29d863324a54fa872022002f612498335f88f377
2026-06-05 08:07:10 +00:00
Mathias Jakobsen b7735d402d Merge pull request #34195 from overleaf/mj-command-palette-menu-labels
[web] Add menu labels to commands, and add more commands to command palette

GitOrigin-RevId: 21e17142bb3112b5fdcda85a472122b011979f49
2026-06-05 08:07:06 +00:00
Mathias Jakobsen cabe0046c5 Merge pull request #34102 from overleaf/mj-document-import-errors
[web] Expose pandoc errors in import

GitOrigin-RevId: 55f89b91a52099a99a5d955bc05f3657b87b2cdc
2026-06-05 08:07:02 +00:00
Anna Claire Fields 97247b8ea5 [PnP migration] Remove mock-fs dependency (#33835)
GitOrigin-RevId: ff8df32d85b2ecd2837c9eee6d6d2b3b95285239
2026-06-05 08:06:54 +00:00
Anna Claire Fields 3fcd133198 [patch] update sandboxed-module for Yarn PnP compatibility and add mongodb-legacy type definitions (#33983)
GitOrigin-RevId: 8f1e9a4e4b4b5fbf3a770951a070b5a259abdcee
2026-06-05 08:06:50 +00:00
Anna Claire Fields 44dee7592a use require.resolve for mocha reporter paths (#34235)
GitOrigin-RevId: af607dfdeac8f91f63db294a964ade7622225932
2026-06-05 08:06:46 +00:00
Anna Claire Fields bfcf75855a [PnP migration] Convert .prettierrc to .prettierrc.cjs with require.resolve (#34237)
GitOrigin-RevId: ab57ca143bca8bfd2b44f03f9712a1aae70b2c1c
2026-06-05 08:06:42 +00:00
Antoine Clausse 3140e46e68 [web] Replace token-link email verification with 6-digit code on SSO registration (ORCID) (#33889)
* Replace token-link email with 6-digit code on SSO registration

Unverified SSO emails previously received a long-lived token link
(90-day TTL) via UserEmailsConfirmationHandler. This replaces that
flow with the same 6-digit code verification used for password
registration, redirecting through /registration/confirm-email.

- SSOManager.registerSSO now always confirms email (caller must
  verify first); removes sendConfirmationEmail / _finishRegistration
- SSOController._signUp sends confirmation code and stores
  pendingSSORegistration in session when IdP email_verified is false
- New SSOConfirmEmailHandler completes registration after code check
  via completeSSOEmailConfirmation module hook
- OnboardingController confirm-email handlers accept
  pendingSSORegistration alongside pendingUserRegistration

confirmEmailFromToken (POST /user/emails/confirm) removal is deferred
to a follow-up PR to avoid breaking in-flight 90-day tokens.

Closes #28607

* Fix unverified-email edge cases; Add ORCID e2e tests;

* Rename `confirmEmail` parameter to `emailVerifiedByIdP` in _signUp function

* Remove `sendConfirmationEmail`

* Mock getUserByAnyEmail in tests

* Extract _finishSSORegistration helper to deduplicate the register →
set session flags → allocate referral → finishSaasLogin → finishLogin
sequence shared by both the direct and deferred (code-confirmed) paths.

* Stop duplicating session data in pendingSSORegistration

analyticsId, splitTests, and referal_* are already in the session at
confirmation time — no need to copy them into pendingSSORegistration.
Re-fetch splitTests fresh on completion instead.

* Simplify the code

* Remove dead confirmEmail template

No callers remain after sendConfirmationEmail was deleted. The token-link
flow (confirmEmailFromToken) only validates tokens, never sends email.

* Remove dead reconfirmEmail template

* Address comments from Copilot

* Clear stale pending registration when starting a new flow

* Add unit tests for completeSSOEmailConfirmation

* Add `verificationMethod` param

* Fix camelcase issues

* Extract _createSSOUser and _registerAndFinish helpers to deduplicate registration logic

* Remove obscure "registration_error"

* Prevent FormTextIcon from shrinking

* Enable "email_already_registered_sso" error

* Misc. improvements to confirm-email-form.tsx

* Remove `UserEmailsConfirmationHandler` mock

Co-authored-by: Olzhas Askar <olzhas.askar@overleaf.com>

* Add info on sso_email.pug page

---------

Co-authored-by: Olzhas Askar <olzhas.askar@overleaf.com>
GitOrigin-RevId: d0196ebc6d81ff61bcd27726d0b899b743d08d64
2026-06-05 08:06:34 +00:00
Daniel Kontšek 2570b6559d Merge pull request #34112 from overleaf/dn0-migration-check-predeploy-hook
Add predeploy migration gate for Mongo-bundling services

GitOrigin-RevId: d9eb192ea32b5328fb24fd453ddb1370f373858e
2026-06-05 08:06:30 +00:00
Davinder Singh 6ce36a2606 adding web changes of Export HTML (#34117)
GitOrigin-RevId: 804c576faefebfc6683a0363b45372e66a43d8fc
2026-06-05 08:06:19 +00:00
Jakob Ackermann fc2abf5b24 [web] fix submit modal in Codespaces (#34137)
GitOrigin-RevId: dc057ed736e97265a901b1cf21995c1f391339a5
2026-06-05 08:06:15 +00:00
Malik Glossop b8fc478e1f Merge pull request #34185 from overleaf/worktree-mg-error-assist-paywall
Show paywall from gutter when user hits suggestion limit

GitOrigin-RevId: 36c09e3d93ac38e1e675aa8ffb419e928094d68e
2026-06-05 08:06:11 +00:00
Malik Glossop d25b032e16 Merge pull request #33450 from overleaf/worktree-mg-writefull-spelling-tab
Add writefull language suggestions section to Spelling and language tab

GitOrigin-RevId: 6195683ca175a4c3da25a7ab334a605c67db04b8
2026-06-05 08:06:07 +00:00
Mathias Jakobsen fc31a88767 Merge pull request #34145 from overleaf/ds-download-html-using-pandoc-clsi-1
[CLSI] Download as HTML feature

GitOrigin-RevId: 374101c1f957a00eda423a6be0363c08b5de7a95
2026-06-05 08:06:03 +00:00
Jakob Ackermann 0501586743 [latexqc] migrate to local s3, add codespaces support, add e2e tests (#34136)
GitOrigin-RevId: 167171103c14ed3c4ba2939d80231c343645e53a
2026-06-05 08:05:59 +00:00
Jakob Ackermann df61bfc788 [clsi] initial version of /convert/pdf-to-jpeg (#33752)
* [monorepo] consolidate clsi-lb host/ip env-vars

Target env-var is CLSI_LB_HOST. Keep CLSI_LB_IP populated for a week.

* [clsi] initial version of /convert/pdf-to-jpeg

* [rails] use fake-secrets in CI and Codespaces

* [rails] adapt tests for using clsi to convert PDFs to image

* [rails] add rake task for comparing clsi conversion with transloadit

* [clsi] double check that output.jpg is a regular file

Co-authored-by: Brian Gough <brian.gough@overleaf.com>

* [clsi] fix composing basename

* [monorepo] fix clsi-lb host env-var post merge

* [monorepo] sort dev-environment.env hosts

* [rails] use local pdf file rather than downloading it again

Download from the old renderer code path still. It's dead code.

* [terraform] clsi: enable pdf to jpg conversion

---------

Co-authored-by: Brian Gough <brian.gough@overleaf.com>
GitOrigin-RevId: 5ecaa8559d299486340bb3961f06b29f7c4dfcca
2026-06-05 08:05:55 +00:00
Brian Gough 9ec0ff065d add missing mongo dependencies (#34298)
* add missing mongo dependency for analytics

* update build scripts for analytics

* add missing mongo dependency for third-party-datastore

* update build scripts for third-party-datastore

* add missing mongo dependency for third-party-references

* update build scripts for third-party-references

* update yarn.lock for buildscript changes

GitOrigin-RevId: 1c42e49af5075529a334d50648da990e4cedb1b4
2026-06-05 08:05:50 +00:00
Olzhas Askar 8e36f20950 Merge pull request #34267 from overleaf/oa-move-upgrade
[web] Moving the upgrade button

GitOrigin-RevId: 33dcdcfa4e816e29177abe2c045e919edd7a4e08
2026-06-04 08:07:21 +00:00
roo hutton 06e99fe62a Merge pull request #34130 from overleaf/rh-enterprise-cio
Expose enterprise indicators and previous_plan_type for first subscriptions to customer.io

GitOrigin-RevId: 693db7f796609f00ecd31216a6d6be32c1f569c8
2026-06-04 08:07:09 +00:00
Maria Florencia Besteiro Gonzalez d112271b1c Merge pull request #34184 from overleaf/cs-icon-button-labs-library
feat(library): add Labs feedback badge to Library heading

GitOrigin-RevId: 6dacc588cc58300a09b8195ca800d042d40f4c89
2026-06-04 08:06:52 +00:00
Antoine Clausse 0658bd9a31 [web] Change plans order in Change Plan modal (#34096)
* [web] Order plans in Change Plan modal consistently

Reorder the plans returned by `buildPlansListForSubscriptionDash` so the
Subscription page "Change plan" modal lists them top-to-bottom as:

  1. Student annual
  2. Student monthly
  3. Standard monthly
  4. Standard annual
  5. Pro monthly
  6. Pro annual

Previously `buildPlansList` produced three per-period buckets which the
dash function concatenated, giving an order that flipped per family.
Replace that with an explicit `CHANGE_PLAN_MODAL_PLAN_CODES` list so the
order matches the Design QA spec at a glance. The now-unused
`studentAccounts`, `individualMonthlyPlans`, `individualAnnualPlans`,
`groupMonthlyPlans`, and `groupAnnualPlans` buckets are dropped from
`buildPlansList` (no other callers).

Closes #34024

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [web] Update personal-plan acceptance test for new buildPlansList shape

The previous test asserted `buildPlansList().individualMonthlyPlans`,
which no longer exists after the change-plan modal reorder dropped the
per-period buckets. Move the assertion to
`buildPlansListForSubscriptionDash()`, which is where the personal-plan
exclusion is now enforced (via `CHANGE_PLAN_MODAL_PLAN_CODES`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [web] Drop now-dead client-side plan filter

`IndividualPlansTable` used to filter out `paid-personal`,
`paid-personal-annual` and `institutional_commons` defensively because
the old `buildPlansListForSubscriptionDash` returned every non-group
plan that wasn't `hideFromUsers`. The previous commit pins the modal to
an explicit six-plan list (`CHANGE_PLAN_MODAL_PLAN_CODES`), so none of
those plan codes ever reach the frontend and the filter is dead. Remove
it and the now-unused `useMemo` import.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Revert "[web] Drop now-dead client-side plan filter"

This reverts commit 83e8448f2cfa2c68e44b749d5a2bc350a7443c6d.

We'll do that in a later cleanup

* Swap "Student monthly" and "Student annual" for consistency

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
GitOrigin-RevId: 046a235e14e7ad6622288f5a5a723f5a4f7f14da
2026-06-04 08:06:40 +00:00
Antoine Clausse b07d141397 [web] Fix /user/subscription/plans#ai-assist redirects (#34124)
* [web] Redirect missing AI add-on purchase to subscription dashboard

The two error paths in `previewAddonPurchase` redirected to
`/user/subscription/plans#ai-assist`, but the `#ai-assist` anchor was
removed when the AI Assist add-on was retired, so users land at the top
of the plans page with no context. Align both with the other error
branches in the same function and the `plans-2026-phase-1` enabled
branch, which already redirect to
`/user/subscription?redirect-reason=ai-assist-unavailable` — the
subscription dashboard shows the matching warning alert
(`redirect-alerts.tsx`).

Update the acceptance test to match the new redirect target.

Closes #34074

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [web] Update ai-assist-unavailable warning to reflect bundled AI features

The previous copy said "AI Assist isn't available to you due to your
current subscription type", which read as a hard block. Now that the AI
Assist add-on has been retired and AI features are included with every
paid plan, the warning should point users to the pricing page instead of
implying their plan can't access AI at all.

Keep the existing translation key for now — a follow-up can rename it
once #33624 (AI page CTA destination) is resolved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [web] Link the ai-assist-unavailable warning to the pricing page

* [web] Rename key `ai_assist_unavailable_due_to_subscription_type` -> `ai_assist_unavailable`

* [web] Update french and german translations

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
GitOrigin-RevId: ae1319fa5b857d8f292de77c82ef0bda1c7ad144
2026-06-04 08:06:31 +00:00
Jakob Ackermann 6869ad5bdf [misc] remove HTTP method override capability (#34243)
GitOrigin-RevId: 2d88b9cdb63c7861e0604bb19d0e0c924701f3e4
2026-06-04 08:06:22 +00:00
Domagoj Kriskovic 9cf1085fbb [web] use updateProject for saving trackChangesState
GitOrigin-RevId: eecb2b78ff18547e8b3653fdff2d380d295c367f
2026-06-04 08:06:14 +00:00
Domagoj Kriskovic ea57ae9125 Rename sourceEditorVisualExtensions to sourceEditorMarkdownExtensions
GitOrigin-RevId: a242742c3844cccb355d4a98eb27b74123ad107e
2026-06-04 08:06:09 +00:00
Domagoj Kriskovic 5cf1b43ce7 Add Markdown visual editor support
GitOrigin-RevId: 4ec2ffb276c729a58f82ccb26ed571f4187a4178
2026-06-04 08:06:04 +00:00
Chris Dryden e38f4e18e4 Merge pull request #33868 from overleaf/dk-package-loading-tests
[web] Add tests for pyodide worker streams and output pane rendering

GitOrigin-RevId: 41ffc25230be23d68d50c61980cfaf1260a0247d
2026-06-04 08:06:00 +00:00
Liam O'Brien f1282ee5cd Helper script for changing expiry of git pat (#34234)
* Helper script for changing expiry of git pat

* Validation fail for invalid date

GitOrigin-RevId: 6786d4e808e0e4e87ef1293f4c22236257948128
2026-06-04 08:05:51 +00:00
Copilot a2f72adf67 Remove useSecondary from backup worker to fix false positive errors during MongoDB failover (#34186)
* Initial plan

* Remove useSecondary from configureBackup to fix false positive backup errors

Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>
GitOrigin-RevId: f7c9bb88fb2f7526948fee196f0444bd33a96e56
2026-06-04 08:05:47 +00:00
Brian Gough 0da93aaab3 add script to finalise broken history-v1 chunks (#34005)
* add script to finalise broken history-v1 chunks

* use history-id instead of project-id

* update project-id to history-id in tests

* silence unwanted event emitter warnings

* fix up test for historyId

GitOrigin-RevId: 58d2a768f1eff296e921e2ed985f6faf3929f619
2026-06-04 08:05:42 +00:00
Liam O'Brien e53c6f2aea Notify users about expiring git PATs and expose PATs in admin panel (#33802)
* Allow admin access to user PATs

* Tests for new screen in admin panel

* Adding error for invalid token and way to parse error for OAuth 2

* Git bridge handles expired PAT

* Script for alerting on close to expiry and expired git tokens

* Refactoring and simplifying

* Updating email templates to match agreed docs

* tweak to email subject to include Overleaf

* Allowing dry run in scripts and general tidy up

* removing redundant tests and dry running script

* Fixing CI errors

* Adding new tab to admin test expectation

* Address PR feedback on oauth2-server changes

- Replace ad-hoc overleafErrorCode prop with a TokenExpiredError subclass
- Collapse listTokens/listTokensForAdmin into a single hook

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* Adding cron definitions for alerting on expiring git pat

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
GitOrigin-RevId: 69b9fd901a201592a580c69abe7bd7d603e85d3a
2026-06-04 08:05:26 +00:00
claude c249d6a6e9 Prod: load SMTP env via envFrom secretRef (flat, paste-proof)
Build and Deploy Verso / deploy (push) Successful in 1m19s
Build and Deploy Verso (prod) / deploy (push) Successful in 1m9s
Replace the six nested secretKeyRef env entries with a single
'envFrom: - secretRef: { name: verso-smtp, optional: true }' in both the
standalone app manifest and the prod workflow. Avoids the deep nesting that
tripped strict server-side decoding, and is simpler to edit. The secret's keys
must now be named exactly like the env vars (OVERLEAF_EMAIL_*).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 12:40:07 +00:00
claude 2d8f23509a Prod: standalone Deployment/Service bootstrap files; drop namespace create
Build and Deploy Verso / deploy (push) Successful in 1m22s
- Add server-ce/k8s/verso-prod-data.yaml (Mongo + Redis) and
  verso-prod-app.yaml (Verso app), mirroring the workflow so the verso
  namespace can be bootstrapped/validated by hand.
- Drop 'kubectl create namespace verso' from the prod workflow (namespace is
  pre-created), so the runner only needs namespaced rights in verso, matching
  the test namespace.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 12:03:02 +00:00
claude 0f640c74b2 Prod: provision PVCs out of band (storageClass under operator control)
Build and Deploy Verso / deploy (push) Successful in 1m18s
- Add server-ce/k8s/verso-prod-pvcs.yaml (mongo-data/redis-data/verso-data,
  ReadWriteOnce, storageClassName left for the operator to set — use a Ceph RBD
  block class).
- Drop the inline PVC definitions from deploy-verso-prod.yml so it won't fight
  the operator-provisioned PVCs; the deploy now assumes they already exist.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 11:36:41 +00:00
claude 54ccb3d712 Add prod deploy workflow (verso namespace, persistent, friends-only)
Build and Deploy Verso / deploy (push) Successful in 1m20s
New .gitea/workflows/deploy-verso-prod.yml triggered by pushes to the 'prod'
branch — a real production target distinct from the ephemeral test rig:

- Runs in the 'verso' namespace; Mongo/Redis/app-data on PersistentVolumeClaims,
  applied idempotently and NEVER deleted (data survives deploys).
- Replica set initialised only once; admin created only if no users exist.
- Builds/pushes verso:stable (separate tag from test's verso:latest);
  imagePullPolicy Always so each rollout pulls the new build.
- SMTP via an optional 'verso-smtp' Secret (no credentials in the repo);
  anonymous read-write sharing left off and public registration off
  (friends-only).
- Example Ingress for verso.alocoq.fr at server-ce/k8s/verso-prod-ingress.example.yaml
  (apply by hand to match the existing TLS/annotation setup).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 11:21:33 +00:00
claude 35fa7cec05 README logo + dates; capitalize Alpha in instance title
Build and Deploy Verso / deploy (push) Successful in 1m21s
- README: show the Verso wordmark logo instead of a text title.
- README: original Overleaf copyright now 2014-2026; Verso modifications 2026.
- Instance/version title: 'alpha' -> 'Alpha'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 11:01:23 +00:00
claude 2385166213 Dashboard footer fix, larger version text, rewrite README
Build and Deploy Verso / deploy (push) Successful in 9m47s
- Fix the projects dashboard footer needing a scroll to reach: the main area
  used min-height: 100% which always pushed the footer a full screen down.
  Lay the content out as a flex column with main growing (flex: 1 0 auto), so
  the footer sticks to the bottom of the viewport when the list is short.
- Bump the instance-name/version text to ~33px ('7.5', between font-size-07
  and -08).
- Rewrite README to match the current triple-compiler product (Quarto + LaTeX
  + Typst), the editor language support, format badge, publishing flow and
  Python venv option; drop the stale 'Quarto-only / TeX Live removed' notes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 10:31:49 +00:00
claude fddb141d19 Polish: smaller version text, bigger loader logo, keep RevealJS slide on recompile
Build and Deploy Verso / deploy (push) Successful in 9m35s
- Reduce the dashboard instance-name/version font size (07 -> 06).
- Enlarge the Verso logo in the loading animation (160px -> 240px).
- Preserve the current RevealJS slide across recompiles: capture the deck's
  URL hash (same-origin) and re-append it to the iframe src so the new build
  reopens on the same slide instead of jumping to the start.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 09:10:33 +00:00
claude 8272d6de88 Editor/dashboard polish: PDF publish, Typst outline, bigger branding
Build and Deploy Verso / deploy (push) Successful in 9m29s
- Hide the Present button when the current output is a PDF (it only makes
  sense for HTML/RevealJS decks).
- Publish now supports PDF projects: snapshot output.pdf and serve it inline
  via a small index.html wrapper at /p/:token, so link holders can view the
  PDF straight from the published version.
- Add a Typst document outline (scans '=' headings) wired into the file
  outline panel.
- Dashboard branding: enlarge the instance-name/version text and let the
  sidebar Verso wordmark span the full column width.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 08:33:56 +00:00
jmescuderowritefull a553a8390d Clean 'writefull-keywords-generator' flag (#34200)
GitOrigin-RevId: 3014f02eba721b002eb35ec81750252993597748
2026-06-03 08:07:27 +00:00
Mathias Jakobsen 5ad548e7d7 Merge pull request #34199 from overleaf/mj-tabs-divider-tweaks
[web] Drop dividers next to active tab

GitOrigin-RevId: 9610e22b0aa7f036233108282687772c30f4c1b0
2026-06-03 08:07:06 +00:00
Maria Florencia Besteiro Gonzalez 021b2e305c Merge pull request #34108 from overleaf/mfb-show-warning-of-duplicate-citation-keys
Show duplicate citation keys as a warning beside the relevant entry

GitOrigin-RevId: e8506b2d77febec6d269a242f6d9b237171db66f
2026-06-03 08:06:44 +00:00
Mathias Jakobsen cc762bb7e6 Merge pull request #33994 from overleaf/mj-command-palette-synctex
[web] Add synctex to command palette

GitOrigin-RevId: 10e769dae6088d279d010fcfa3577b489c6ff89c
2026-06-03 08:06:40 +00:00
Brian Gough f8c7e092fa upgrade to eslint v10 (#34054)
* upgrade from eslint version 8 to eslint version 10

* remove unsupported eslint-env directive

* include jsx files in latexqc linting

* use basePath and extends to maintain paths in writefull eslint

* fix yarn.lock

with ./bin/yarn install

* preserve existing glob patterns in web eslint config

* restore original comments

* fix worker path

* corrected comment about eslint-plugin-mocha

* remove unused imports

* remove unused import of includeIgnoreFile

* switch to individual eslit.config.mjs files

* fix lint errors on eslint.config.mjs in web

* update build scripts for eslint.config.mjs

* update volumes for RUN_LINTING_CI_MONOREPO in web Makefile

updated manually as this makefile is not autogenerated
the RUN_LINTING_CI_MONOREPO command is only used for prettier, not eslint, but updating for consistency.

* migrate from mocha/no-skipped-tests to mocha/no-pending-tests

see https://github.com/lo1tuma/eslint-plugin-mocha/pull/365
"rule no-skipped-tests has been removed, its functionality has been merged into the existing no-pending-tests rule"

GitOrigin-RevId: 2c8f25c8049a0dba374a51df1214286bb5093a51
2026-06-03 08:06:29 +00:00
Mathias Jakobsen 98bd09c31d Merge pull request #34189 from overleaf/mj-fix-flaky-review-panel-tests
[web] Fix flaky <ReviewPanel /> Cypress tests

GitOrigin-RevId: b34dc9a0ca53da5a282513e8fb92297e4b2f702a
2026-06-03 08:06:17 +00:00
Alf Eaton 78bea8d574 Use Emulation.setFocusEmulationEnabled in Cypress (#33787)
GitOrigin-RevId: d3b9ba1b2362bdb23dbf8282514c972c52c83fec
2026-06-03 08:06:04 +00:00
Alf Eaton 979f065581 Upgrade to MathJax v4 (#15030)
GitOrigin-RevId: d1536bce67286da23e15aa18eb525dd83859978b
2026-06-03 08:05:55 +00:00
Andrew Rumble b6451d5bb0 Merge pull request #34179 from overleaf/ar-analytics-upgrade-development-postgres
[analytics] upgrade test postgres version to 14

GitOrigin-RevId: fac9d063c2572d4393d885554ef688876c300c29
2026-06-03 08:05:50 +00:00
Lucie Germain d52b5ae141 [Security upgrade] bump brace-expansion to 5.0.6 (#33915)
* Bump brace-expansion to 5.0.6 in linked-url-proxy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* drop unnecessary brace-expansion resolution; ^5.0.5 already permits 5.0.6

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
GitOrigin-RevId: 837dcd88e5e0a6181d3ac2fe4f512a6ec1904002
2026-06-03 08:05:41 +00:00
claude 4fc86ebd3d Editor: qmd/typst autocomplete, format column, compiler gating, Verso loader
Build and Deploy Verso / deploy (push) Successful in 9m48s
- Add a Typst language (stream highlighting + completions) for .typ, and
  Quarto completions (code chunks, callouts, cross-refs) for .qmd/markdown.
- Project dashboard: new Format column (Quarto/Typst/LaTeX) from the cheap
  project compiler field, surfaced through the projects list API.
- Compiler dropdown: grey out engines that don't match the root file's
  extension (.qmd->Quarto, .typ->Typst, .tex->LaTeX engines).
- Replace the Overleaf fill loader with an animated Verso logo: the four
  quadrant circles drift on their own orbits while colour warms up with load
  progress; reused on the token-access screen too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 07:47:31 +00:00
claude 12cabd1d1b Branding: build-number version, EB Garamond title, blue filters, Present button
Build and Deploy Verso / deploy (push) Successful in 9m21s
- Instance name: stamp the nav title with the build number at deploy time
  ("Verso V0.<run> alpha") via a sed placeholder fed by GITHUB_RUN_NUMBER,
  instead of the static "Verso V1.0 Alpha".

- Title typeface: self-host the EB Garamond latin subset (same one embedded in
  the logo SVGs) and apply it to .navbar-title so the instance name matches the
  Verso wordmark.

- Sidebar wordmark: let the logo fill the full sidebar column width (drop the
  160px cap).

- Project filters: switch the ds-nav active state (filter selection + theme
  toggle) from the green tokens to the blue scale, matching the rail.

- Present button: rename the presentation toolbar action from "Preview" to
  "Present" / "Présenter" and add a tooltip explaining it publishes the
  presentation and opens it in a new tab. New keys present /
  present_publishes_and_opens_in_new_tab in en, fr and extracted-translations.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 22:32:07 +00:00
claude 676663ffcc Branding polish: blue rail accent, drop fork link, bigger login logo, dashboard logo placement
Build and Deploy Verso / deploy (push) Successful in 9m41s
- Editor rail: the active item used the Overleaf green accent. Switch
  --ide-rail-link-active-color/background to the blue scale (--blue-10/70,
  --bg-info-03) to match the Verso palette.

- Footers: remove the default "Fork on GitHub!" right_footer item (redundant
  with the "Built on Overleaf" link); right_footer now defaults to [].

- Login: move the hero wordmark into a full-width centered block and bump it to
  max-width 480px so it's no longer constrained by the form column.

- Projects dashboard: restore the instance name in the top-left navbar (set
  OVERLEAF_NAV_TITLE="Verso V1.0 Alpha") instead of the wordmark logo, and move
  the full Verso wordmark to the sidebar's lower section (where the old
  "Digital Science" mark sat). Revert HeaderLogoOrTitle to its title-first
  behaviour now that the dashboard no longer passes a logo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 21:28:50 +00:00
claude 7d5deebfce Fix Python-packages toolbar icon: add deployed_code to unfilled font subset
Build and Deploy Verso / deploy (push) Successful in 9m35s
The file-tree "Python packages" button rendered the literal text
"deployed_code" in the icon font because that glyph was missing from the
outlined/unfilled Material Symbols subset (MaterialSymbolsRoundedUnfilledPartialSlice.woff2),
so the ligature never resolved. The toolbar buttons all use the unfilled
variant, so switching this one to the full filled font would look inconsistent.

Add 'deployed_code' to unfilled-symbols.mjs and regenerate the subset woff2
(same Google Fonts request build-unfilled.mjs makes) so the box/package icon
renders, matching the other outlined toolbar icons.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 21:06:55 +00:00
claude 7a50f42e02 Restore dashboard footer; show navbar logo over title; enlarge login logo
Build and Deploy Verso / deploy (push) Successful in 9m46s
Three follow-ups after the visual-identity deploy:

- Footer: restore the React <Footer> on the projects dashboard (both
  ProjectListDsNav and the legacy DefaultNavbarAndFooter). Removing it earlier
  was an overcorrection — it now renders the Verso/AGPL thin footer rather than
  the old "Powered by Overleaf" line. Other pages already kept the pug footer.

- Navbar brand: HeaderLogoOrTitle previously hid the logo whenever a nav title
  was set, so on the dashboard only the "Verso" instance-name text showed and
  the wired-up Verso logo never appeared. Make a configured logo (custom logo
  or the Verso brand logo) take precedence over the title text; fall back to the
  title only when no logo is provided (unchanged for other navbars).

- Login: enlarge the hero wordmark (max-width 260px -> 380px, full column width).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 20:41:18 +00:00
claude 38edd5269c CI: retry Yarn Classic dep packing on transient esbuild fetch corruption
Build and Deploy Verso / deploy (push) Successful in 11m5s
Build #78 failed in the compile step while Yarn Classic prepared the
@replit/codemirror-* git deps: fetching esbuild's per-platform binaries
returned truncated tarballs ("the file appears to be corrupt" / missing
.yarn-tarball.tgz). The tmpfs classic cache is fresh each build, so there is no
stale entry to blame and nothing to fall back to — it is a transient download
failure (builds #75-77 passed with an identical Dockerfile).

Wrap both the install and compile steps in a 3-attempt retry loop that wipes
the Yarn Classic cache (/usr/local/share/.cache/yarn) and re-fetches before
giving up, dumping pack.log on final failure. The persistent Berry cache and
YARN_NETWORK_CONCURRENCY=1 are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 20:03:51 +00:00
claude 2eccfe7f75 Add Verso visual identity (logos + favicon)
Build and Deploy Verso / deploy (push) Has been cancelled
Introduce the Verso brand marks as self-contained SVGs with the EB Garamond
latin subset embedded as a base64 @font-face, so they render identically in
every context (favicon, CSS background, <img>, inline) with no runtime Google
Fonts dependency — important for the self-hosted alpha. Falls back to Georgia
serif if a browser ignores SVG-embedded fonts.

Assets:
- verso-square.svg  — rounded "V" tile (200×200); used as favicon.svg and the
  editor top-left toolbar logo.
- verso-logo.svg / verso-logo-dark.svg — wide "verso · ONLINE EDITOR" wordmark
  (760×200), light + dark wordmark variants.

Wiring:
- favicon: public/favicon.svg replaced with the square mark.
- editor toolbar: --redesign-toolbar-logo-url (light + dark) -> verso-square.svg.
- projects dashboard navbar: ProjectListDsNav logo -> verso-logo(.dark), with
  --navbar-brand-width widened to 200px to fit the wide wordmark.
- login page: centered Verso wordmark above the form; suppress the top navbar
  so the hero logo stands alone (no competing Overleaf mark).

PNG favicons / apple-touch-icon are left as-is (no raster tooling available);
modern browsers use the SVG favicon.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 19:43:36 +00:00
claude 7670982f60 Dashboard: drop footer + Digital Science branding; Verso-ify React thin footer
Build and Deploy Verso / deploy (push) Successful in 9m47s
The project dashboard ("main menu") rendered the React <Footer> (ThinFooter)
at the bottom of the page, which forced a page-level scrollbar just to reach a
stale "© 2025 Powered by Overleaf" line. Remove <Footer> from both dashboard
variants (ProjectListDsNav and the legacy DefaultNavbarAndFooter) so the main
menu has no footer and no useless scroll. The login/auth pages keep the Verso
attribution footer (thin-footer.pug), which already satisfies the AGPL source
link requirement.

Also remove the hardcoded "Digital Science" marking from the dashboard sidebar
lower section, and update the React ThinFooter (used by other React pages such
as settings/subscription) to match the pug footer: © <year> Aloïs Coquillard ·
Built on Overleaf, with AGPL licence + source-code links on the right, instead
of "Powered by Overleaf".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 19:13:19 +00:00
claude f50d6cb053 Footer: put Verso/AGPL attribution in the rendered thin-footer
Build and Deploy Verso / deploy (push) Successful in 9m41s
The login (and other CE) pages render layout/thin-footer, not
fat-footer-website-redesign, because showThinFooter = !hasFeature('saas')
is true in Community Edition. The earlier footer edit therefore never
showed. Replace the static "© 2025 Built on Overleaf" line with the
Verso attribution (© <year> Aloïs Coquillard · Built on Overleaf) and
add an AGPL licence + source-code link group on the right, keeping the
language picker and custom nav items intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 17:42:06 +00:00
claude e0a4938a78 CI: make Yarn Classic fallback cache a tmpfs (fresh per build)
Build and Deploy Verso / deploy (push) Successful in 11m9s
#74 corrupted the persistent fallback cache again despite serialising the
fetch, so the cause isn't a write race: BuildKit evicts part of that persistent
cache mount between builds (the first build after each id bump always passed,
later ones failed). Mount /usr/local/share/.cache/yarn as tmpfs so it's clean
every build and nothing can be half-evicted; the Berry cache stays persistent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 15:15:38 +00:00
claude 2e657e51d6 Replace marketing footer with Verso attribution/AGPL footer
Swap the Overleaf marketing footer (careers, pricing, 'for universities', …)
shown on the login and other auth pages for a clean Verso footer: copyright
(Aloïs Coquillard -> alocoq.fr), 'Built on Overleaf' (-> Overleaf repo), and on
the right the AGPL licence (-> repo LICENSE) and Source code (-> the Gitea
repo). This also satisfies the AGPL source-offer on the public domain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 15:06:27 +00:00
claude 4c13d139f6 Share modal: 'Add collaborators' heading; fix French 404 title
Build and Deploy Verso / deploy (push) Has been cancelled
Add an 'Add collaborators' heading above the email-invite section in the share
modal so it's visually distinct from the presentation-sharing section.

Add the missing French 'not_found' key so the 404 page shows 'Introuvable'
instead of the raw 'not_found' (the 404 pug template translates server-side;
the key existed in en.json but not fr.json).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 14:36:33 +00:00
claude 405c1d27c9 Bundle Python requirements into a dedicated editor; hide requirements.vrf
Add a 'Python packages' button to the file-tree toolbar that opens a modal to
edit the project's requirements.vrf (one package per line, pip syntax), backed
by GET/POST /project/:id/python-requirements (read via ProjectEntityHandler,
write via EditorController.upsertDocWithPath, write-gated). The .vrf file is now
hidden from the file tree, so it is managed only through this editor rather than
appearing as a loose file. Adds python_packages / python_packages_help i18n.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 14:26:03 +00:00
claude c9727a26e4 Python deps: smart missing-package hint + switch to .vrf requirements file
Build and Deploy Verso / deploy (push) Successful in 9m46s
Option A: when a {python} cell fails with ModuleNotFoundError/ImportError, the
log now suggests the exact PyPI package to add (with a module->package map, e.g.
cv2 -> opencv-python, sklearn -> scikit-learn), names the Verso requirements
file, and notes it could instead be a local module — so the langmuirthermalstudy
case isn't mistaken for a PyPI package.

Switch the per-project requirements file from requirements.txt to a Verso-
specific requirements.vrf (so it won't be confused with arbitrary .txt files);
QuartoRunner now looks for requirements.vrf, and 'vrf' is registered as an
editable text extension. The dedicated in-UI editor (and hiding it from the
file tree) follows in a separate change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 14:19:01 +00:00
claude 8530c5ebe0 Run Quarto Python kernel inside the project venv, not base python
Build and Deploy Verso / deploy (push) Successful in 9m33s
The global python3 kernelspec hardcodes /usr/bin/python3, so even with
QUARTO_PYTHON pointing at the project venv, Quarto launched the kernel in the
base interpreter — packages installed into the venv (e.g. openpyxl) were not
importable. Register a python3 kernelspec inside the venv via
'ipykernel install --sys-prefix' (kernel.json argv -> the venv's python); since
Quarto runs kernel discovery through QUARTO_PYTHON, the venv's kernelspec is
found ahead of the global one and the kernel runs in the venv.

Bump the completion marker (.verso-complete -> .verso-ready) so venvs built
before this change are rebuilt with the kernelspec.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 13:50:01 +00:00
claude 83b6b323c3 Add cv2/tqdm to base; implement per-project Python venvs (Design B, Phase 1)
Build and Deploy Verso / deploy (push) Successful in 17m0s
Base image: add opencv-python-headless (cv2) and tqdm to the bundled
scientific stack, and python3-venv (needed to build per-project venvs).

Per-project dependencies: a project's requirements.txt is now installed into a
venv cached by its sha256 (python3 -m venv --system-site-packages, so the
bundled stack stays visible and only extra packages are installed); QuartoRunner
points Quarto at it via QUARTO_PYTHON. A per-hash flock serialises concurrent
builds; pip output is merged into output.log; on failure the render falls back
to the base interpreter. Venvs live under PYTHON_VENVS_DIR
(default /var/lib/overleaf/data/python-venvs).

Gating: PythonVenvGate.userCanInstallPython restricts installs to the project
owner + invited collaborators (ignorePublicAccess excludes anonymous/link
users), threaded to CLSI as allowPythonInstall on the editor compile,
presentation export, and publish paths. Behind OVERLEAF_ENABLE_PROJECT_PYTHON_VENV
(enabled in the deployment). Design doc updated; Phase 2 (egress policy) and
Phase 3 (venv eviction) remain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 13:14:47 +00:00
claude 8b9fe4e760 CI: stop Yarn git-dep prepare from corrupting the shared fallback cache
Build and Deploy Verso / deploy (push) Successful in 12m50s
The web build's 'yarn install' re-prepares the git-sourced @replit/codemirror-*
deps whenever the Berry cache misses (BuildKit GCs it between builds). Each
prepare uses Yarn Classic, which pulls every esbuild platform binary into the
single shared /usr/local/share/.cache/yarn folder; running several prepares in
parallel races and corrupts it ('tar content corrupt', EEXIST, missing
.yarn-tarball.tgz). Bumping the cache id only cleared it until the next
cache-miss build (#69).

Serialise Yarn's fetch with YARN_NETWORK_CONCURRENCY=1 on the install and
compile steps so the prepares no longer write that cache concurrently, and bump
the fallback cache id (v2 -> v3) once more to discard the currently-corrupt
cache. Slightly slower fetch, but no more random cache corruption.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 12:20:35 +00:00
claude 654cd7db9f Fix Quarto Jupyter engine: install PyYAML
Build and Deploy Verso / deploy (push) Has been cancelled
Quarto's own jupyter wrapper (/opt/quarto/share/jupyter/jupyter.py ->
notebook.py) does 'from yaml import safe_load', so executing a {python} cell
failed with ModuleNotFoundError: No module named 'yaml'. The minimal jupyter
stack didn't pull PyYAML in (psutil/ipython already come via ipykernel), so
add pyyaml explicitly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 11:39:48 +00:00
claude 51620caf8b docs: design for per-project Python dependencies (cached venv)
Captures the proposed requirements.txt -> cached virtualenv approach (keyed by
hash, --system-site-packages, QUARTO_PYTHON), its guard rails (auth gating,
egress restriction, resource caps) given anonymous write is enabled, lifecycle
(eviction, failure UX), a phased rollout, and the open decisions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 11:35:38 +00:00
claude 96fc1a90a1 Surface missing-Python-package errors clearly in the Quarto log
Build and Deploy Verso / deploy (push) Successful in 14m45s
When a {python} cell fails with ModuleNotFoundError/ImportError, the Quarto
log parser now emits an actionable error ('Python package "X" is not
installed on the server') noting which scientific packages are pre-installed,
instead of leaking an opaque traceback line.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 11:32:08 +00:00
claude f1d827202f Bundle the scientific-Python stack in the base image
Pre-install numpy, pandas, scipy, matplotlib, seaborn, scikit-learn, sympy,
plotly and tabulate so the common data-science libraries are available to
Quarto's Python code cells out of the box. matplotlib uses the headless Agg
backend automatically in the compile environment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 11:25:18 +00:00
claude 8691907210 Enable Python code execution in Quarto documents (install Jupyter)
Build and Deploy Verso / deploy (push) Successful in 14m1s
Quarto executes ```{python}``` cells via a Jupyter kernel, but the base image
had no Jupyter ('Jupyter: (None)') and the runtime user (www-data) couldn't
create Quarto's log dir or Jupyter's runtime dir ('Permission denied: mkdir
/var/www/.local/...').

Install the headless Jupyter execution stack (jupyter-client, nbclient,
nbformat, ipykernel) for the system python3 Quarto uses, and register a
system-wide python3 kernelspec under /usr/local/share/jupyter. Also make
/var/www/.local writable by www-data so Quarto/Jupyter can write their
runtime/log files (mirrors the existing /var/www/.cache setup).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 11:20:22 +00:00
claude e3fb781042 CI: bust corrupted Yarn fallback build cache
Build and Deploy Verso / deploy (push) Successful in 8m0s
The web compile step failed packing the git-sourced @replit/codemirror-*
deps with 'tar content corrupt' / EEXIST / missing .yarn-tarball.tgz errors,
all under /usr/local/share/.cache/yarn/v6 — i.e. a corrupted BuildKit
fallback-cache mount (likely left half-written by an interrupted build), not
a code or dependency change. Bump the fallback cache id so BuildKit
allocates a fresh empty cache; the berry and webpack caches are untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 10:07:14 +00:00
claude f2abd42969 Presentation export: progress modal + inline failure log
Build and Deploy Verso / deploy (push) Has been cancelled
The HTML/PDF export links were plain downloads that left the browser
silently spinning during the server-side render and, on failure, saved an
error page as pdf.txt/pdf.htm. Replace them with fetch-based downloads that
show a modal: a spinner with a 'this can take up to a minute' message while
compiling, and the actual compile log inline if the export fails. The user
can dismiss at any time; a stale request that finishes after dismissal no
longer reopens the modal. Adds the three i18n keys (en/fr + extracted).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 09:57:25 +00:00
claude 7e1c2ce53a Fix standalone-HTML export: inject embed-resources into the deck frontmatter
Build and Deploy Verso / deploy (push) Has been cancelled
embed-resources cannot be enabled from the CLI: Quarto only honours it when
nested under the format, and a document's own format block fully overrides
project/CLI metadata (confirmed in Quarto docs). So --metadata embed-resources
was silently ignored and the 'standalone' HTML was the ordinary non-embedded
deck referencing a sibling _files/ dir — unstyled, no math, no images once
downloaded on its own.

For the html-standalone export, render a temporary copy of the root .qmd with
embed-resources/self-contained-math enabled and chalkboard disabled inside its
revealjs block (replacing an existing chalkboard key rather than duplicating
it), then clean the temp file up. Falls back to the original file if the deck
isn't an editable nested-revealjs document, so the export is never worse than
before.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 09:51:52 +00:00
claude 67b27c2684 Fix PDF export Chromium launch + HTML export caching
Build and Deploy Verso / deploy (push) Successful in 7m54s
The slide-PDF export failed because the CLSI runtime user has no writable
HOME, so Chromium's crashpad couldn't create its database and the browser
died on launch ('chrome_crashpad_handler: --database is required'). Give
decktape's Chromium a fresh writable temp dir via HOME/XDG_*/--user-data-dir
(plus --disable-gpu).

The standalone-HTML export kept returning the old non-embedded file partly
because the GET response had no cache headers, so the browser served its
cached copy; add Cache-Control: no-store to both export responses. Also
switch the embed-resources flags to the long '--metadata KEY:VALUE' form
(the documented Quarto syntax) to remove any ambiguity vs the '-M' alias.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 09:27:44 +00:00
Jakob Ackermann ec84a88eb3 [server-ce] tests: build git-bridge latest locally in CI (#34177)
GitOrigin-RevId: 78bf654eee77a62185a53b1abdf2cd9ae0662802
2026-06-02 08:08:39 +00:00
Mathias Jakobsen 96e0830eef Merge pull request #34167 from overleaf/mj-conversion-error-update
[web] Point conversion errors to docs page

GitOrigin-RevId: 1a5208065252159b6a69bc6ae4cecae1dd0cd4d8
2026-06-02 08:08:31 +00:00
Copilot a9a9f6ee6b Migrate history-v1 recover_zip scripts from archiver to zip-stream (#32813)
* migrate recover_zip_from_backup from archiver to zip-stream

Replace the `archiver` package with `zip-stream` (the lower-level library
that `archiver` wraps) in the `recover_zip_from_backup.mjs` script and
`backupArchiver.mjs` library. The `archiver` package has known issues with
hanging when creating large zip files and is no longer actively maintained.

Changes:
- Add `zip-stream@^7.0.2` as a direct dependency
- Update `backupArchiver.mjs` to use promisified `ZipStream.entry()`
  instead of `Archiver.append()`
- Rewrite `recover_zip_from_backup.mjs` to use `ZipStream` with
  `stream/promises.pipeline` for cleaner async flow
- Keep `archiver` dependency for `project_archive.js` (separate code path)

Agent-Logs-Url: https://github.com/overleaf/internal/sessions/0df27a8b-97f1-43cc-ac26-f5247a84313f

Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>

* extract finalize timeout to named constant

Agent-Logs-Url: https://github.com/overleaf/internal/sessions/0df27a8b-97f1-43cc-ac26-f5247a84313f

Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>

* convert recover_zip.js to zip-stream, remove finalize timeout, add verbose logging

Agent-Logs-Url: https://github.com/overleaf/internal/sessions/9380d08a-d813-4e9f-a2ac-4891122c163b

Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>

* add acceptance tests for recover_zip_from_backup in raw and latest modes

Agent-Logs-Url: https://github.com/overleaf/internal/sessions/9380d08a-d813-4e9f-a2ac-4891122c163b

Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>

* fix comment formatting in recover_zip_from_backup.mjs

Agent-Logs-Url: https://github.com/overleaf/internal/sessions/9380d08a-d813-4e9f-a2ac-4891122c163b

Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>

* restore EventEmitter.defaultMaxListeners in recover_zip.js, add acceptance test

Agent-Logs-Url: https://github.com/overleaf/internal/sessions/e7443126-22d5-4d0e-a176-a7a5dba49ffd

Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>

* fix formatting

* refactor: simplify stream handling by using named imports for pipeline

* fix blob hash verification in backup acceptance tests

* fix recover_zip script and tests

* fix: exit with non-zero status on error in recover_zip.js

Agent-Logs-Url: https://github.com/overleaf/internal/sessions/ef3f109b-488f-47c9-84a5-b5269387166a

Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>

* migrate from npm to yarn

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: briangough <7457354+briangough@users.noreply.github.com>
Co-authored-by: Brian Gough <briangough@users.noreply.github.com>
GitOrigin-RevId: 6255f9610f3c846790e2ed8b1979ac08b7effece
2026-06-02 08:08:18 +00:00
Mathias Jakobsen 7053434da6 Merge pull request #34160 from overleaf/mj-tabs-design-tweaks
[web] Apply design tweaks to editor tabs

GitOrigin-RevId: c0b064c4f5977bb13a961f03d2c5f2949d338cfe
2026-06-02 08:08:13 +00:00
Mathias Jakobsen 24dba36060 Merge pull request #34152 from overleaf/mj-select-all
[web] Add select all to context menu

GitOrigin-RevId: ff5fb828db8e1cd57d1361a2e572918339e5e18b
2026-06-02 08:08:08 +00:00
Brian Gough fda0283490 Merge pull request #33377 from overleaf/lucie/js-yaml-security-fix
[Security Upgrade]: js-yaml in yarn.lock

GitOrigin-RevId: 4f388ca74de0e33a4f8894b1aa7e7963d1de552d
2026-06-02 08:07:45 +00:00
Antoine Clausse 2a5f1be811 [web] Fix "For students" link, fix toggles and navigation (#34051)
* [web] Fix footer For Students link to activate student toggle

The footer link only set itm_referrer plus a #student-annual hash. The
plans page reads the active plan/period from `plan` and `period` query
params (PlansHelper.getPlansPageViewOptions), so the student tab never
activated from the footer link.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* syncStudentModeFromPlanType after in handleDeprecatedHash

* Change URL update to use replaceState in the pricing page

* Revert "Change URL update to use replaceState in the pricing page"

This reverts commit eac71f193029e3f1c75e0c97261d8a5982c0d35c.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
GitOrigin-RevId: 69d689d0fe89fc68cefab9233739fc61da8f2ced
2026-06-02 08:07:40 +00:00
Antoine Clausse 105a0ff35c [web] Add nonprofit discount FAQ to plans page (#34126)
Insert a new "Do you offer discounts for nonprofits?" accordion item
under the educational group discount question in the "Overleaf
multi-license plans" FAQ tab. Routes the "contact sales" link through
the existing `faqContactLink` mixin so click tracking stays consistent
with the other FAQ contact links.

Closes #33494

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
GitOrigin-RevId: 582517f1d1f1f7934610253c252cf0f8af2b68a2
2026-06-02 08:07:35 +00:00
Antoine Clausse 2c7129be3a [web] Stop bolding AI features on the interstitial plans page (#34125)
* [web] Stop bolding AI features unconditionally on the interstitial

The four `strong: true` flags on the AI features in `sectionMain2026`
caused those rows to render bold on every interstitial visit, regardless
of paywall context. The original intent (per Design QA #34022) was for
boldness to highlight the features relevant to the specific paywall the
user came from (e.g. AI paywall -> AI features bolded) — that
conditional logic was never wired up, and currently no `purchaseReferrer`
or paywall reason is plumbed through to the feature config.

Remove the unconditional `strong: true` so the cards render consistently
with the pricing page. Reintroduce conditional bolding in a follow-up
once the paywall→features mapping is scoped by design.

Closes #34022

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Remove `card-include-strong` and related code

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
GitOrigin-RevId: 2112214217f3b53d34518efbca546082ce559e26
2026-06-02 08:07:31 +00:00
Antoine Clausse bd4f73b836 [web] Render "Try for free instead" CTA as link, not button (#34098)
* [web] Render "Try for free instead" CTA as link, not button

Design QA wants the "Try for free instead" CTAs on the pricing and
interstitial pages styled as marketing links (`link-monospace link-lg`)
rather than the current `btn-ghost` button. Add a `link` button type to
the `plans-cta` mixin that drops the `btn` class and applies the link
classes, and set `buttonType: 'link'` on the six `try_for_free_instead`
CTAs (plans-individual, plans-student, interstitial-payment).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Make link smaller

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
GitOrigin-RevId: f911698a9bfa19f8180e58edb3cebcea90468cbd
2026-06-02 08:07:26 +00:00
Antoine Clausse 0e4fe4090a [web] Migrate manual plurals to i18next _plural convention (#33989)
* Add tests on plurals

* Update `collabs_per_proj` and its pluralisations

* Update `n_user` and its pluralisations

* Update `showing_x_results` and its pluralisations

* Update `show_x_more_projects` and its pluralisations

* `bin/run web npm run extract-translations`

* Populate `_plural` keys in non-en locales

For 2-form languages (da, de, es, fi, fr, it, nl, no, pt, sv, tr), copy
the existing bare-key value into the new `_plural` sibling to prevent
i18next from falling back to English for count!=1.

Also remove orphan singular keys (`collabs_per_proj_single`,
`showing_1_result*`) left over from the previous commits.

Bare-key values remain in their original plural form pending translator
review — count=1 will still render the plural form in non-en until
translators flip those to singular. Multi-form (cs, pl, ru) and
single-form (ja, ko, zh-CN, zh-TW) locales are unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* Flip non-en bare-key values to singular form

Per review, the i18next v3 plural convention uses the bare key for count=1
(singular) and `_plural` for count!=1. The non-en bare-key values were
left as the original plural form by the previous commit so the `_plural`
siblings could be copied from them; this commit flips the bare values to
the singular form per language.

Languages where singular and plural noun forms coincide (Finnish, Swedish,
Turkish) are unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* Apply suggestions from code review

Co-authored-by: Olzhas Askar <olzhas.askar@gmail.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Olzhas Askar <olzhas.askar@gmail.com>
GitOrigin-RevId: 628513ca792c2dcce023247e52b7320e2741cc54
2026-06-02 08:07:17 +00:00
Antoine Clausse 58884231c1 [web] Redirect to plans page when previewing subscription change without an existing subscription (#33925)
GitOrigin-RevId: feb47fb519dd7872149d787a8543293cae66a908
2026-06-02 08:07:12 +00:00
Chris Dryden db1deb1617 Merge pull request #33895 from overleaf/cd-pyodide-unsupported-module-message
Improve error messaging for python modules unsupported by Pyodide

GitOrigin-RevId: 038c672ad9da46ea6d4640b8ed37426c92d22e72
2026-06-02 08:07:01 +00:00
Brian Gough b8067723b6 Merge pull request #33628 from overleaf/lg-otel-security-upgrade
Bump @opentelemetry/sdk-node and auto-instrumentations-node (GHSA-q7rr-3cgh-j5r3)

GitOrigin-RevId: 2d5bac25735e9ef8a462423505f142f49ef73d8b
2026-06-02 08:06:52 +00:00
Davinder Singh c09ada9ddb Revert "[WEB] Move Review Toggle into the toolbar (#34066)" (#34150)
This reverts commit 36847e0debdc4dce5f96492261d25e7cc46b2e96.

GitOrigin-RevId: 9bab306156006f683314fd59eea45854f62eae62
2026-06-02 08:06:47 +00:00
Davinder Singh 8b61e8cdca [WEB] removing the beta icon from import modal (#34025)
* removing the beta icon from import modal

* removing the unused classes

GitOrigin-RevId: 11dbe04f31ba831f96e30ab93f3f6c732166e08f
2026-06-02 08:06:38 +00:00
Davinder Singh e0f542a241 [WEB] Move Review Toggle into the toolbar (#34066)
* move Review Toggle into the toolbar

* cleaning up and adding a comment

* adding the cursor styling

* adding isolation on writefull toolbar to adjust z-index of writefull toolbar

* fixing the dark mode colours for review dropdown trigger

* Fix review mode switcher dark mode styles

GitOrigin-RevId: 36847e0debdc4dce5f96492261d25e7cc46b2e96
2026-06-02 08:06:34 +00:00
Davinder Singh ac83bc520c Merge pull request #34065 from overleaf/ds-move-toggle-to-right
[WEB] Move Code/Visual toggle to right-hand side and redesign

GitOrigin-RevId: efc1aa062fd44e20fdf719a6d4ecba9d8bb0e5e8
2026-06-02 08:06:28 +00:00
claude 4d9adb2723 Fix presentation export: Quarto -M uses colon syntax, harden decktape
Build and Deploy Verso / deploy (push) Successful in 8m13s
The standalone-HTML export produced a non-self-contained file (no slide
CSS/JS, math or images when opened away from the server) because Quarto's
--metadata/-M flag uses KEY:VALUE (colon), not KEY=VALUE. '-M
embed-resources=true' silently registered a bogus key and left
embed-resources unset. Switch to colon syntax and also embed MathJax
(self-contained-math:true) so equations render offline.

For the slide PDF, add --disable-dev-shm-usage (the usual cause of
Chromium crashing inside a container with a small /dev/shm), and have the
export controller return the compile log as text/plain on failure so a
failed PDF export shows the real decktape/Chromium error instead of an
HTML page the browser saves as 'pdf.htm'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 07:11:51 +00:00
claude c38e2b8b49 Presentation download menu: standalone HTML + faithful slide PDF (decktape)
Build and Deploy Verso / deploy (push) Failing after 24m2s
In RevealJS mode the download button becomes a 2-choice menu:

- Standalone HTML: a one-off compile with embed-resources (chalkboard and other
  runtime-only plugins are dropped, since they don't survive self-containment),
  yielding a single portable .html.
- Slide PDF: render the deck, then print it with decktape (headless Chromium)
  to a faithful one-slide-per-page PDF.

Implementation:
- Dockerfile-base: install decktape + headless Chromium (open-source; deps via
  playwright install-deps for Ubuntu-Noble correctness). Base-only change.
- QuartoRunner honours options.exportMode ('html-standalone' | 'pdf-slides');
  exportMode is threaded web ClsiManager -> CLSI RequestParser -> CompileManager
  -> runner.
- New GET /project/:id/presentation-export/:format compiles in the matching
  export mode and streams the result as a download (PresentationExportController,
  reusing ClsiManager.getOutputFileStream).
- pdf-hybrid-download-button shows the dropdown when the output is output.html;
  PDF/LaTeX projects keep the single download button.
- i18n: download_as_standalone_html / download_as_pdf_slides (en + fr +
  extracted-translations.json).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 21:00:50 +00:00
claude 899879472e Default the instance to French and translate the Verso-specific strings
Build and Deploy Verso / deploy (push) Successful in 7m35s
- Deployment: set OVERLEAF_SITE_LANGUAGE=fr so the UI defaults to French.
- fr.json: add French translations for the Verso strings — blank_/example_
  {quarto,latex,typst}_project, share_compiled_presentation(_info),
  presentation_link_{members,private,public}, reset_link, and preview (which
  was missing from fr.json). Other untranslated keys keep falling back to
  English via the translations-loader.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 20:04:42 +00:00
claude 28a578ec85 Fix untranslated UI keys (raw "snake_case" labels) + anonymous edit links
Build and Deploy Verso / deploy (push) Successful in 7m46s
The frontend bundles only the locale keys listed in
frontend/extracted-translations.json (a custom webpack translations-loader
filters en.json to that set, normally regenerated by i18next-scanner). Every
key added by hand to en.json without also adding it here renders as its raw
key — which is why "blank_quarto_project", "share_compiled_presentation", etc.
showed up literally in the New-project menu and Share dialog.

Add all introduced keys to extracted-translations.json: blank_/example_
{quarto,latex,typst}_project, share_compiled_presentation(_info),
presentation_link_{members,private,public}, reset_link.

Also enable anonymous read-AND-write share links (edit without an account) via
OVERLEAF_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING; read-only links already worked
through OVERLEAF_ALLOW_PUBLIC_ACCESS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 19:40:47 +00:00
claude 4766071e69 Published presentations: three access tiers + per-link reset
Build and Deploy Verso / deploy (push) Successful in 7m57s
Adds a project-members-only link tier and independent link rotation.

- Three tokens per project instead of two: publicToken (anyone), loginToken
  (any logged-in user), memberToken (only users who can read the project).
  serve() resolves the token to its tier and enforces accordingly — 'member'
  requires AuthorizationManager.canUserReadProject.
- New POST /project/:id/publish-presentation/regenerate { tier } rotates a
  single tier's token (invalidating only that old link), leaving the snapshot
  and the other links intact.
- Share dialog now shows three links (members / logged-in / anyone), each with
  its own Copy and Reset buttons; Publish refreshes, Unpublish removes all.
  Preview button opens the logged-in-users link.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 18:19:15 +00:00
claude 539cb877b4 Deploy: allow public (anonymous) access so share links work without login
Build and Deploy Verso / deploy (push) Successful in 1m20s
The web service installs a site-wide login gate (router.mjs: webRouter.all('*',
requireGlobalLogin)) whenever Settings.allowPublicAccess is false — which it was,
since OVERLEAF_ALLOW_PUBLIC_ACCESS wasn't set. That gate bounced every anonymous
request to /login, breaking both Overleaf's own link-sharing and the public
presentation links (the dynamic token routes can't be in the exact-match
global whitelist, so there's no per-path exemption — allowPublicAccess is the
intended knob).

Set OVERLEAF_ALLOW_PUBLIC_ACCESS=true on the verso Deployment. Per-project and
per-route authorization still applies, and private presentation links still
require a login (enforced in the serve handler), so only genuinely public
content is reachable anonymously.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 17:50:48 +00:00
claude 4d3ac2b9ea Published presentations: two fixed links (public + private) instead of a toggle
Build and Deploy Verso / deploy (push) Successful in 7m30s
Replace the single token + visibility toggle with two stable tokens per project
pointing at the same snapshot:
  - publicToken  → anyone with the link
  - privateToken → any logged-in Verso user

This fixes both reported issues: changing visibility no longer mutates a link
(there's no toggle — both links always exist), and a public link can never
become private by accident. It also fixes public links redirecting to login:
access is now decided purely by which token was used (public token = open),
not a per-record flag.

- Model: storageId (snapshot dir) + publicToken + privateToken; drop token/
  visibility.
- Manager.publish: mints both tokens once and reuses them on re-publish; serve
  resolves a token to its record and treats the public token as open.
- Controller: returns { publicUrl, privateUrl }.
- Share dialog: shows the private and public links side by side, each with its
  own copy button; Publish refreshes, Unpublish removes. Preview button opens
  the private link.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 16:07:37 +00:00
claude 2cb81bd246 Serve published decks from a trailing-slash URL so assets load
Build and Deploy Verso / deploy (push) Successful in 7m29s
A deck served at /p/:token (no trailing slash) made the browser resolve its
relative asset references (main_files/... CSS+JS) against /p/, 404ing them —
so the deck rendered as unstyled HTML with no reveal.js. Publish links now end
in a slash, and the bare /p/:token URL 301-redirects to /p/:token/, so relative
assets resolve under /p/:token/ and load correctly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 15:49:21 +00:00
claude eae5a0ebc7 Store published presentations on the writable data volume
Build and Deploy Verso / deploy (push) Successful in 2m41s
The default published-presentations folder resolved to the app dir
(/overleaf/services/web/data/published), which isn't writable by the runtime
user → EACCES on publish. Point it at the Overleaf data volume in the
production config (Path.join(DATA_DIR, 'published') = /var/lib/overleaf/data/
published), alongside compiles/output, where the app user can write (and which
persists when a volume is mounted). Overridable via PUBLISHED_PRESENTATIONS_PATH.
2026-06-01 15:41:18 +00:00
claude cb0d9ac9fa Fix publish-presentation failing right after an editor compile
Build and Deploy Verso / deploy (push) Successful in 7m49s
CompileManager.compile debounces compiles via a Redis key set on every compile
(_checkIfRecentlyCompiled), returning {status:'too-recently-compiled',
outputFiles:[]} when the editor has just auto-compiled. Publishing called
compile() and then required output.html, so it threw "did not produce an HTML
presentation" — which is why Preview/Publish errored whenever the deck was
freshly compiled.

- CompileManager.compile: honour options.bypassRecentCompileCheck to skip the
  debounce (still runs the normal autocompile-limit guards).
- PublishedPresentationManager: publish with bypassRecentCompileCheck, and put
  the compile status in the error message for diagnosis.
- Controller: catch publish errors, log them, and return the message so the
  Share dialog can show what went wrong instead of a generic error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 15:30:46 +00:00
claude 59055aa67e Publish presentations: share-modal section + Preview button (UI)
Build and Deploy Verso / deploy (push) Successful in 7m53s
Wires the two entry points to the publishing backend:

- Share dialog: a "Share compiled presentation" section (owner only) with a
  public / logged-in-users-only choice, Publish/Unpublish, and a copyable link.
- Top-right toolbar: a "Preview" button that publishes a private (logged-in-
  users-only) link in one click and opens the standalone deck in a new tab
  (opened synchronously to dodge popup blockers).

Both talk to /project/:id/publish-presentation. Reuses existing i18n
(publish/unpublish/copy/preview); adds share_compiled_presentation(_info) and
presentation_link_public/private.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 14:39:39 +00:00
claude 18f9220e73 Publish presentations as standalone shareable links (backend)
Adds the engine + API for publishing a project's compiled HTML/RevealJS deck as
a stable, standalone snapshot served at /p/:token, independent of the editor.

- PublishedPresentation model: one per project { token, visibility, buildId },
  re-publishing keeps the same token so shared links stay stable.
- Manager.publish: compiles the project, then copies the HTML deck + its _files
  assets + referenced media (now included thanks to the OutputFileFinder fix)
  into a persistent snapshot dir (Settings.path.publishedPresentationsFolder,
  override with PUBLISHED_PRESENTATIONS_PATH). Logs/aux are excluded.
- Routes: GET/POST/DELETE /project/:id/publish-presentation (owner/reader) for
  status/publish/unpublish; public GET /p/:token(/*) serves the deck full-page.
  Visibility is enforced in the handler: 'public' = anonymous, 'private' = any
  logged-in Verso user. CSP is dropped on these responses so reveal.js renders.

Frontend entry points (share-modal section + top-right Preview button) follow.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 14:34:06 +00:00
claude 9b01fab383 Serve referenced media for HTML/RevealJS output
Build and Deploy Verso / deploy (push) Successful in 7m39s
OutputFileFinder excluded all incoming project resources from the output set,
and OutputCacheManager only copies outputs into the served build dir. For PDF
that's fine (media is embedded), but for HTML/RevealJS the browser fetches
images/videos/fonts from the output path at runtime — so a deck's referenced
image (a project input file) was never served and rendered broken in the
preview.

When the compile produced output.html, keep media inputs (img/video/audio/font
extensions) in the output set so they're served alongside the deck. PDF/LaTeX
compiles are unaffected. This also makes referenced media land in output.zip,
which the upcoming presentation-publishing feature relies on.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 14:01:58 +00:00
claude 7c2b903e4d Warn about missing images/videos in Quarto HTML output
Build and Deploy Verso / deploy (push) Successful in 7m49s
Since we dropped --embed-resources (so RevealJS plugins like chalkboard work),
pandoc no longer tries to fetch referenced media for HTML output, so a missing
image or video produces no compile-time warning — it only renders broken in the
browser. PDF/Typst output is unaffected because Typst hard-errors on a missing
image.

After an HTML render, QuartoRunner now scans output.html for local media
references (img/video/audio/iframe src, poster, RevealJS data-background-*) and
appends a `[WARNING] Missing resource: …` line to output.log for any that don't
exist on disk. External URLs, data URIs, anchors and Quarto's own generated
<basename>_files assets are ignored. The [WARNING] prefix is recognised by the
Quarto/Typst log parser, so these show up in the Warnings tab.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 13:24:56 +00:00
claude 2d4ca6f13a Fix LaTeX projects failing to compile (HTTP 500, no logs)
Build and Deploy Verso / deploy (push) Successful in 7m44s
Project.compiler defaults to settings.defaultLatexCompiler ('quarto' in this
fork), so every .tex project carried compiler='quarto'. Since the CLSI runner
is chosen by file extension, a .tex root still goes to LatexRunner, whose
_buildLatexCommand threw `unknown compiler: quarto` — surfacing as an opaque
HTTP 500 with no compile log.

- LatexRunner: fall back to pdfLaTeX when the compiler isn't a known TeX engine
  instead of throwing. Universal safety net (covers existing projects, uploads
  and GitHub imports already saved with compiler='quarto').
- ProjectCreationHandler: store a sensible compiler per flavour at creation via
  a shared _flavourConfig helper — blank/example LaTeX → 'pdflatex',
  Typst → 'typst', Quarto → 'quarto' — so the compiler dropdown reflects the
  engine and LatexRunner receives a valid one directly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 13:08:57 +00:00
claude d67bc77b0e Add a Typst compiler alongside Quarto and LaTeX
Build and Deploy Verso / deploy (push) Successful in 7m37s
A project whose root file is a .typ file now compiles straight to PDF with
Typst, as a third engine beside Quarto (.qmd) and latexmk (.tex). Dispatch
stays purely extension-based.

CLSI:
- New TypstRunner.js: runs `quarto typst compile <main>.typ output.pdf` (reuses
  the Typst bundled in Quarto, so no extra binary / Docker change). stderr is
  merged into output.log.
- CompileManager: _isTypstFile + a TypstRunner branch in _getRunner, and
  TypstRunner added to the isRunning check and stopCompile kill list.
- RequestParser: 'typst' added to VALID_COMPILERS.

web:
- settings.defaults: 'typ' added to validRootDocExtensions and the text
  extensions (so .typ opens in the editor); 'typst' added to safeCompilers.
- output-files: the Quarto/Typst log parser (which already understands Typst
  `error:`/`warning:` + `┌─ file:line:col` diagnostics) now also handles .typ
  compiles, so their errors/warnings populate the log tabs.

Polish:
- New-project menu: "Blank Typst project" + "Example Typst project" in both the
  main and welcome dropdowns, backed by createBasicProject/createExampleProject
  flavour 'typst', a new mainbasic.typ template and an example-project-typst
  presentation (math, an image, a table, lists).
- Compiler dropdown gains a "Typst" option (cosmetic; dispatch is by extension).

README updated: three compilers side by side, with a Writing-a-Typst-document
section.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 12:56:30 +00:00
claude 2a9c4cfe81 New-project menu: split into Quarto and LaTeX blank/example options
Build and Deploy Verso / deploy (push) Successful in 7m44s
Replace the generic "Blank project" / "Example project" entries with four
flavour-specific ones in both the New-project dropdown and the welcome-screen
dropdown:

- Blank Quarto project   -> empty main.qmd (format: typst)
- Blank LaTeX project    -> empty main.tex
- Example Quarto project -> a Reveal.js presentation showcasing images, math,
  a table, code and incremental lists (new template
  project_files/example-project-quarto/)
- Example LaTeX project  -> the existing LaTeX example

Backend: ProjectController.newProject now dispatches the `template` value
(blank_quarto/blank_latex/example_quarto/example_latex, plus the legacy
'example'/'none') to createBasicProject(flavour) / createExampleProject(flavour).
_createRootDoc takes a root-doc name so each flavour gets the right extension —
this also fixes the LaTeX example, whose root doc was wrongly created as
main.qmd, back to main.tex (matching the acceptance test). Signatures stay
backward compatible (flavour defaults: blank=quarto, example=latex).

Also refresh the README: Verso now runs Quarto and LaTeX side by side
(engine chosen by root-file extension), not Quarto instead of LaTeX.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 12:30:07 +00:00
claude 3e10d1c4ee Recolour remaining green brand-accent surfaces to the accent token
Build and Deploy Verso / deploy (push) Successful in 7m50s
The $accent knob caught primary buttons, but several places still
referenced the green ramp directly as a brand-accent colour (rather than
genuine success semantics). Repoint those at the --bg-accent-* tokens so
they too follow the single $accent knob:

- navbar Sign in / Register ("primary" + subdued/link hover) buttons
- file-tree selected-item highlight and drag background (IDE redesign,
  light and dark)
- document-outline highlighted item (IDE redesign, light and dark)
- the Visual/Code editor-switcher button mixin
- web/content hyperlinks (--link-web*), e.g. on the project dashboard;
  dark-theme variants point at the blue ramp to stay readable on dark

Genuine success/positive greens (notification success icon,
$content-positive, beta badges, etc.) are deliberately left green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 11:49:12 +00:00
claude b3541ba6f3 CI: skip unchanged base image and add registry build cache
Build and Deploy Verso / deploy (push) Successful in 12m40s
Two build-speed changes to the Gitea Actions deploy workflow.

(#1) Build the base image only when it changes. The base layers' only
repo input is server-ce/Dockerfile-base, so the prepare step hashes that
file and the base is tagged verso-base:base-<hash>; the app builds FROM
that exact tag. If a base with the current hash already exists in the
registry, the heavy base build (apt ~111s, TeX Live ~51s, Quarto, plus
its ~49s export/push) is skipped entirely — which is every commit that
doesn't touch Dockerfile-base.

(#2) Import/export a registry-backed layer cache (verso-cache:base and
verso-cache:app, mode=max) on both builds. Unchanged layers are reused
instead of rebuilt: yarn install is skipped when package.json is
unchanged, and only the web compile re-runs on a frontend source change.
No new cluster resources — the cache lives as extra tags in the same
in-cluster registry.

First run after this is still a full build (populates the caches and the
hash-tagged base); subsequent commits should be substantially faster.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 11:30:20 +00:00
claude aa3fb56458 Parse Quarto logs and make the accent colour a single knob
Build and Deploy Verso / deploy (push) Successful in 11m55s
Quarto compiles (.qmd/.md/.Rmd, dispatched to QuartoRunner) write
Typst/Pandoc/Quarto diagnostics to output.log that the LaTeX log parser
does not understand, so the Errors/Warnings tabs stayed empty. Add a
dedicated quarto-log-parser that recognises Typst `error:`/`warning:`
(+ `┌─ file:line:col`), Pandoc `[WARNING]`/`[ERROR]`, Quarto CLI/Deno
`ERROR:`/`WARNING:`, and knitr `Quitting from lines`. handleLogFiles now
routes to it when the root file is a Quarto file (mirrors CLSI dispatch),
otherwise the LaTeX path is unchanged.

Also decouple the UI accent from the green ramp. The framework already
funnels every primary/accent surface (primary buttons, Bootstrap
$primary/$success, --btn-primary-background) through the --bg-accent-*
tokens; those just happened to point at Overleaf green. Introduce a
single $accent knob in foundations/colors.scss (with auto-derived
hover/tint shades) and repoint the accent tokens at it, defaulting to
the Verso/Quarto blue. Re-skinning the whole UI is now a one-line edit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 10:57:06 +00:00
claude e87bbfe5b0 HTML preview: drop embed-resources and clear stale deck on failure
Build and Deploy Verso / deploy (push) Successful in 12m5s
Two HTML/RevealJS preview fixes:

1. Stop passing --embed-resources to quarto render. A self-contained
   single-file HTML breaks reveal.js plugins that load/store resources at
   runtime (chalkboard, multiplex) and is slow to transfer. Quarto now
   emits the HTML plus a sibling "<basename>_files/" asset dir referenced
   by relative paths; both are served from the same .../output/ path
   (nginx output/(.+) and web :file(.*) both capture slashes), so the
   relative links resolve. The renamed output.html still points at the
   unchanged "<basename>_files" dir. This also fixes the slow-load issue,
   since assets now load on demand instead of one giant inlined file.

2. On a failed compile that follows a successful one, the previous deck
   stayed in the iframe, making the failure look like a success. We now
   clear pdfFile when a non-success status carries a stale output.html.
   The last-good-PDF-beside-the-error behaviour is preserved for PDF
   output (only output.html is dropped).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 08:40:18 +00:00
claude 56d66b109e Outline: ignore YAML frontmatter and strip Quarto attribute blocks
Build and Deploy Verso / deploy (push) Successful in 12m25s
Two fixes to the Markdown/Quarto file outline:

1. The last frontmatter line (e.g. `format: typst`) appeared as a
   heading. The Lezer Markdown grammar has no frontmatter support, so it
   reads the closing `---` of the YAML block as a Setext underline and
   promotes the line above it to a heading. Detect the leading
   `---`...`---`/`...` block and skip any heading inside it.

2. Pandoc/Quarto attribute blocks were shown in titles, e.g.
   `## Slide {.smaller auto-animate="true"}`. Strip a trailing `{...}`
   from the extracted title.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 08:30:15 +00:00
Eric Mc Sween 31fbc3daee Merge pull request #34128 from overleaf/em-library-analytics
Add analytics events to the account-level library page

GitOrigin-RevId: d0357f37a89ec29cca5b6b375a9553fbdf021b00
2026-06-01 08:05:02 +00:00
Gernot Schulz a0ca344065 Merge pull request #34127 from overleaf/gs-j-cd-hooks
Add deploy pipeline trigger hooks to Jenkinsfiles

GitOrigin-RevId: 80bb89615ae16b733009dca21a5fc41b5c30e993
2026-06-01 08:04:55 +00:00
Malik Glossop 54e122610e Merge pull request #34100 from overleaf/mg-fix-style
Stop inherited color overriding active list group item colour

GitOrigin-RevId: 7e36c2129661b4582658a5ccd9edfb15f12e701c
2026-06-01 08:04:52 +00:00
Domagoj Kriskovic 10ef1d0f34 [web] Fix empty lines being invisible in Python script output
GitOrigin-RevId: eb4b732cae74fa050384fd4cec6bd96a9caae152
2026-06-01 08:04:45 +00:00
claude b6c1a2d5ce Fix empty titles in Markdown/Quarto file outline
Build and Deploy Verso / deploy (push) Successful in 12m13s
The outline entries showed up at the right lines and jumped correctly,
but their titles were blank. The text-extraction walked the heading
node's children and collected non-HeaderMark child text — but in the
Lezer Markdown grammar a heading has NO child node for its text; the
only children are the HeaderMark nodes. The title text lives in the
gaps between marks, so the walk collected nothing.

Slice the whole heading's source instead and strip the markers:
leading/trailing '#'s for ATX headings and the '==='/'---' underline
for Setext headings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 08:04:42 +00:00
Domagoj Kriskovic 987b3a1f71 Track script-runner-opened analytics event
GitOrigin-RevId: fb95aa2f5ad649061a6b8e9797789024a3345f3b
2026-06-01 08:04:41 +00:00
domagojk 270cbaf84e Move python labs icon next to run button
Closes #33892

GitOrigin-RevId: c48d920ee982ddd5e4295fc1279b0f70096820d1
2026-06-01 08:04:37 +00:00
Jakob Ackermann 3c763015ce [monorepo] consolidate clsi-lb host/ip env-vars (#33894)
* [monorepo] consolidate clsi-lb host/ip env-vars

Target env-var is CLSI_LB_HOST. Keep CLSI_LB_IP populated for a week.

* [monorepo] sort dev-environment.env hosts

GitOrigin-RevId: 95d12753c86ffb91264f8971e1c2c412c60de790
2026-06-01 08:04:31 +00:00
Olzhas Askar b5a73efaeb Merge pull request #34060 from overleaf/oa-timeout-cta
[web] Compile timeout CTA

GitOrigin-RevId: c1dd014150964ffec1b556943f572d3e5a8069ce
2026-06-01 08:04:24 +00:00
claude 5f761c1772 Use minimal scheme-basic TeX Live install (small, fast, reversible)
Build and Deploy Verso / deploy (push) Has been cancelled
Reverts the heavy multi-collection texlive install back toward the
original upstream-Overleaf approach: install-tl with scheme-basic
(~300 MB) plus latexmk and texcount via tlmgr, no docfiles/srcfiles.
This restores the fast, small base image we had before LaTeX support
was added in full.

Tradeoff: documents needing tikz/beamer/siunitx/extra fonts won't
compile out of the box for now — those should stay in Quarto/Typst
until the project is mature enough to justify a full TeX Live.

Made deliberately easy to reverse: a header comment documents that
switching scheme-basic -> scheme-full (one line) restores the complete
toolchain, or individual packages can be appended to the tlmgr list.
Uses TEXDIR=/usr/local/texlive (unversioned) so PATH stays stable
across TeX Live releases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 08:01:07 +00:00
claude 4800a51957 Use a curated TeX Live set instead of near-full to speed up builds
Build and Deploy Verso / deploy (push) Successful in 14m42s
The previous install expanded texlive-full (minus -doc/-lang-), pulling in
essentially every CTAN package plus inkscape's large GTK GUI tree — ~20 min
and several GB. Replace it with a curated set of meta-packages that covers
the vast majority of documents: latex base/recommended/extra, recommended
fonts, plain-generic, science (math/physics), xetex, luatex, bibtex-extra,
extra-utils (texcount), plus latexmk/biber/chktex/pygments.

Smaller and faster to build. Documents needing an omitted package can have
the relevant texlive-* collection added back. Drops inkscape (only used for
auto SVG->PDF conversion) to avoid its heavy GUI dependency chain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 21:52:56 +00:00
claude 7c86657548 CI: pull deploy image via public registry address
Build and Deploy Verso / deploy (push) Has been cancelled
The cluster nodes' containerd can only pull from registry.alocoq.fr, not
the in-cluster service name. Keep pushing via the in-cluster address (to
bypass the Traefik upload-timeout), but reference registry.alocoq.fr/verso
in the test Deployment and the rolling update. Both addresses front the
same registry storage, so the pushed image resolves at the public name.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 21:30:45 +00:00
claude 3af4e2f46a CI: write buildkitd.toml in-container instead of a ConfigMap
Build and Deploy Verso / deploy (push) Failing after 25m12s
The previous approach created a verso-buildkitd-config ConfigMap, but the
workflow's RBAC does not permit creating new cluster resources. Write the
buildkitd.toml (marking the in-cluster registry as http/insecure) directly
inside the buildkit container at runtime via printf, and drop the configMap
volume/mount. No new k8s resources are created.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 21:01:16 +00:00
claude 8f2f6d1684 CI: push images to in-cluster registry to bypass Traefik
Build and Deploy Verso / deploy (push) Failing after 1s
The TeX Live layer (~3.5 GB) failed to push to registry.alocoq.fr:
Traefik severed the upload mid-stream ("client disconnected during blob
PUT ... unexpected EOF"), buildkit retried at the wrong offset, and the
registry returned "blob upload invalid".

Push to the in-cluster registry Service (registry.git.svc.cluster.local:5000)
instead, so the upload never traverses Traefik. Changes:
- buildctl outputs use registry.insecure=true (registry is plain HTTP)
- add a verso-buildkitd-config ConfigMap with buildkitd.toml marking the
  registry http/insecure, so the second build can pull the base image back
- the verso Deployment and rolling update reference the in-cluster image

NOTE: the cluster nodes' containerd must also treat
registry.git.svc.cluster.local:5000 as an insecure registry, otherwise
the kubelet image pull for the test deployment will fail. That is node-
level config outside this repo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 20:46:30 +00:00
claude 3bb293f7a7 Fix TeX Live install: texcount is not a standalone package
Build and Deploy Verso / deploy (push) Has been cancelled
The base image build failed with "E: Unable to locate package texcount".
texcount ships inside texlive-extra-utils, not as its own apt package.
Replace the bogus texcount entry with texlive-extra-utils (which provides
both texcount and latexmk). latexmk is kept explicit for clarity.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 19:54:51 +00:00
claude 2ae860a1a8 Raise upload limit from 50 MB to 500 MB
Build and Deploy Verso / deploy (push) Has been cancelled
Both limits that gate uploads are bumped in tandem so they don't conflict:
- settings.defaults.js maxUploadSize: 50 MB → 500 MB (app-level check)
- nginx.conf.template client_max_body_size: 50m → 500m (proxy body limit)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 19:38:21 +00:00
claude 422ac30e6c Support LaTeX and Quarto compilation in parallel
Build and Deploy Verso / deploy (push) Has been cancelled
Verso now compiles both .tex (latexmk) and .qmd (Quarto) projects,
dispatching by the root file's extension rather than replacing one with
the other. LaTeX and Quarto projects can coexist on the same server.

CompileManager: re-import LatexRunner and add a _getRunner() dispatcher
  that returns a uniform {run, isRunning, kill} interface. .qmd/.md/.Rmd
  → QuartoRunner; everything else (.tex/.ltx/.Rtex/.Rnw) → LatexRunner.
  stopCompile now checks/kills both runners since it has no root path.

compiler-setting.tsx: restore the LaTeX engine choices (pdfLaTeX, LaTeX,
  XeLaTeX, LuaLaTeX) alongside Quarto. The dropdown still controls which
  TeX engine latexmk uses; actual engine dispatch is by file extension.

Dockerfile-base: reinstall TeX Live alongside Quarto (texlive-full minus
  -doc/-lang- packages, plus xetex/luatex/biber/latexmk/texcount/chktex/
  synctex). Restore TEXMFVAR for a writable LuaTeX cache. This brings back
  a large image, which is the accepted cost of full LaTeX+Quarto support.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 19:27:39 +00:00
claude a89b8bd282 Enable gzip for HTML/CSS/JS output in clsi-nginx
Build and Deploy Verso / deploy (push) Successful in 11m13s
RevealJS presentations are served as (currently embed-resources) HTML that
went over the wire uncompressed, because gzip_types only listed text/plain.
This made the HTML preview slow to load for heavy decks.

Add text/html, text/css, application/javascript, application/json and
image/svg+xml to gzip_types so the text-based portion of the output is
compressed. Already-compressed formats (pdf, png/jpeg/webp, woff/woff2)
are intentionally excluded to avoid wasting CPU. Also set gzip_min_length
1024 so tiny responses aren't compressed needlessly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 18:52:39 +00:00
claude a241e2c201 Pre-install popular Quarto extensions in the Docker image
Build and Deploy Verso / deploy (push) Successful in 11m22s
Dockerfile-base: after Quarto is installed, run 'quarto add --no-prompt'
  for a curated set of extensions into /opt/quarto-extensions/. Quarto
  writes _extensions/<author>/<name>/ in the working dir, giving us a
  clean shared store. Extensions included:
    - igorlima/charged-ieee      — IEEE paper format (Typst)
    - quarto-ext/fontawesome     — Font Awesome icons
    - quarto-ext/attribution     — attribution footer on RevealJS slides
    - quarto-ext/pointer         — laser pointer for presentations
    - quarto-ext/drop            — drop-down overlay for RevealJS
  Adding more: one extra '&& quarto add --no-prompt <author>/<repo>' line.

QuartoRunner: before quarto render, merge /opt/quarto-extensions/_extensions/
  into the compile dir's _extensions/ with 'cp -rn' (no-clobber). This
  makes all pre-installed extensions available to every project without
  any user action. Project-uploaded _extensions/ files take precedence
  since cp -n never overwrites existing files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 16:54:56 +00:00
claude 4460c1d9d6 Fix README copyright: Aloïs Coquillard, 2026
Build and Deploy Verso / deploy (push) Successful in 10m53s
2026-05-31 16:37:59 +00:00
claude 0407e17c68 Rewrite README for Verso
Build and Deploy Verso / deploy (push) Has been cancelled
Replace Overleaf's original README with a Verso-specific one covering:
the project's purpose (collaborative Quarto editor), output formats
(typst/PDF and revealjs/HTML), quick-start Docker instructions, service
architecture overview, a minimal .qmd example, key env vars, and a
clear description of what differs from upstream Overleaf.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 16:30:17 +00:00
claude 24cd4bf13d Fix HTML compile success check: size is undefined for non-PDF outputs
Build and Deploy Verso / deploy (push) Has been cancelled
collectOutputPdfSize() only calls stat() and sets .size on output.pdf.
All other output files (including output.html) keep size: undefined.
The previous check required file.size > 0 for both PDF and HTML, so
undefined > 0 always evaluated false for output.html, making every
RevealJS compile report 'failure' even when the file was produced.

Fix: require size > 0 only for output.pdf; accept output.html
regardless of size (it is always non-empty if Quarto succeeded).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 16:27:02 +00:00
claude 090018c191 Fix QuartoRunner mv: use relative paths to avoid $COMPILE_DIR replacement bug
Build and Deploy Verso / deploy (push) Successful in 11m1s
LocalCommandRunner.replace() uses String.replace() which only substitutes
the FIRST occurrence of '$COMPILE_DIR' in the shell script string. The mv
commands had two more occurrences that stayed as literal '$COMPILE_DIR',
which the shell expanded to '', making 'mv /main.pdf /output.pdf' fail
silently. The file was produced (Quarto logged 'Output created: main.pdf')
but never renamed to output.pdf, so the pipeline reported failure.

Fix: mv uses relative filenames since the shell CWD is already the compile
directory (set by LocalCommandRunner via the spawnCwd option).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 15:51:01 +00:00
claude 48fd24a6b2 Add HTML/RevealJS preview alongside existing PDF preview
Build and Deploy Verso / deploy (push) Successful in 11m0s
clsi-nginx.conf: the types{} block was overriding all nginx defaults,
  leaving HTML/CSS/JS/fonts as application/octet-stream. Add the full
  set of web MIME types so RevealJS assets are served correctly. Also
  needed for X-Content-Type-Options: nosniff to pass.

CompileController.js: success was hardcoded to require output.pdf.
  Also accept output.html so a RevealJS compile is reported as
  'success' rather than 'failure'.

QuartoRunner.js: remove hardcoded --to typst --output output.pdf.
  Instead run `quarto render` without --to/--output so the YAML
  frontmatter decides the format (typst → PDF, revealjs → HTML, etc.).
  Pass --embed-resources so HTML output is self-contained (flag is
  silently ignored by the typst backend). After render, rename
  main.pdf → output.pdf or main.html → output.html so the pipeline
  finds the standard canonical filename.

output-files.ts: handleOutputFiles now falls back to output.html when
  output.pdf is absent. Download URL uses outputFile.path instead of
  the hardcoded 'output.pdf' string.

pdf-viewer.tsx: when pdfUrl contains output.html, bypass PDF.js
  entirely and render a sandboxed iframe (allow-scripts for RevealJS
  interactivity, allow-presentation for fullscreen).

Usage: set `format: revealjs` in the .qmd YAML frontmatter to get
  an HTML presentation preview; set `format: typst` for PDF.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 15:32:00 +00:00
claude 141cf95f9e Apply Verso brand identity: Quarto palette, logo, UI text
Build and Deploy Verso / deploy (push) Successful in 10m58s
Color palette: introduce Quarto's five brand colours ($verso-blue
  #447099, $verso-blue-dark #1B3B6F, $verso-blue-light #75AADB,
  $verso-green #72994E, $verso-orange #EE6331) as CSS custom
  properties alongside the existing layout vars.

Logo: replace all Overleaf SVG assets (icon, wordmarks, favicons,
  horizontal logos) with the Verso mark — a circle split into four
  Quarto-coloured quadrants (Quarto DNA) with a bold white V
  letterform (Verso identity). Filenames kept so imports stay intact.
  Status favicons keep their layout; brand green #046530#447099.

UI text:
  - appName / nav.title default → 'Verso'
  - Footer copyright → '© Verso'; remove Overleaf social links;
    thin-footer attribution → 'Built on Overleaf' (with OSS link)
  - mask-icon colour → #447099
  - interstitial logo alt → 'Verso'
  - Key locale strings (welcome, agree terms, go-to) → Verso;
    SaaS-specific strings (subscriptions, AI Assist) left as-is
    since CE users never see them

Env var names (OVERLEAF_*) intentionally untouched to avoid breaking
  the build. Code comments citing Overleaf origin preserved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 15:06:36 +00:00
claude 1e5ce6c068 Add document outline support for Markdown/Quarto files
Build and Deploy Verso / deploy (push) Successful in 10m47s
outline.ts: export NestingLevel so it can be used outside the file.

markdown/document-outline.ts: new enterMarkdownNode function that walks
  the Lezer Markdown syntax tree and extracts ATXHeading1-6 and
  SetextHeading1-2 nodes, mapping them to the same NestingLevel enum
  used by the LaTeX outline (Section→SubSection→SubSubSection…).
  Wrapped in makeProjectionStateField for incremental updates.

markdown/index.ts: register markdownDocumentOutline as a CodeMirror
  extension in the Markdown LanguageSupport so the StateField is active
  whenever a .qmd file is open.

codemirror-outline.tsx: fall back to markdownDocumentOutline when the
  LaTeX documentOutline StateField is not present in the editor state
  (i.e. when the active language is Markdown, not LaTeX).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 14:35:01 +00:00
claude ce0572e01e Revert QuartoRunner: restore --output output.pdf
Build and Deploy Verso / deploy (push) Successful in 11m9s
The previous compile logs confirm Quarto handles --to typst --output
output.pdf correctly: pandoc produces main.typ, typst compiles it to
main.pdf, then Quarto renames to output.pdf. The mv-based approach was
unnecessary and incorrect.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 14:11:03 +00:00
claude 824b873c69 Fix QuartoRunner: drop --output flag to let Quarto run full typst→PDF pipeline
Build and Deploy Verso / deploy (push) Failing after 12m18s
--to typst combined with --output output.pdf caused Quarto to write a
Typst source file (.typ content) named output.pdf instead of invoking
the typst compiler, producing a text file that the PDF viewer could not
render (hence 'markdown not rendered' — it was literally showing the raw
.typ markup). Fix: let Quarto name the PDF after the input file
(main.qmd → main.pdf) and rename to output.pdf with mv afterwards.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 14:08:08 +00:00
claude b2b2ed13aa Fix Quarto cache permission: create /var/www/.cache/quarto for www-data
Build and Deploy Verso / deploy (push) Successful in 10m56s
Quarto resolves its cache dir as $HOME/.cache/quarto. The process runs
as www-data (home=/var/www) but that directory is root-owned, so Quarto
crashed immediately with PermissionDenied on mkdir. Pre-create the cache
dir and chown it to www-data at image build time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 13:39:02 +00:00
claude 09f5329a07 Fix compile error propagation: 'failure' instead of HTTP 500
Build and Deploy Verso / deploy (push) Successful in 10m37s
LocalCommandRunner: attach captured stdout to the error object when
  exit code is 1, so callers can read Quarto's output even on failure.

QuartoRunner: stop propagating plain 'exited' errors from Quarto up
  to CompileManager. A Quarto exit-code-1 is a compile failure, not a
  server error — CLSI already detects failure by the absence of
  output.pdf and returns status='failure' (HTTP 200). Previously it
  fell through to the generic error handler (HTTP 500), which caused
  the frontend to show "Server Error" instead of the log panel.
  Only true process-level errors (terminated, timedout) are propagated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 13:22:58 +00:00
claude 0323fd4813 Fix Quarto compile pipeline: install, logs, template, draft mode
Build and Deploy Verso / deploy (push) Successful in 10m58s
Dockerfile-base: remove TeX Live (no longer needed), install Quarto
  1.6.39 which bundles Typst for PDF output. This was the root cause
  of all compile failures — the server-ce monolith never had Quarto.

QuartoRunner: run quarto via /bin/sh so stderr is merged into stdout
  with 2>&1; write combined output to output.log (not output.stdout)
  so the PDF-preview log panel picks it up and shows raw output.
  Also write the log on error so failures are always visible.

CompileManager: guard DraftModeManager behind an isLatexFile check —
  injecting LaTeX preamble commands into a .qmd file corrupts it and
  causes a guaranteed compile failure when draft mode is requested.

ProjectCreationHandler + mainbasic.qmd: new projects now create
  main.qmd with a minimal Quarto/Typst frontmatter instead of the
  LaTeX main.tex; _createRootDoc names the file main.qmd accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 12:59:43 +00:00
claude af54b5fd49 Fix Quarto compiler integration: UI, root doc detection, type safety
Build and Deploy Verso / deploy (push) Successful in 11m58s
- compiler-setting.tsx: replace hardcoded LaTeX compiler list with a
  single Quarto option; drop now-unused getMeta/lodash imports
- project-settings.ts: add 'quarto' to ProjectCompiler union type
- ClsiManager: detect main.qmd as a default root document (preferred
  over main.tex); replace hasMainFile boolean with detectedMainFile
  so we know which filename to use
- settings.defaults.js: add 'qmd' to validRootDocExtensions so .qmd
  files appear as selectable root documents in the UI
- ProjectRootDocManager: sort main.qmd before main.tex in the root
  doc candidate list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 12:29:12 +00:00
claude 5b5a54f7b1 Merge branch 'ai/quarto-investigation': replace LaTeX with Quarto
Build and Deploy Verso / deploy (push) Successful in 12m28s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 12:08:11 +00:00
claude a7c2403c4a Replace LaTeX compiler with Quarto (typst PDF output)
- Add QuartoRunner.js: runs `quarto render --to typst --output output.pdf`,
  using Typst (bundled with Quarto >= 1.4) so no separate LaTeX install needed
- Swap LatexRunner for QuartoRunner in CompileManager; remove latexmk-specific
  stats, fdb metrics, and performance sampling that no longer apply
- Add 'quarto' to VALID_COMPILERS in RequestParser and set it as the default;
  change default rootResourcePath from main.tex to main.qmd
- Add 'quarto' to safeCompilers and set it as the default in web settings
- Replace with-texlive Dockerfile stage with with-quarto (Quarto deb install);
  add Quarto to the default final stage as well

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 12:08:07 +00:00
alois d52821e7cc Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Successful in 9m49s
2026-05-30 15:00:42 +00:00
alois d3a9259b42 Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Failing after 9m59s
2026-05-30 14:23:03 +00:00
alois a2db1f04be Actualiser server-ce/Dockerfile
Build and Deploy Verso / deploy (push) Has been cancelled
2026-05-30 12:08:40 +00:00
alois 070d0c1352 Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Has been cancelled
2026-05-30 12:01:00 +00:00
alois 016da98027 Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Failing after 17m13s
2026-05-30 10:54:21 +00:00
alois 1aae2fb3fc switch to minimal dockerfile
Build and Deploy Verso / deploy (push) Has been cancelled
2026-05-30 08:59:24 +00:00
alois 12290c5d93 Ajouter server-ce/Dockerfile-base-minimal
Build and Deploy Verso / deploy (push) Has been cancelled
2026-05-30 08:54:39 +00:00
alois 85ecaf1ff6 Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Successful in 9m57s
2026-05-29 21:57:51 +00:00
alois 3b8879b9ca Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Successful in 9m39s
2026-05-29 20:58:02 +00:00
alois f341d6e64d Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Successful in 9m39s
2026-05-29 20:33:30 +00:00
alois ecbf7d4bdc Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Successful in 9m38s
2026-05-29 19:39:37 +00:00
alois ba5d159f28 Fix dockerfile ARG
Build and Deploy Verso / deploy (push) Has been cancelled
2026-05-29 20:40:57 +02:00
alois a851f53005 Merge branch 'main' of https://git.alocoq.fr/alois/verso
Build and Deploy Verso / deploy (push) Has been cancelled
2026-05-29 20:26:46 +02:00
alois e4db4fe458 Fix corepack yarn install for build 2026-05-29 20:22:40 +02:00
alois 4424286dfd Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Has been cancelled
2026-05-29 18:01:08 +00:00
alois 0771eeab43 Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Failing after 1s
2026-05-29 17:58:05 +00:00
alois 3fe806fc0e Actualiser .gitea/workflows/deploy-verso.yml
Build and Deploy Verso / deploy (push) Has been cancelled
2026-05-29 17:46:19 +00:00
alois cc0db0813f Ajouter .gitea/workflow/deploy-verso.yml 2026-05-29 17:43:06 +00:00
419 changed files with 13803 additions and 18094 deletions
+383
View File
@@ -0,0 +1,383 @@
name: Build and Deploy Verso (prod)
# Production deploy. Triggered only by pushes to the `prod` branch — keep `main`
# for day-to-day work and fast-forward `prod` when a build is stable.
#
# Differences from the test deploy (deploy-verso.yml):
# - Runs in the `verso` namespace (test runs in `test`).
# - Mongo / Redis / app data live on PersistentVolumeClaims and are applied
# idempotently: this workflow NEVER deletes them, so data survives deploys.
# - The replica set is initialised only once.
# - Builds/pushes a distinct image tag (verso:stable) so prod and test never
# clobber each other's image.
# - SMTP comes from the `verso-smtp` Secret (create it with kubectl); email is
# optional so the app still boots before the secret exists.
# - Public self-registration stays off (CE default): friends-only, admin
# creates accounts / sends invites.
#
# Out of band (do once): create the PVCs (server-ce/k8s/verso-prod-pvcs.yaml,
# with your storageClass), the `verso-smtp` Secret, and a verso.alocoq.fr
# Ingress (see server-ce/k8s/verso-prod-ingress.example.yaml) + DNS.
on:
push:
branches:
- prod
workflow_dispatch:
env:
SITE_URL: https://verso.alocoq.fr
jobs:
deploy:
runs-on: native
timeout-minutes: 240
steps:
- name: Build and push Verso prod image with BuildKit
run: |
kubectl -n ci delete job verso-buildkit-prod --ignore-not-found=true --wait=true
cat <<'EOF' | kubectl apply -f -
apiVersion: batch/v1
kind: Job
metadata:
name: verso-buildkit-prod
namespace: ci
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
initContainers:
- name: prepare
image: alpine/git:latest
command: ["sh", "-c"]
args:
- |
set -eux
REG=registry.git.svc.cluster.local:5000
git clone --depth 1 --branch prod https://git.alocoq.fr/alois/verso.git /workspace/repo
# Build the base image only when Dockerfile-base changes
# (content-hash tag); otherwise reuse the cached base.
BTAG=$(sha256sum /workspace/repo/server-ce/Dockerfile-base | cut -c1-16)
printf '%s' "$BTAG" > /workspace/base_tag
if wget -qO- "http://$REG/v2/verso-base/tags/list" 2>/dev/null | grep -q "\"base-$BTAG\""; then
echo "Base image base-$BTAG already present - skipping base build"
else
touch /workspace/build-base
echo "Base image base-$BTAG not found - base will be built"
fi
volumeMounts:
- name: workspace
mountPath: /workspace
containers:
- name: buildkit
image: moby/buildkit:latest
securityContext:
privileged: true
command: ["sh", "-c"]
args:
- |
set -eux
REG=registry.git.svc.cluster.local:5000
mkdir -p /etc/buildkit
printf '[registry."%s"]\n http = true\n insecure = true\n' "$REG" > /etc/buildkit/buildkitd.toml
BTAG=$(cat /workspace/base_tag)
BASE_REF="$REG/verso-base:base-$BTAG"
if [ -f /workspace/build-base ]; then
buildctl-daemonless.sh build \
--frontend=dockerfile.v0 \
--local context=/workspace/repo \
--local dockerfile=/workspace/repo/server-ce \
--opt filename=Dockerfile-base \
--import-cache type=registry,ref=$REG/verso-cache:base \
--export-cache type=registry,ref=$REG/verso-cache:base,mode=max \
--output type=image,name=$BASE_REF,push=true,registry.insecure=true
else
echo "Reusing existing base image $BASE_REF"
fi
# App image → verso:stable (prod tag).
buildctl-daemonless.sh build \
--frontend=dockerfile.v0 \
--local context=/workspace/repo \
--local dockerfile=/workspace/repo/server-ce \
--opt filename=Dockerfile \
--opt build-arg:OVERLEAF_BASE_TAG=$BASE_REF \
--import-cache type=registry,ref=$REG/verso-cache:app \
--export-cache type=registry,ref=$REG/verso-cache:app,mode=max \
--output type=image,name=$REG/verso:stable,push=true,registry.insecure=true
volumeMounts:
- name: workspace
mountPath: /workspace
volumes:
- name: workspace
emptyDir: {}
EOF
- name: Wait for build
run: |
kubectl -n ci wait --for=condition=complete job/verso-buildkit-prod --timeout=14400s
- name: Show build logs
if: always()
run: |
kubectl -n ci logs job/verso-buildkit-prod -c prepare || true
kubectl -n ci logs job/verso-buildkit-prod -c buildkit || true
- name: Ensure data services (Mongo + Redis, never deleted)
run: |
# Mongo/Redis. Applied idempotently — this step must never delete
# these, so project data survives every deploy. The namespace and the
# PVCs (server-ce/k8s/verso-prod-pvcs.yaml) are provisioned out of
# band, so the runner only needs namespaced rights in `verso` (like
# `test`). This step assumes the namespace and the
# mongo-data / redis-data / verso-data PVCs already exist.
cat <<'EOF' | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo
namespace: verso
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:8
command: ["mongod", "--replSet", "rs0", "--bind_ip_all"]
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-data
mountPath: /data/db
volumes:
- name: mongo-data
persistentVolumeClaim:
claimName: mongo-data
---
apiVersion: v1
kind: Service
metadata:
name: mongo
namespace: verso
spec:
selector:
app: mongo
ports:
- name: mongo
port: 27017
targetPort: 27017
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
namespace: verso
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:7
# AOF persistence so a restart doesn't drop in-flight edits
# before they're flushed to Mongo.
command: ["redis-server", "--appendonly", "yes"]
ports:
- containerPort: 6379
volumeMounts:
- name: redis-data
mountPath: /data
volumes:
- name: redis-data
persistentVolumeClaim:
claimName: redis-data
---
apiVersion: v1
kind: Service
metadata:
name: redis
namespace: verso
spec:
selector:
app: redis
ports:
- name: redis
port: 6379
targetPort: 6379
EOF
kubectl -n verso rollout status deployment/mongo --timeout=300s
kubectl -n verso rollout status deployment/redis --timeout=300s
- name: Initialise Mongo replica set (only if not already initialised)
run: |
kubectl -n verso exec deploy/mongo -- mongosh --quiet --eval '
try {
rs.status()
print("replica set already initialised")
} catch (e) {
if (e.codeName === "NotYetInitialized" || /no replset config/i.test(e.message)) {
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "mongo:27017" }] })
print("replica set initiated")
} else {
throw e
}
}
'
kubectl -n verso exec deploy/mongo -- mongosh --quiet --eval '
while (rs.status().myState !== 1) { sleep(1000) }
print("Mongo replica set is PRIMARY")
'
- name: Ensure Verso deployment + service
run: |
# Stamp the instance name with this build number, e.g. "Verso V0.12 Alpha".
NAV_TITLE="Verso V0.${GITHUB_RUN_NUMBER:-${GITEA_RUN_NUMBER:-0}} Alpha"
cat <<'EOF' | sed "s|__NAV_TITLE__|${NAV_TITLE}|g" | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: verso
namespace: verso
spec:
replicas: 1
# RWO data volume → can't run two pods at once; recreate on update.
strategy:
type: Recreate
selector:
matchLabels:
app: verso
template:
metadata:
labels:
app: verso
spec:
securityContext:
# App runs as www-data (uid/gid 33); make the data volume
# group-writable by it.
fsGroup: 33
initContainers:
- name: init-data-perms
image: busybox:latest
command: ["sh", "-c"]
args:
- |
set -eux
mkdir -p /data/template_files /data/user_files \
/data/compiles /data/cache /data/output /data/published
chown -R 33:33 /data
volumeMounts:
- name: verso-data
mountPath: /data
containers:
- name: verso
image: registry.alocoq.fr/verso:stable
# :stable is a fixed tag, so force a pull on every rollout to
# pick up the freshly built image.
imagePullPolicy: Always
ports:
- containerPort: 80
env:
- name: OVERLEAF_MONGO_URL
value: mongodb://mongo:27017/sharelatex?replicaSet=rs0
- name: OVERLEAF_REDIS_HOST
value: redis
- name: REDIS_HOST
value: redis
- name: OVERLEAF_APP_NAME
value: Verso
- name: OVERLEAF_NAV_TITLE
value: "__NAV_TITLE__"
- name: OVERLEAF_SITE_URL
value: https://verso.alocoq.fr
- name: OVERLEAF_SITE_LANGUAGE
value: fr
# Allow anonymous visitors so public published-presentation
# links and read-only share links work without login.
- name: OVERLEAF_ALLOW_PUBLIC_ACCESS
value: "true"
# NB: anonymous read-AND-write sharing is intentionally NOT
# enabled (compiles are unsandboxed → only trusted accounts
# may trigger them). Public self-registration is also off
# (CE default): admin creates accounts / sends invites.
- name: OVERLEAF_ENABLE_PROJECT_PYTHON_VENV
value: "true"
# (SMTP email vars are loaded below via envFrom.)
# SMTP for password-reset / invite emails. All
# OVERLEAF_EMAIL_* vars come from the optional 'verso-smtp'
# Secret (its keys must be named exactly like those env
# vars). Optional, so the app boots before the secret exists.
envFrom:
- secretRef:
name: verso-smtp
optional: true
volumeMounts:
- name: verso-data
mountPath: /var/lib/overleaf/data
volumes:
- name: verso-data
persistentVolumeClaim:
claimName: verso-data
---
apiVersion: v1
kind: Service
metadata:
name: verso
namespace: verso
spec:
selector:
app: verso
ports:
- name: http
port: 80
targetPort: 80
EOF
- name: Deploy Verso image
run: |
kubectl -n verso set image deployment/verso \
verso=registry.alocoq.fr/verso:stable
kubectl -n verso rollout restart deployment/verso
kubectl -n verso rollout status deployment/verso --timeout=600s
- name: Create initial admin (only if no users exist)
run: |
COUNT=$(kubectl -n verso exec deploy/mongo -- mongosh sharelatex --quiet --eval 'db.users.countDocuments()' | tr -d '[:space:]')
if [ "$COUNT" = "0" ]; then
echo "No users yet — creating the initial admin account"
kubectl -n verso exec deploy/verso -- bash -lc '
cd /overleaf/services/web
node modules/server-ce-scripts/scripts/create-user \
--admin \
--email=alois.coquillard@gmail.com
'
else
echo "Users already exist ($COUNT) — skipping admin creation"
fi
+339
View File
@@ -0,0 +1,339 @@
name: Build and Deploy Verso
on:
push:
branches:
- main
workflow_dispatch:
env:
SITE_URL: https://test.alocoq.fr
jobs:
deploy:
runs-on: native
timeout-minutes: 240
steps:
- name: Build and push Verso images with BuildKit
run: |
kubectl -n ci delete job verso-buildkit --ignore-not-found=true --wait=true
cat <<'EOF' | kubectl apply -f -
apiVersion: batch/v1
kind: Job
metadata:
name: verso-buildkit
namespace: ci
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
initContainers:
- name: prepare
image: alpine/git:latest
command: ["sh", "-c"]
args:
- |
set -eux
REG=registry.git.svc.cluster.local:5000
git clone --depth 1 https://git.alocoq.fr/alois/verso.git /workspace/repo
# (#1) Build the base image only when it actually changes.
# The base layers' only repo input is Dockerfile-base, so
# we key on a content hash of that file: the base is tagged
# verso-base:base-<hash> and the app builds FROM that exact
# tag. If a base with this hash is already in the registry,
# the heavy base build (apt, TeX Live, Quarto) is skipped.
BTAG=$(sha256sum /workspace/repo/server-ce/Dockerfile-base | cut -c1-16)
printf '%s' "$BTAG" > /workspace/base_tag
if wget -qO- "http://$REG/v2/verso-base/tags/list" 2>/dev/null | grep -q "\"base-$BTAG\""; then
echo "Base image base-$BTAG already present - skipping base build"
else
touch /workspace/build-base
echo "Base image base-$BTAG not found - base will be built"
fi
volumeMounts:
- name: workspace
mountPath: /workspace
containers:
- name: buildkit
image: moby/buildkit:latest
securityContext:
privileged: true
command: ["sh", "-c"]
args:
- |
set -eux
# Push to the in-cluster registry (plain HTTP) to bypass
# the Traefik ingress, whose read timeout was killing the
# multi-GB TeX Live layer upload mid-stream. Mark the
# registry http+insecure so both push and the base pull
# for the app build treat it as plain HTTP. Written inside
# the container so no extra k8s resources are needed.
REG=registry.git.svc.cluster.local:5000
mkdir -p /etc/buildkit
printf '[registry."%s"]\n http = true\n insecure = true\n' "$REG" > /etc/buildkit/buildkitd.toml
BTAG=$(cat /workspace/base_tag)
BASE_REF="$REG/verso-base:base-$BTAG"
# (#1) Base build, only when prepare flagged it changed.
# (#2) Import/export a registry layer cache so that, when
# the base does change, unchanged layers (e.g. apt) are
# still reused instead of rebuilt from scratch.
if [ -f /workspace/build-base ]; then
buildctl-daemonless.sh build \
--frontend=dockerfile.v0 \
--local context=/workspace/repo \
--local dockerfile=/workspace/repo/server-ce \
--opt filename=Dockerfile-base \
--import-cache type=registry,ref=$REG/verso-cache:base \
--export-cache type=registry,ref=$REG/verso-cache:base,mode=max \
--output type=image,name=$BASE_REF,push=true,registry.insecure=true
else
echo "Reusing existing base image $BASE_REF"
fi
# App image, built FROM the content-pinned base tag.
# (#2) The registry cache lets yarn install be skipped when
# package.json is unchanged; the web build only re-runs
# when the frontend source actually changes.
buildctl-daemonless.sh build \
--frontend=dockerfile.v0 \
--local context=/workspace/repo \
--local dockerfile=/workspace/repo/server-ce \
--opt filename=Dockerfile \
--opt build-arg:OVERLEAF_BASE_TAG=$BASE_REF \
--import-cache type=registry,ref=$REG/verso-cache:app \
--export-cache type=registry,ref=$REG/verso-cache:app,mode=max \
--output type=image,name=$REG/verso:latest,push=true,registry.insecure=true
volumeMounts:
- name: workspace
mountPath: /workspace
volumes:
- name: workspace
emptyDir: {}
EOF
- name: Wait for build
run: |
kubectl -n ci wait --for=condition=complete job/verso-buildkit --timeout=14400s
- name: Show build logs
if: always()
run: |
kubectl -n ci logs job/verso-buildkit -c prepare || true
kubectl -n ci logs job/verso-buildkit -c buildkit || true
- name: Recreate test dependencies
run: |
kubectl -n test delete deployment mongo redis --ignore-not-found=true --wait=true
kubectl -n test delete service mongo redis --ignore-not-found=true --wait=true
cat <<'EOF' | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo
namespace: test
spec:
replicas: 1
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:8
command: ["mongod", "--replSet", "rs0", "--bind_ip_all"]
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-data
mountPath: /data/db
volumes:
- name: mongo-data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: mongo
namespace: test
spec:
selector:
app: mongo
ports:
- name: mongo
port: 27017
targetPort: 27017
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
namespace: test
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:7
ports:
- containerPort: 6379
volumeMounts:
- name: redis-data
mountPath: /data
volumes:
- name: redis-data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: redis
namespace: test
spec:
selector:
app: redis
ports:
- name: redis
port: 6379
targetPort: 6379
EOF
kubectl -n test rollout status deployment/mongo --timeout=180s
kubectl -n test rollout status deployment/redis --timeout=180s
sleep 5
kubectl -n test exec deploy/mongo -- mongosh --eval '
rs.initiate({
_id: "rs0",
members: [{ _id: 0, host: "mongo:27017" }]
})
'
kubectl -n test exec deploy/mongo -- mongosh --eval '
while (rs.status().myState !== 1) {
sleep(1000)
}
print("Mongo replica set is PRIMARY")
'
- name: Ensure Verso deployment exists
run: |
# Stamp the instance name with this build number, e.g. "Verso V0.83 Alpha".
NAV_TITLE="Verso V0.${GITHUB_RUN_NUMBER:-${GITEA_RUN_NUMBER:-0}} Alpha"
cat <<'EOF' | sed "s|__NAV_TITLE__|${NAV_TITLE}|g" | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: verso
namespace: test
spec:
replicas: 1
selector:
matchLabels:
app: verso
template:
metadata:
labels:
app: verso
spec:
containers:
- name: verso
# Pull via the public address: the cluster nodes' containerd
# is configured for registry.alocoq.fr, not the in-cluster
# service name. Both front the same registry storage, so the
# image pushed via the in-cluster address resolves here too.
image: registry.alocoq.fr/verso:latest
ports:
- containerPort: 80
env:
- name: OVERLEAF_MONGO_URL
value: mongodb://mongo:27017/sharelatex?replicaSet=rs0
- name: OVERLEAF_REDIS_HOST
value: redis
- name: REDIS_HOST
value: redis
- name: OVERLEAF_APP_NAME
value: Verso
- name: OVERLEAF_NAV_TITLE
value: "__NAV_TITLE__"
- name: OVERLEAF_SITE_URL
value: https://test.alocoq.fr
# Default UI language for the instance.
- name: OVERLEAF_SITE_LANGUAGE
value: fr
# Allow anonymous visitors to reach the site so link
# sharing and public presentation links work without a
# login. Per-project and per-route access checks still
# apply; private presentation links still require login.
- name: OVERLEAF_ALLOW_PUBLIC_ACCESS
value: "true"
# Also let anonymous visitors use read-AND-write share
# links (edit without an account). Read-only links only
# need OVERLEAF_ALLOW_PUBLIC_ACCESS above.
- name: OVERLEAF_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING
value: "true"
# Let Quarto Python cells use a project's requirements.txt:
# the compiler installs it into a cached venv. Gated to the
# project owner + invited collaborators (never anonymous /
# link-sharing users).
- name: OVERLEAF_ENABLE_PROJECT_PYTHON_VENV
value: "true"
---
apiVersion: v1
kind: Service
metadata:
name: verso
namespace: test
spec:
selector:
app: verso
ports:
- name: http
port: 80
targetPort: 80
EOF
- name: Deploy Verso image
run: |
kubectl -n test set image deployment/verso \
verso=registry.alocoq.fr/verso:latest
kubectl -n test rollout restart deployment/verso
kubectl -n test rollout status deployment/verso --timeout=300s
- name: Create admin user
run: |
sleep 20
kubectl -n test exec deploy/verso -- bash -lc '
cd /overleaf/services/web
node modules/server-ce-scripts/scripts/create-user \
--admin \
--email=test@example.com || true
'
- name: Cleanup
if: always()
run: |
kubectl -n ci delete job verso-buildkit --ignore-not-found=true --wait=true
@@ -1,5 +1,5 @@
diff --git a/lib/sandboxed_module.js b/lib/sandboxed_module.js
index 1cd6743fe221cbe91ea92fea3707ed07a8a2ded3..46889217d96d5534a206549ae7bd97100e41c3e4 100644
index 1cd6743..4718b97 100644
--- a/lib/sandboxed_module.js
+++ b/lib/sandboxed_module.js
@@ -4,7 +4,7 @@ var Module = require('module');
@@ -11,3 +11,47 @@ index 1cd6743fe221cbe91ea92fea3707ed07a8a2ded3..46889217d96d5534a206549ae7bd9710
var parent = module.parent;
var globalOptions = {};
var registeredBuiltInSourceTransformers = ['coffee'];
@@ -157,12 +157,20 @@ SandboxedModule.prototype._createRecursiveRequireProxy = function() {
var cache = Object.create(null);
var required = this._getRequires();
for (var key in required) {
- var injectedFilename = requireLike(this.filename).resolve(key);
- cache[injectedFilename] = required[key];
+ // Under Yarn PnP, resolution from a transitive dependency's context may fail
+ // for packages not declared in that dependency's package.json. Silently skip
+ // cache pre-population on failure; the mock will still be injected via the
+ // inject map in requireInterceptor or resolved via RecursiveRequireProxy fallback.
+ try {
+ var injectedFilename = requireLike(this.filename).resolve(key);
+ cache[injectedFilename] = required[key];
+ } catch (e) {}
}
cache[this.filename] = this.exports;
var globals = this.globals;
+ // Store the top-level module's filename for PnP fallback resolution
+ var topLevelFilename = this.filename;
var options;
if(!this._options.sourceTransformersSingleOnly && this._options.sourceTransformers){
options = {
@@ -208,8 +216,18 @@ SandboxedModule.prototype._createRecursiveRequireProxy = function() {
if (request in cache) return cache[request];
return require(request);
}
- // cached modules
- var requestedFilename = requireLike(this.filename).resolve(request);
+ // Resolve the requested module filename.
+ // Under Yarn PnP, packages can only resolve their declared dependencies.
+ // When sandboxed-module loads a transitive dependency, the resolution context
+ // may not have access to all needed packages. Fall back to resolving from
+ // the top-level module's context (the module under test).
+ var requestedFilename;
+ try {
+ requestedFilename = requireLike(this.filename).resolve(request);
+ } catch (e) {
+ if (this.filename === topLevelFilename) throw e;
+ requestedFilename = requireLike(topLevelFilename).resolve(request);
+ }
if (requestedFilename in cache) return cache[requestedFilename];
var sandboxedModule = createInnerSandboxedModule(requestedFilename)
return sandboxedModule.exports;
+205 -52
View File
@@ -1,80 +1,233 @@
<h1 align="center">
<br>
<a href="https://www.overleaf.com"><img src="doc/logo.png" alt="Overleaf" width="300"></a>
</h1>
<h4 align="center">An open-source online real-time collaborative LaTeX editor.</h4>
<p align="center">
<a href="https://github.com/overleaf/overleaf/wiki">Wiki</a> •
<a href="https://www.overleaf.com/for/enterprises">Server Pro</a> •
<a href="#contributing">Contributing</a> •
<a href="https://mailchi.mp/overleaf.com/community-edition-and-server-pro">Mailing List</a> •
<a href="#authors">Authors</a> •
<a href="#license">License</a>
<img src="services/web/public/img/ol-brand/verso-logo.svg" alt="Verso" width="440">
</p>
<img src="doc/screenshot.png" alt="A screenshot of a project being edited in Overleaf Community Edition">
<p align="center">
Figure 1: A screenshot of a project being edited in Overleaf Community Edition.
</p>
**A collaborative, real-time editor for Quarto, LaTeX and Typst — documents and presentations.**
## Community Edition
Verso is a fork of [Overleaf](https://github.com/overleaf/overleaf) that adds
first-class [Quarto](https://quarto.org) and [Typst](https://typst.app) support
alongside Overleaf's LaTeX toolchain. It keeps Overleaf's real-time
collaboration infrastructure and runs **three compilers side by side**, chosen
automatically from the root file's extension:
[Overleaf](https://www.overleaf.com) is an open-source online real-time collaborative LaTeX editor. We run a hosted version at [www.overleaf.com](https://www.overleaf.com), but you can also run your own local version, and contribute to the development of Overleaf.
| Root file | Compiler | Typical output |
|-----------|----------|----------------|
| `.qmd` | Quarto | PDF (via Typst or LaTeX), or an HTML/RevealJS deck |
| `.tex` | `latexmk` / TeX Live | PDF |
| `.typ` | Typst | PDF |
> [!CAUTION]
> Overleaf Community Edition is intended for use in environments where **all** users are trusted. Community Edition is **not** appropriate for scenarios where isolation of users is required due to Sandbox Compiles not being available. When not using Sandboxed Compiles, users have full read and write access to the `sharelatex` container resources (filesystem, network, environment variables) when running LaTeX compiles.
All three coexist on one server; no per-project configuration is required to
pick the engine.
For more information on Sandbox Compiles check out our [documentation](https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/sandboxed-compiles).
---
## Enterprise
## Features
If you want help installing and maintaining Overleaf in your lab or workplace, we offer an officially supported version called [Overleaf Server Pro](https://www.overleaf.com/for/enterprises). It also includes more features for security (SSO with LDAP or SAML), administration and collaboration (e.g. tracked changes). [Find out more!](https://www.overleaf.com/for/enterprises)
- **Real-time collaboration** — multiple people editing the same file at once,
powered by Overleaf's operational-transformation engine, with live cursors
and full project history.
- **Three compilers, auto-dispatched** — Quarto, LaTeX and Typst projects live
side by side; the runner is selected from the root file's extension.
- **Language-aware editor for all three**:
- *LaTeX* — syntax highlighting, command/environment/reference autocomplete,
linting (inherited from Overleaf).
- *Quarto (`.qmd`)* — Markdown highlighting plus Quarto-aware completions:
code chunks (```` ```{python} ````, `{r}`, `{julia}`, `{ojs}`…), callouts
and fenced divs (`::: {.callout-note}`, columns, tabsets) and
cross-references (`@fig-`, `@tbl-`, `@sec-`, `@eq-`).
- *Typst (`.typ`)* — syntax highlighting and completions for the common
functions and markup (`#import`, `#let`, `#set`, `#show`, `#figure`,
`#table`, `#cite`, …).
- **Document outline** — section headings are extracted into the sidebar
outline panel for LaTeX, Quarto (`#`, `##`, …) and Typst (`=`, `==`, …).
- **Format at a glance** — the project dashboard shows a per-project format
badge (Quarto / Typst / LaTeX), and the compiler dropdown greys out engines
that don't apply to the current root file.
- **Publish & share compiled output** — publish the compiled result as a
standalone page at `/p/:token`, with three independent access tiers (project
members / any logged-in user / public). Works for both HTML/RevealJS decks
(served live) and PDFs (embedded inline). HTML decks also get a one-click
**Present** button in the toolbar.
- **Quarto Python cells** — optional per-project virtual environment built from
the project's `requirements.txt`, so Python code chunks run during render
(gated to the project owner and invited collaborators).
- **Auto-compile** — the preview refreshes automatically shortly after you stop
typing.
## Keeping up to date
## Output formats
Sign up to the [mailing list](https://mailchi.mp/overleaf.com/community-edition-and-server-pro) to get updates on Overleaf releases and development.
In the YAML frontmatter of a `.qmd` file:
## Installation
```yaml
format: typst # → PDF preview, rendered via Typst (no LaTeX required)
format: pdf # → PDF preview, rendered via LaTeX
format: revealjs # → interactive HTML slideshow preview
format: html # → a static HTML page
```
We have detailed installation instructions in the [Overleaf Toolkit](https://github.com/overleaf/toolkit/).
Typst ships inside Quarto, so `format: typst` needs no separate installation.
## Upgrading
> **Note on display math**: keep `$$ … $$` blocks on a single line. Multi-line
> display-math blocks can trigger YAML parse errors in some Quarto versions.
If you are upgrading from a previous version of Overleaf, please see the [Release Notes section on the Wiki](https://github.com/overleaf/overleaf/wiki#release-notes) for all of the versions between your current version and the version you are upgrading to.
## Quick start
## Overleaf Docker Image
### With Docker
This repo contains two dockerfiles, [`Dockerfile-base`](server-ce/Dockerfile-base), which builds the
`sharelatex/sharelatex-base` image, and [`Dockerfile`](server-ce/Dockerfile) which builds the
`sharelatex/sharelatex` (or "community") image.
```bash
docker run -d \
-p 80:80 \
-v ~/verso_data:/var/lib/overleaf \
--name verso \
registry.alocoq.fr/verso:latest
```
The Base image generally contains the basic dependencies like `wget`, plus `texlive`.
We split this out because it's a pretty heavy set of
dependencies, and it's nice to not have to rebuild all of that every time.
Open `http://localhost` in your browser, then visit `/launchpad` on first run to
create the admin account.
The `sharelatex/sharelatex` image extends the base image and adds the actual Overleaf code
and services.
### Build from source
Use `make build-base` and `make build-community` from `server-ce/` to build these images.
```bash
# Build the base image (system deps + Quarto + TeX Live)
cd server-ce
make build-base
We use the [Phusion base-image](https://github.com/phusion/baseimage-docker)
(which is extended by our `base` image) to provide us with a VM-like container
in which to run the Overleaf services. Baseimage uses the `runit` service
manager to manage services, and we add our init-scripts from the `server-ce/runit`
folder.
# Build the application image
make build-community
```
| File | Purpose |
|------|---------|
| `server-ce/Dockerfile-base` | Base OS image — system deps, Quarto (with Typst) and a TeX Live (`latexmk`) toolchain |
| `server-ce/Dockerfile` | Application image — Node services and the compiled frontend |
## Architecture
Verso is a microservices monorepo (Yarn workspaces). All services run inside a
single container managed by `runit`, with `nginx` as the front router.
```
browser ──→ nginx:80
├── / ──────────────────→ web:4000 (main app, React UI)
├── /socket.io ──────────→ real-time:3026 (WebSocket, OT engine)
├── /p/:token ───────────→ web (published output)
└── /project/*/output/* → clsi-nginx:8080 (compiled output files)
web → document-updater → Redis pub/sub → real-time → browser
web → CLSI (quarto render / latexmk / typst) → output files → nginx → browser
```
| Service | Role |
|---------|------|
| `web` | HTTP API, React frontend, auth, project & sharing management |
| `real-time` | WebSocket layer, live cursors and edit sync |
| `document-updater` | Operational transformation, Redis pub/sub |
| `clsi` | Compiler — runs `quarto render` (`.qmd`), `latexmk` (`.tex`) or `typst` (`.typ`) and serves output |
| `docstore` | Document text storage (MongoDB) |
| `filestore` | Binary file storage (S3 or local) |
| `project-history` | Change history and version tracking |
## Writing documents
### Quarto (`main.qmd`)
```markdown
---
title: My Presentation
author: Your Name
date: today
format: revealjs
---
## Slide one
Write **Markdown** here.
## Mathematics
$$\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}$$
```
Switch `format: revealjs` to `format: typst` (or `pdf`) for a PDF preview.
### LaTeX (`main.tex`)
LaTeX works exactly as in Overleaf: a project whose root file is a `.tex` file
compiles with `latexmk`/TeX Live, no setting required. The **Example LaTeX
project** in the *New project* menu is a ready-made starting point.
> The bundled TeX Live is a minimal install. Documents that need extra packages
> may not build out of the box — see `server-ce/Dockerfile-base` for how to
> switch to a fuller TeX Live scheme.
### Typst (`main.typ`)
A project whose root file is a `.typ` file compiles directly to PDF with
[Typst](https://typst.app) — fast, modern markup with a real scripting
language. Verso drives the Typst bundled with Quarto, so no extra install is
needed. Use the **Blank Typst project** entry in the *New project* menu to get
started.
## Publishing compiled output
From **Share → Publish**, Verso compiles the project and snapshots the result to
a standalone page at `/p/:token`:
- **HTML / RevealJS** decks are served as a live page (the **Present** toolbar
button is a one-click shortcut to this).
- **PDF** output is embedded inline; the raw file stays reachable at
`/p/:token/output.pdf`.
Three stable links are issued, one per access tier — project members, any
logged-in user, or anyone — and each can be copied or independently reset.
## Environment variables
Verso inherits all of Overleaf's environment variables (prefixed `OVERLEAF_`).
The most commonly needed:
| Variable | Default | Description |
|----------|---------|-------------|
| `OVERLEAF_APP_NAME` | `Verso` | Name shown in the UI |
| `OVERLEAF_NAV_TITLE` | — | Instance name/version shown in the top bar |
| `OVERLEAF_MONGO_URL` | `mongodb://mongo/sharelatex` | MongoDB connection string |
| `OVERLEAF_REDIS_HOST` | `localhost` | Redis host |
| `OVERLEAF_SITE_URL` | — | Public URL (used in emails and published links) |
| `OVERLEAF_SITE_LANGUAGE` | `en` | Default UI language (e.g. `fr`) |
| `OVERLEAF_ENABLE_PROJECT_PYTHON_VENV` | `false` | Allow Quarto Python cells to use a project `requirements.txt` |
| `OVERLEAF_ADMIN_EMAIL` | — | Email for the first admin account |
See the [Overleaf Server documentation](https://github.com/overleaf/overleaf/wiki)
for the full list.
## Relation to Overleaf
Verso is a fork of [Overleaf Community Edition](https://github.com/overleaf/overleaf).
The main additions on top of upstream are:
- Quarto and Typst compilers running alongside LaTeX, dispatched by the root
file's extension.
- Editor language support (highlighting, autocomplete, outline) for Quarto and
Typst.
- A per-project format badge on the dashboard and a root-file-aware compiler
selector.
- Publishing/sharing of compiled output (HTML decks and PDFs) via `/p/:token`
with tiered access links, and a toolbar **Present** shortcut.
- Optional per-project Python virtual environments for Quarto code execution.
- Verso branding (name, logo, palette, loading animation).
All other infrastructure — real-time collaboration, history, auth, file
storage, project management — is unchanged from Overleaf.
## Contributing
Please see the [CONTRIBUTING](CONTRIBUTING.md) file for information on contributing to the development of Overleaf.
## Authors
[The Overleaf Team](https://www.overleaf.com/about)
Contributions are welcome — open an issue or pull request on the
[Verso repository](https://git.alocoq.fr/alois/verso). The upstream Overleaf
contribution guidelines are in [CONTRIBUTING.md](CONTRIBUTING.md).
## License
The code in this repository is released under the GNU AFFERO GENERAL PUBLIC LICENSE, version 3. A copy can be found in the [`LICENSE`](LICENSE) file.
GNU Affero General Public License v3 — see [LICENSE](LICENSE).
Copyright (c) Overleaf, 2014-2025.
Copyright © Overleaf, 20142026 (original code).
Verso modifications © Aloïs Coquillard, 2026.
+41
View File
@@ -0,0 +1,41 @@
# Verso — Next Alpha Roadmap
Ideas and features deferred from the current alpha.
---
## Next alpha (post-current)
### Typst editing experience (inspired by Collabst)
- **typst.ts WASM preview** — Run the Typst compiler in the browser via
WebAssembly (typst.ts). This would give instant, sub-second preview
without a server round-trip, and would eliminate the entire class of
race conditions in the CLSI watcher (files written → typst compiles →
resolver missed). Could coexist with the CLSI watcher for PDF export
while using the WASM path for live preview.
- **Tinymist LSP integration** — Wire up
[Tinymist](https://github.com/Myriad-Dreamin/tinymist) (the Typst
language server) behind a WebSocket proxy. Would give Typst files
first-class autocomplete, hover docs, go-to-definition, and inline
error diagnostics — the main editing comfort gap vs. a native editor.
### Editor UX for non-LaTeX formats (.typ, .qmd, .md)
- **Visual/rich-text editing mode** — A toggle between raw source and a
rendered-in-place view for `.typ`, `.qmd`, and `.md` files (similar to
Overleaf's rich-text mode for LaTeX). Users who don't know Typst or
Markdown syntax should be able to edit content without seeing markup.
CodeMirror 6 already supports this pattern via a custom `NodeView` layer
or a separate Prosemirror bridge.
- **Toolbar / insertion shortcuts** — A formatting toolbar and keyboard
shortcuts for common operations, adapted per file type:
- **All formats**: bold, italic, underline, headings, bullet/numbered
lists, inline code, links.
- **Quarto / Markdown**: insert image, insert table, insert code block
with language tag.
- **Quarto RevealJS**: insert slide divider (`---`), insert speaker
notes (`::: notes`), insert columns layout, insert video embed
(using Quarto's `{{< video >}}` shortcode).
+100
View File
@@ -0,0 +1,100 @@
# Design: per-project Python dependencies (cached virtualenv)
Status: **Phase 1 implemented** (gated behind `OVERLEAF_ENABLE_PROJECT_PYTHON_VENV`,
on in the deployment). Network egress policy and venv eviction (Phases 23)
remain. Captures the plan for letting Quarto `{python}` cells use libraries
beyond the curated base set.
## What ships in Phase 1
- A project root `requirements.vrf` is installed into a venv cached by its
sha256, created with `python3 -m venv --system-site-packages`; `QuartoRunner`
points Quarto at it via `QUARTO_PYTHON`. A per-hash `flock` serialises
concurrent builds; pip output is merged into `output.log`; on failure the
render falls back to the base interpreter (and the missing-package message
surfaces). Venvs live under `PYTHON_VENVS_DIR`
(default `/var/lib/overleaf/data/python-venvs`).
- Gated by `userCanInstallPython` (`PythonVenvGate.mjs`) to the project owner +
invited collaborators (any role) — never anonymous / link-sharing users —
threaded to CLSI as `allowPythonInstall` on the editor compile, presentation
export, and publish paths.
### Known Phase-1 limitations
- The first build of a heavy `requirements.vrf` runs within the compile
timeout; a very large install can be killed and retried next compile (the
venv is only marked complete on success).
- No egress restriction yet (Phase 2) — installs reach PyPI directly.
- No eviction yet (Phase 3) — venvs accumulate under `PYTHON_VENVS_DIR`.
## Background
Quarto executes `` ```{python} `` cells through a Jupyter kernel. The base image
([`server-ce/Dockerfile-base`](../server-ce/Dockerfile-base)) bundles a curated
scientific stack (numpy, pandas, scipy, matplotlib, seaborn, scikit-learn,
sympy, plotly, tabulate). Anything outside that set currently fails the render
with `ModuleNotFoundError`.
As a first step that already shipped, the Quarto log parser
([`quarto-log-parser.ts`](../services/web/frontend/js/ide/log-parser/quarto-log-parser.ts))
turns a missing-package traceback into an actionable message. This document is
the *next* step: letting a project declare and install its own dependencies.
**Key constraint:** the instance runs with anonymous read+write enabled
(`OVERLEAF_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING=true`), so compiles can be
triggered by untrusted users. Installing arbitrary packages is therefore a
security decision, not just a convenience.
## Mechanism
1. **Declaration.** A standard `requirements.vrf` at the project root opts the
project in (familiar, Quarto-agnostic, supports version pinning).
2. **Keying.** CLSI hashes `sha256(requirements.vrf + python version)`. The hash
names a venv directory on a **persistent volume**, e.g.
`…/data/python-venvs/<hash>/`. Identical dependency sets share one venv across
projects and compiles.
3. **Build-if-missing.** `python3 -m venv --system-site-packages <dir>` (so the
bundled stack stays visible and only the *extra* deps are installed — smaller
and faster), then `<dir>/bin/pip install -r requirements.vrf`. Guard with a
per-hash `flock` so concurrent compiles don't build the same venv twice.
4. **Point Quarto at it.** Set `QUARTO_PYTHON=<dir>/bin/python3` in the render
environment (threaded web → CLSI exactly like `exportMode`). With
`--system-site-packages`, `ipykernel` from the base is importable, so the
kernel runs in that interpreter with base + project packages.
## Guard rails
- **Auth gating.** Only run the install path for **logged-in owner/collaborator**
compiles. Anonymous-link compiles use the plain base interpreter and never
trigger installs. Web decides and passes a boolean to CLSI; default-deny.
- **Network egress.** The compile environment must reach PyPI to install.
Restrict egress to PyPI / an internal mirror only (k8s NetworkPolicy + pip
`--index-url`), not arbitrary hosts.
- **Resource caps.** Install timeout, venv size cap, max package count; surface
overruns as a clear log error.
- **Trust boundary.** Even gated, a trusted user installing packages is
arbitrary code execution in the sandbox. Containment stays the CLSI container
+ resource limits + egress policy. This is owner-trust-level by design.
## Lifecycle
- **Eviction.** `touch` the venv on use; an LRU cleanup job prunes the oldest
venvs when the volume exceeds a size budget.
- **Failure UX.** pip errors flow into the log panel (reusing the friendly-error
pattern) showing pip's output.
## Rollout
- **Phase 1.** Detection + `flock` venv build + `QUARTO_PYTHON`, behind a
settings flag (default **off**), gated to logged-in owner, dev volume.
- **Phase 2.** Egress NetworkPolicy + index pinning + eviction job.
- **Phase 3.** Nicer pip-error surfacing + a small project-settings UI
affordance.
## Open decisions
- `requirements.vrf` vs a frontmatter field vs both?
- Shared global venv volume vs per-user namespacing (sharing is cheaper;
per-user is stricter isolation)?
- Allow native/compiled wheels (broader support) vs wheels-only/no-build
(tighter security)?
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+6
View File
@@ -1,4 +1,10 @@
const pkg = require('./package.json')
module.exports = {
meta: {
name: pkg.name,
version: pkg.version,
},
rules: {
'no-unnecessary-trans': require('./no-unnecessary-trans'),
'prefer-kebab-url': require('./prefer-kebab-url'),
+2 -2
View File
@@ -8,10 +8,10 @@
"lodash": "^4.18.1"
},
"devDependencies": {
"@typescript-eslint/parser": "^8.50.0"
"@typescript-eslint/parser": "^8.59.4"
},
"peerDependencies": {
"eslint": "^8.51.0"
"eslint": "^10.4.0"
},
"scripts": {
"test": "node rules.test.js"
@@ -22,7 +22,7 @@ module.exports = {
},
},
create(context) {
const currentFilePath = context.getFilename()
const currentFilePath = context.filename
// ESLint can sometimes pass <text> or <input> for snippets not in a file
if (currentFilePath === '<text>' || currentFilePath === '<input>') {
return {}
@@ -81,9 +81,10 @@ module.exports = {
typeof firstArg.value !== 'string'
) {
if (firstArg.type === 'Identifier') {
const variable = context
.getScope()
.variables.find(v => v.name === firstArg.name)
const scope = context.sourceCode.getScope(node)
const variable = scope.variables.find(
v => v.name === firstArg.name
)
if (
variable &&
variable.defs.length > 0 &&
+18 -7
View File
@@ -1,4 +1,5 @@
const { RuleTester } = require('eslint')
const tsParser = require('@typescript-eslint/parser')
const noThrowInCallback = require('./no-throw-in-callback')
const preferKebabUrl = require('./prefer-kebab-url')
const noUnnecessaryTrans = require('./no-unnecessary-trans')
@@ -8,10 +9,10 @@ const viDoMockValidPath = require('./require-vi-doMock-valid-path')
const requireCioSnakeCaseProperties = require('./require-cio-snake-case-properties')
const ruleTester = new RuleTester({
parser: require.resolve('@typescript-eslint/parser'),
parserOptions: {
languageOptions: {
parser: tsParser,
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
parserOptions: { ecmaFeatures: { jsx: true } },
},
})
@@ -33,19 +34,27 @@ ruleTester.run('prefer-kebab-url', preferKebabUrl, {
invalid: [
{
code: `app.get('/fooBar')`,
errors: [{ message: 'Route path should be in kebab-case.' }],
errors: [
{ message: 'Route path should be in kebab-case.', suggestions: 1 },
],
},
{
code: `app.get('/fooBar/:id')`,
errors: [{ message: 'Route path should be in kebab-case.' }],
errors: [
{ message: 'Route path should be in kebab-case.', suggestions: 1 },
],
},
{
code: `webRouter.get('/foo_bar/:id/FooBar/:name/fooBar')`,
errors: [{ message: 'Route path should be in kebab-case.' }],
errors: [
{ message: 'Route path should be in kebab-case.', suggestions: 1 },
],
},
{
code: `router.get(/^\\/downLoad\\/pro-ject\\/([^/]*)\\/OutPut\\/out-put\\.pdf$/)`,
errors: [{ message: 'Route path should be in kebab-case.' }],
errors: [
{ message: 'Route path should be in kebab-case.', suggestions: 1 },
],
},
],
})
@@ -153,6 +162,7 @@ ruleTester.run('domock-require-valid-path', viDoMockValidPath, {
{
message:
'The path "./require-vi-doMock-valid-path2" in vi.doMock() cannot be resolved relative to the current file.',
suggestions: [],
},
],
},
@@ -163,6 +173,7 @@ ruleTester.run('domock-require-valid-path', viDoMockValidPath, {
{
message:
'The first argument of vi.doMock() must be (or resolve to) a string literal representing a path.',
suggestions: [],
},
],
},
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+6 -6
View File
@@ -10,12 +10,12 @@
"dependencies": {
"@google-cloud/opentelemetry-cloud-trace-exporter": "^3.0.0",
"@google-cloud/profiler": "^6.0.4",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/auto-instrumentations-node": "^0.72.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.214.0",
"@opentelemetry/resources": "^2.6.0",
"@opentelemetry/sdk-node": "^0.214.0",
"@opentelemetry/semantic-conventions": "^1.39.0",
"@opentelemetry/api": "^1.9.1",
"@opentelemetry/auto-instrumentations-node": "^0.76.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.218.0",
"@opentelemetry/resources": "^2.7.1",
"@opentelemetry/sdk-node": "^0.218.0",
"@opentelemetry/semantic-conventions": "^1.41.1",
"compression": "^1.7.4",
"prom-client": "^14.1.1",
"yn": "^3.1.1"
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
-1
View File
@@ -38,7 +38,6 @@
"mocha": "^11.1.0",
"mocha-junit-reporter": "^2.2.1",
"mocha-multi-reporters": "^1.5.1",
"mock-fs": "^5.2.0",
"mongodb": "6.12.0",
"sandboxed-module": "^2.0.4",
"sinon": "^9.2.4",
@@ -3,9 +3,12 @@ const fs = require('node:fs')
const fsPromises = require('node:fs/promises')
const { glob } = require('glob')
const Path = require('node:path')
const { promisify } = require('node:util')
const { PassThrough } = require('node:stream')
const { pipeline } = require('node:stream/promises')
const openCb = promisify(fs.open)
const AbstractPersistor = require('./AbstractPersistor')
const { ReadError, WriteError, NotImplementedError } = require('./Errors')
const PersistorHelper = require('./PersistorHelper')
@@ -85,8 +88,9 @@ module.exports = class FSPersistor extends AbstractPersistor {
})
const fsPath = this._getFsPath(location, name, opts.useSubdirectories)
let fd
try {
opts.fd = await fsPromises.open(fsPath, 'r')
fd = await openCb(fsPath, 'r')
} catch (err) {
throw PersistorHelper.wrapError(
err,
@@ -96,7 +100,7 @@ module.exports = class FSPersistor extends AbstractPersistor {
)
}
const stream = fs.createReadStream(null, opts)
const stream = fs.createReadStream(null, { ...opts, fd })
// Return a PassThrough stream with a minimal interface. It will buffer until the caller starts reading. It will emit errors from the source stream (Stream.pipeline passes errors along).
const pass = new PassThrough()
pipeline(stream, observer, pass).catch(() => {})
@@ -1,6 +1,6 @@
const crypto = require('node:crypto')
const os = require('node:os')
const { expect } = require('chai')
const mockFs = require('mock-fs')
const fs = require('node:fs')
const fsPromises = require('node:fs/promises')
const Path = require('node:path')
@@ -10,22 +10,59 @@ const Errors = require('../../src/Errors')
const MODULE_PATH = '../../src/FSPersistor.js'
function createTree(base, tree) {
fs.mkdirSync(base, { recursive: true })
for (const [name, content] of Object.entries(tree)) {
const fullPath = Path.join(base, name)
if (Buffer.isBuffer(content) || typeof content === 'string') {
fs.writeFileSync(fullPath, content)
} else if (content && typeof content.symlink === 'string') {
fs.symlinkSync(content.symlink, fullPath)
} else {
createTree(fullPath, content)
}
}
}
describe('FSPersistorTests', function () {
const localFiles = {
'/uploads/info.txt': Buffer.from('This information is critical', {
const fileContents = {
'info.txt': Buffer.from('This information is critical', {
encoding: 'utf-8',
}),
'/uploads/other.txt': Buffer.from('Some other content', {
'other.txt': Buffer.from('Some other content', {
encoding: 'utf-8',
}),
}
const location = '/bucket'
let tmpDir
let location
let notADirPath
const files = {
wombat: 'animals/wombat.tex',
giraffe: 'animals/giraffe.tex',
potato: 'vegetables/potato.tex',
}
beforeEach(function () {
tmpDir = fs.mkdtempSync(Path.join(os.tmpdir(), 'fs-persistor-test-'))
createTree(tmpDir, {
uploads: {
'info.txt': fileContents['info.txt'],
'other.txt': fileContents['other.txt'],
},
'not-a-dir':
'This regular file is meant to prevent using this path as a directory',
directory: {
subdirectory: {},
},
})
notADirPath = Path.join(tmpDir, 'not-a-dir')
location = Path.join(tmpDir, 'bucket')
})
afterEach(function () {
fs.rmSync(tmpDir, { recursive: true })
})
const scenarios = [
{
description: 'default settings',
@@ -54,31 +91,26 @@ describe('FSPersistorTests', function () {
persistor = new FSPersistor(scenario.settings)
})
beforeEach(function () {
mockFs({
...localFiles,
'/not-a-dir':
'This regular file is meant to prevent using this path as a directory',
'/directory/subdirectory': {},
})
})
afterEach(function () {
mockFs.restore()
})
describe('sendFile', function () {
it('should copy the file', async function () {
await persistor.sendFile(location, files.wombat, '/uploads/info.txt')
await persistor.sendFile(
location,
files.wombat,
Path.join(tmpDir, 'uploads', 'info.txt')
)
const contents = await fsPromises.readFile(
scenario.fsPath(files.wombat)
)
expect(contents.equals(localFiles['/uploads/info.txt'])).to.be.true
expect(contents.equals(fileContents['info.txt'])).to.be.true
})
it('should return an error if the file cannot be stored', async function () {
await expect(
persistor.sendFile('/not-a-dir', files.wombat, '/uploads/info.txt')
persistor.sendFile(
notADirPath,
files.wombat,
Path.join(tmpDir, 'uploads', 'info.txt')
)
).to.be.rejectedWith(Errors.WriteError)
})
})
@@ -88,7 +120,9 @@ describe('FSPersistorTests', function () {
describe("when the file doesn't exist", function () {
beforeEach(function () {
stream = fs.createReadStream('/uploads/info.txt')
stream = fs.createReadStream(
Path.join(tmpDir, 'uploads', 'info.txt')
)
})
it('should write the stream to disk', async function () {
@@ -96,7 +130,7 @@ describe('FSPersistorTests', function () {
const contents = await fsPromises.readFile(
scenario.fsPath(files.wombat)
)
expect(contents.equals(localFiles['/uploads/info.txt'])).to.be.true
expect(contents.equals(fileContents['info.txt'])).to.be.true
})
it('should delete the temporary file', async function () {
@@ -109,7 +143,7 @@ describe('FSPersistorTests', function () {
describe('on error', function () {
beforeEach(async function () {
await expect(
persistor.sendStream('/not-a-dir', files.wombat, stream)
persistor.sendStream(notADirPath, files.wombat, stream)
).to.be.rejectedWith(Errors.WriteError)
})
@@ -129,13 +163,12 @@ describe('FSPersistorTests', function () {
describe('when the md5 hash matches', function () {
it('should write the stream to disk', async function () {
await persistor.sendStream(location, files.wombat, stream, {
sourceMd5: md5(localFiles['/uploads/info.txt']),
sourceMd5: md5(fileContents['info.txt']),
})
const contents = await fsPromises.readFile(
scenario.fsPath(files.wombat)
)
expect(contents.equals(localFiles['/uploads/info.txt'])).to.be
.true
expect(contents.equals(fileContents['info.txt'])).to.be.true
})
})
@@ -169,9 +202,11 @@ describe('FSPersistorTests', function () {
await persistor.sendFile(
location,
files.wombat,
'/uploads/info.txt'
Path.join(tmpDir, 'uploads', 'info.txt')
)
stream = fs.createReadStream(
Path.join(tmpDir, 'uploads', 'other.txt')
)
stream = fs.createReadStream('/uploads/other.txt')
})
it('should write the stream to disk', async function () {
@@ -179,7 +214,7 @@ describe('FSPersistorTests', function () {
const contents = await fsPromises.readFile(
scenario.fsPath(files.wombat)
)
expect(contents.equals(localFiles['/uploads/other.txt'])).to.be.true
expect(contents.equals(fileContents['other.txt'])).to.be.true
})
it('should delete the temporary file', async function () {
@@ -192,7 +227,7 @@ describe('FSPersistorTests', function () {
describe('on error', function () {
beforeEach(async function () {
await expect(
persistor.sendStream('/not-a-dir', files.wombat, stream)
persistor.sendStream(notADirPath, files.wombat, stream)
).to.be.rejectedWith(Errors.WriteError)
})
@@ -200,8 +235,7 @@ describe('FSPersistorTests', function () {
const contents = await fsPromises.readFile(
scenario.fsPath(files.wombat)
)
expect(contents.equals(localFiles['/uploads/info.txt'])).to.be
.true
expect(contents.equals(fileContents['info.txt'])).to.be.true
})
it('should delete the temporary file', async function () {
@@ -215,13 +249,12 @@ describe('FSPersistorTests', function () {
describe('when the md5 hash matches', function () {
it('should write the stream to disk', async function () {
await persistor.sendStream(location, files.wombat, stream, {
sourceMd5: md5(localFiles['/uploads/other.txt']),
sourceMd5: md5(fileContents['other.txt']),
})
const contents = await fsPromises.readFile(
scenario.fsPath(files.wombat)
)
expect(contents.equals(localFiles['/uploads/other.txt'])).to.be
.true
expect(contents.equals(fileContents['other.txt'])).to.be.true
})
})
@@ -238,8 +271,7 @@ describe('FSPersistorTests', function () {
const contents = await fsPromises.readFile(
scenario.fsPath(files.wombat)
)
expect(contents.equals(localFiles['/uploads/info.txt'])).to.be
.true
expect(contents.equals(fileContents['info.txt'])).to.be.true
})
it('should delete the temporary file', async function () {
@@ -254,13 +286,17 @@ describe('FSPersistorTests', function () {
describe('getObjectStream', function () {
beforeEach(async function () {
await persistor.sendFile(location, files.wombat, '/uploads/info.txt')
await persistor.sendFile(
location,
files.wombat,
Path.join(tmpDir, 'uploads', 'info.txt')
)
})
it('should return a string with the object contents', async function () {
const stream = await persistor.getObjectStream(location, files.wombat)
const contents = await streamToBuffer(stream)
expect(contents.equals(localFiles['/uploads/info.txt'])).to.be.true
expect(contents.equals(fileContents['info.txt'])).to.be.true
})
it('should support ranges', async function () {
@@ -274,8 +310,8 @@ describe('FSPersistorTests', function () {
)
const contents = await streamToBuffer(stream)
// end is inclusive in ranges, but exclusive in slice()
expect(contents.equals(localFiles['/uploads/info.txt'].slice(5, 17)))
.to.be.true
expect(contents.equals(fileContents['info.txt'].slice(5, 17))).to.be
.true
})
it('should give a NotFoundError if the file does not exist', async function () {
@@ -287,13 +323,17 @@ describe('FSPersistorTests', function () {
describe('getObjectSize', function () {
beforeEach(async function () {
await persistor.sendFile(location, files.wombat, '/uploads/info.txt')
await persistor.sendFile(
location,
files.wombat,
Path.join(tmpDir, 'uploads', 'info.txt')
)
})
it('should return the file size', async function () {
expect(
await persistor.getObjectSize(location, files.wombat)
).to.equal(localFiles['/uploads/info.txt'].length)
).to.equal(fileContents['info.txt'].length)
})
it('should throw a NotFoundError if the file does not exist', async function () {
@@ -305,7 +345,11 @@ describe('FSPersistorTests', function () {
describe('copyObject', function () {
beforeEach(async function () {
await persistor.sendFile(location, files.wombat, '/uploads/info.txt')
await persistor.sendFile(
location,
files.wombat,
Path.join(tmpDir, 'uploads', 'info.txt')
)
})
it('Should copy the file to the new location', async function () {
@@ -313,13 +357,17 @@ describe('FSPersistorTests', function () {
const contents = await fsPromises.readFile(
scenario.fsPath(files.potato)
)
expect(contents.equals(localFiles['/uploads/info.txt'])).to.be.true
expect(contents.equals(fileContents['info.txt'])).to.be.true
})
})
describe('deleteObject', function () {
beforeEach(async function () {
await persistor.sendFile(location, files.wombat, '/uploads/info.txt')
await persistor.sendFile(
location,
files.wombat,
Path.join(tmpDir, 'uploads', 'info.txt')
)
await fsPromises.access(scenario.fsPath(files.wombat))
})
@@ -337,7 +385,11 @@ describe('FSPersistorTests', function () {
describe('deleteDirectory', function () {
beforeEach(async function () {
for (const file of Object.values(files)) {
await persistor.sendFile(location, file, '/uploads/info.txt')
await persistor.sendFile(
location,
file,
Path.join(tmpDir, 'uploads', 'info.txt')
)
await fsPromises.access(scenario.fsPath(file))
}
})
@@ -365,7 +417,11 @@ describe('FSPersistorTests', function () {
describe('checkIfObjectExists', function () {
beforeEach(async function () {
await persistor.sendFile(location, files.wombat, '/uploads/info.txt')
await persistor.sendFile(
location,
files.wombat,
Path.join(tmpDir, 'uploads', 'info.txt')
)
})
it('should return true for existing files', async function () {
@@ -384,13 +440,17 @@ describe('FSPersistorTests', function () {
describe('directorySize', function () {
beforeEach(async function () {
for (const file of Object.values(files)) {
await persistor.sendFile(location, file, '/uploads/info.txt')
await persistor.sendFile(
location,
file,
Path.join(tmpDir, 'uploads', 'info.txt')
)
}
})
it('should sum directory files size', async function () {
expect(await persistor.directorySize(location, 'animals')).to.equal(
2 * localFiles['/uploads/info.txt'].length
2 * fileContents['info.txt'].length
)
})
@@ -404,7 +464,11 @@ describe('FSPersistorTests', function () {
describe('listDirectoryKeys', function () {
beforeEach(async function () {
for (const file of Object.values(files)) {
await persistor.sendFile(location, file, '/uploads/info.txt')
await persistor.sendFile(
location,
file,
Path.join(tmpDir, 'uploads', 'info.txt')
)
}
})
@@ -427,7 +491,11 @@ describe('FSPersistorTests', function () {
describe('listDirectoryStats', function () {
beforeEach(async function () {
for (const file of Object.values(files)) {
await persistor.sendFile(location, file, '/uploads/info.txt')
await persistor.sendFile(
location,
file,
Path.join(tmpDir, 'uploads', 'info.txt')
)
}
})
@@ -438,7 +506,7 @@ describe('FSPersistorTests', function () {
expect(keys).to.include(scenario.fsPath(files.wombat))
expect(keys).to.include(scenario.fsPath(files.giraffe))
for (const stat of stats) {
expect(stat.size).to.equal(localFiles['/uploads/info.txt'].length)
expect(stat.size).to.equal(fileContents['info.txt'].length)
}
})
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+17 -16
View File
@@ -3,39 +3,41 @@
"private": true,
"packageManager": "yarn@4.14.1",
"devDependencies": {
"@eslint/compat": "^2.1.0",
"@eslint/js": "^10.0.1",
"@overleaf/eslint-plugin": "workspace:*",
"@prettier/plugin-pug": "^3.4.0",
"@types/chai": "^4.3.0",
"@types/chai-as-promised": "^7.1.8",
"@types/mocha": "^10.0.6",
"@types/multer": "^2.1.0",
"@typescript-eslint/eslint-plugin": "8.50.0",
"@typescript-eslint/parser": "^8.50.0",
"@typescript-eslint/eslint-plugin": "^8.59.4",
"@typescript-eslint/parser": "^8.59.4",
"@vitest/eslint-plugin": "^1.5.0",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-chai-expect": "^3.0.0",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint": "^10.4.0",
"eslint-config-prettier": "^10.0.1",
"eslint-formatter-unix": "^8.40.0",
"eslint-plugin-chai-expect": "^4.0.0",
"eslint-plugin-chai-friendly": "^1.1.0",
"eslint-plugin-cypress": "^4.1.0",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-mocha": "^11.0.0",
"eslint-plugin-n": "^18.0.0",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-unicorn": "^56.0.0",
"globals": "^17.6.0",
"prettier": "3.7.4",
"prettier-plugin-groovy": "0.2.1",
"typescript": "^5.9.3"
},
"engines": {
"node": ">=20.0.0"
"node": ">=20.19.0"
},
"resolutions": {
"@xmldom/xmldom": "0.8.13",
"argparse/underscore": "1.13.8",
"east/underscore": "1.13.8",
"referer-parser/js-yaml": "^4.1.0",
"referer-parser/js-yaml": "^4.1.1",
"sandboxed-module": "patch:sandboxed-module@npm%3A2.0.4#~/.yarn/patches/sandboxed-module-npm-2.0.4-f8b45aacc9.patch",
"request/tough-cookie": "5.1.2",
"request/form-data": "2.5.5",
@@ -99,7 +101,6 @@
"knip": "5.64.1",
"eslint-plugin-testing-library": "7.5.3",
"chart.js": "4.0.1",
"mock-fs": "5.2.0",
"@customerio/cdp-analytics-node": "0.3.9",
"@google-cloud/bigquery": "8.1.1",
"moment": "2.29.4",
-29
View File
@@ -1,29 +0,0 @@
{
"extends": [
"eslint:recommended",
"standard",
"prettier"
],
"plugins": [
"unicorn"
],
"parserOptions": {
"ecmaVersion": 2020
},
"env": {
"node": true
},
"rules": {
// Do not allow importing of implicit dependencies.
"import/no-extraneous-dependencies": "error",
"unicorn/prefer-node-protocol": "error"
},
"overrides": [
// Extra rules for Cypress tests
{ "files": ["**/*.spec.ts"], "extends": ["plugin:cypress/recommended"] }
],
"ignorePatterns": [
"hotfix/",
"develop/"
]
}
+37 -7
View File
@@ -3,7 +3,8 @@
# Overleaf Community Edition (overleaf/overleaf)
# ---------------------------------------------
ARG OVERLEAF_BASE_TAG=sharelatex/sharelatex-base:latest
#ARG OVERLEAF_BASE_TAG=sharelatex/sharelatex-base:latest
ARG OVERLEAF_BASE_TAG=sharelatex/sharelatex-base:5
FROM $OVERLEAF_BASE_TAG
WORKDIR /overleaf
@@ -18,26 +19,55 @@ COPY server-ce/genScript.js server-ce/services.js /overleaf/
# Corepack setup, shared between all the images.
ENV PATH="/overleaf/node_modules/.bin:$PATH"
ENV COREPACK_HOME=/opt/corepack
RUN corepack enable && corepack install -g yarn@4.14.1
#RUN corepack enable && corepack install -g yarn@4.14.1
RUN corepack enable && corepack prepare yarn@4.14.1 --activate
ENV COREPACK_ENABLE_NETWORK=0
# Install yarn dependencies
# -------------------------
# The git-sourced @replit/codemirror-* deps are prepared with Yarn Classic,
# whose cache lives in /usr/local/share/.cache/yarn. We mount that as a *tmpfs*
# (fresh every build) rather than a persistent BuildKit cache: when it was
# persistent, BuildKit would garbage-collect/evict part of it between builds,
# leaving a half-populated cache that Yarn Classic then tripped over (missing
# .yarn-tarball.tgz / EEXIST). A clean cache per build is reliable; the cost is
# re-fetching that small set of git deps. The valuable Berry cache
# (server-ce-yarn-cache) stays persistent. YARN_NETWORK_CONCURRENCY=1 is kept
# as cheap insurance against concurrent writes to the fresh cache.
#
# Preparing those git deps also makes Yarn Classic fetch esbuild's ~10
# per-platform binaries, whose downloads occasionally arrive truncated ("the
# file appears to be corrupt" / missing .yarn-tarball.tgz). Since the tmpfs is
# fresh each build there is nothing to fall back to, so we wrap the step in a
# small retry loop that wipes the classic cache and re-fetches before failing.
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \
--mount=type=cache,target=/usr/local/share/.cache/yarn,id=server-ce-yarn-fallback-cache \
--mount=type=tmpfs,target=/tmp node genScript install | bash
--mount=type=tmpfs,target=/usr/local/share/.cache/yarn \
--mount=type=tmpfs,target=/tmp \
for i in 1 2 3; do \
node genScript install | YARN_NETWORK_CONCURRENCY=1 bash && exit 0; \
echo "==== install attempt $i failed; wiping Yarn Classic cache and retrying ===="; \
rm -rf /usr/local/share/.cache/yarn/* 2>/dev/null || true; \
done; \
exit 1
# Add the actual source files
# ---------------------------
COPY --parents libraries/ services/ tools/migrations/ /overleaf/
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \
--mount=type=cache,target=/usr/local/share/.cache/yarn,id=server-ce-yarn-fallback-cache \
--mount=type=tmpfs,target=/usr/local/share/.cache/yarn \
--mount=type=cache,target=/overleaf/services/web/node_modules/.cache,id=server-ce-webpack-cache \
--mount=type=tmpfs,target=/tmp \
node genScript compile | bash
for i in 1 2 3; do \
node genScript compile | YARN_NETWORK_CONCURRENCY=1 bash && exit 0; \
echo "==== compile attempt $i failed; wiping Yarn Classic cache and retrying ===="; \
find /tmp -name pack.log -exec cat {} \; 2>/dev/null || true; \
rm -rf /usr/local/share/.cache/yarn/* 2>/dev/null || true; \
done; \
echo "==== PACK LOGS (all attempts failed) ===="; \
find /tmp -name pack.log -exec cat {} \; 2>/dev/null || true; \
exit 1
# Copy runit service startup scripts to its location
# --------------------------------------------------
ADD server-ce/runit /etc/service
+106 -30
View File
@@ -4,7 +4,7 @@
FROM phusion/baseimage:noble-1.0.3
# Makes sure LuaTex cache is writable
# Makes sure LuaTeX cache is writable
# -----------------------------------
ENV TEXMFVAR=/var/lib/overleaf/tmp/texmf-var
@@ -39,44 +39,120 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
/etc/nginx/nginx.conf \
/etc/nginx/sites-enabled/default
# Install TexLive
# ---------------
# CTAN mirrors occasionally fail, in that case install TexLive using a
# different server, for example https://ctan.crest.fr
# Install Quarto (bundles Typst for PDF rendering — no LaTeX needed)
# ------------------------------------------------------------------
ARG QUARTO_VERSION=1.6.39
RUN curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb" -o /tmp/quarto.deb \
&& dpkg -i /tmp/quarto.deb \
&& rm /tmp/quarto.deb \
&& mkdir -p /var/www/.cache/quarto /var/www/.local/share \
&& chown -R www-data:www-data /var/www/.cache /var/www/.local
# Install official Typst binary (Quarto bundles a modified fork without --synctex)
# ---------------------------------------------------------------------------------
ARG TYPST_VERSION=0.13.1
RUN curl -fsSL "https://github.com/typst/typst/releases/download/v${TYPST_VERSION}/typst-x86_64-unknown-linux-musl.tar.xz" \
| tar -xJC /usr/local/bin --strip-components=1 "typst-x86_64-unknown-linux-musl/typst"
# Pre-install popular Quarto extensions
# -----------------------------------------------------------------------
# Extensions land in /opt/quarto-extensions/_extensions/<author>/<name>/.
# QuartoRunner copies them into each project's compile dir (no-clobber,
# so user-uploaded extensions in their project always take precedence).
# To add more: append another line: && quarto add --no-prompt <author>/<repo>
# -----------------------------------------------------------------------
RUN mkdir -p /opt/quarto-extensions \
&& cd /opt/quarto-extensions \
\
# Typst document formats
&& quarto add --no-prompt igorlima/charged-ieee \
\
# RevealJS presentation plugins (official Quarto extensions)
&& quarto add --no-prompt quarto-ext/fontawesome \
&& quarto add --no-prompt quarto-ext/attribution \
&& quarto add --no-prompt quarto-ext/pointer \
&& quarto add --no-prompt quarto-ext/drop \
\
&& chown -R www-data:www-data /opt/quarto-extensions
# Install Jupyter so Quarto can execute Python code cells in documents/decks
# -----------------------------------------------------------------------
# Quarto runs ```{python}``` cells through a Jupyter kernel. It uses the system
# python3 it detected (/usr/bin/python3), so Jupyter must be installed there.
# We install only the headless execution stack Quarto needs (jupyter-client +
# nbclient/nbformat + the ipykernel kernel + pyyaml, which Quarto's own
# /opt/quarto/share/jupyter wrapper imports), not the notebook/lab servers, and
# register a system-wide "python3" kernelspec under /usr/local/share/jupyter so
# it is discoverable regardless of HOME/XDG. Noble's Python is externally
# managed (PEP 668), hence --break-system-packages in this controlled image.
# The runtime user (www-data) writes Jupyter's runtime/connection files under
# its HOME (/var/www/.local), which is made writable in the Quarto step above.
# python3-venv is needed so a project's requirements.txt can be installed into
# a per-project venv (see QuartoRunner / PythonVenvGate).
RUN apt-get update \
&& apt-get install -y python3-pip python3-venv \
&& pip3 install --no-cache-dir --break-system-packages \
jupyter-core jupyter-client nbclient nbformat ipykernel pyyaml \
&& python3 -m ipykernel install --prefix /usr/local --name python3 --display-name "Python 3" \
# Bundle the common scientific-Python stack so most decks "just work" without
# any per-project install. matplotlib renders headless (Agg) automatically;
# opencv-python-headless is the GUI-less OpenCV build (provides cv2) suited to
# a server. To add more later, append to this list (the cheapest way to cover
# a library many projects need).
&& pip3 install --no-cache-dir --break-system-packages \
numpy pandas scipy matplotlib seaborn scikit-learn sympy plotly tabulate \
opencv-python-headless tqdm \
&& rm -rf /var/lib/apt/lists/* /root/.cache
# Install decktape + headless Chromium (for exporting RevealJS decks to PDF)
# -----------------------------------------------------------------------
# decktape drives a headless Chromium (via Puppeteer) to print the rendered
# reveal.js slides to a faithful, one-slide-per-page PDF. Chromium is the
# open-source engine (BSD); decktape is MIT, Puppeteer Apache-2.0 — all
# permissive and AGPL-compatible. They are invoked as a separate process
# (QuartoRunner runs `decktape ...`), never linked into the app.
#
# # docker build \
# --build-arg TEXLIVE_MIRROR=https://ctan.crest.fr/tex-archive/systems/texlive/tlnet \
# -f Dockerfile-base -t sharelatex/sharelatex-base .
# Puppeteer downloads its Chromium into PUPPETEER_CACHE_DIR during the global
# install; we put it in a world-readable /opt path so the www-data runtime user
# can launch it. Playwright is used only as a robust, distro-aware installer for
# Chromium's system libraries (handles Ubuntu Noble's t64 package renames).
ENV PUPPETEER_CACHE_DIR=/opt/puppeteer
RUN npm install -g decktape \
&& npx --yes playwright@latest install-deps chromium \
&& chmod -R a+rX /opt/puppeteer \
&& rm -rf /root/.npm /root/.cache
# Install TeX Live (for compiling .tex projects with latexmk)
# -----------------------------------------------------------------------
# Verso compiles .qmd with Quarto and .tex with latexmk; both engines live
# side by side.
#
# MINIMAL install (current): the upstream-Overleaf approach — scheme-basic
# (~300 MB) plus a few essential packages via tlmgr. Fast to build and small.
# Many documents that need extra packages (tikz, beamer, siunitx, extra
# fonts, ...) will NOT compile out of the box; users can be told to keep
# those projects in Quarto/Typst for now.
#
# TO GO FULL LATER (when the project is mature): change
# selected_scheme scheme-basic -> scheme-full
# and optionally drop the explicit `tlmgr install` line. That single change
# restores a complete LaTeX toolchain at the cost of size/build time.
# Alternatively add individual packages to the `tlmgr install` list below.
# -----------------------------------------------------------------------
ARG TEXLIVE_MIRROR=https://mirror.ox.ac.uk/sites/ctan.org/systems/texlive/tlnet
ENV PATH="${PATH}:/usr/local/texlive/bin/x86_64-linux"
RUN mkdir /install-tl-unx \
&& wget --quiet https://tug.org/texlive/files/texlive.asc \
&& gpg --import texlive.asc \
&& rm texlive.asc \
&& wget --quiet ${TEXLIVE_MIRROR}/install-tl-unx.tar.gz \
&& wget --quiet ${TEXLIVE_MIRROR}/install-tl-unx.tar.gz.sha512 \
&& wget --quiet ${TEXLIVE_MIRROR}/install-tl-unx.tar.gz.sha512.asc \
&& gpg --verify install-tl-unx.tar.gz.sha512.asc \
&& sha512sum -c install-tl-unx.tar.gz.sha512 \
&& tar -xz -C /install-tl-unx --strip-components=1 -f install-tl-unx.tar.gz \
&& rm install-tl-unx.tar.gz* \
&& echo "tlpdbopt_autobackup 0" >> /install-tl-unx/texlive.profile \
&& curl -sSL ${TEXLIVE_MIRROR}/install-tl-unx.tar.gz \
| tar -xzC /install-tl-unx --strip-components=1 \
&& echo "tlpdbopt_autobackup 0" >> /install-tl-unx/texlive.profile \
&& echo "tlpdbopt_install_docfiles 0" >> /install-tl-unx/texlive.profile \
&& echo "tlpdbopt_install_srcfiles 0" >> /install-tl-unx/texlive.profile \
&& echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile \
\
&& echo "selected_scheme scheme-full" >> /install-tl-unx/texlive.profile \
&& echo "TEXDIR /usr/local/texlive" >> /install-tl-unx/texlive.profile \
&& /install-tl-unx/install-tl \
-profile /install-tl-unx/texlive.profile \
-repository ${TEXLIVE_MIRROR} \
\
&& $(find /usr/local/texlive -name tlmgr) path add \
&& tlmgr install --repository ${TEXLIVE_MIRROR} \
latexmk \
texcount \
synctex \
etoolbox \
xetex \
&& tlmgr path add \
&& rm -rf /install-tl-unx
+32
View File
@@ -0,0 +1,32 @@
FROM phusion/baseimage:noble-1.0.2
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
bash \
ca-certificates \
curl \
git \
gnupg \
nginx \
logrotate \
cron \
redis-tools \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Node.js 22
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get update \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Needed by Overleaf scripts
RUN npm install -g corepack
# Runit/log dirs expected by Overleaf
RUN mkdir -p /etc/service /var/log/overleaf /overleaf
WORKDIR /overleaf
+6
View File
@@ -173,6 +173,12 @@ const settings = {
clsiCacheDir: Path.join(DATA_DIR, 'cache'),
// Where to write the output files to disk after running LaTeX
outputDir: Path.join(DATA_DIR, 'output'),
// Where to store published-presentation snapshots served at /p/:token.
// Lives on the data volume so it is writable by the app user (and, with a
// persistent volume, survives restarts).
publishedPresentationsFolder:
process.env.PUBLISHED_PRESENTATIONS_PATH ||
Path.join(DATA_DIR, 'published'),
},
// Server Config
+33
View File
@@ -0,0 +1,33 @@
import { defineConfig, globalIgnores } from 'eslint/config'
import cypress from 'eslint-plugin-cypress/flat'
import path from 'node:path'
import baseConfig from '../eslint.config.mjs'
const ROOT_DIR = path.resolve(import.meta.dirname, '..')
export default defineConfig([
globalIgnores(['**/hotfix/', '**/develop/']),
{
basePath: ROOT_DIR,
extends: baseConfig,
languageOptions: {
ecmaVersion: 2020,
},
},
{
// The cypress block in baseConfig has patterns rooted at the
// monorepo root (`server-ce/test/helpers/*.ts`). When ESLint loads
// this file (server-ce/eslint.config.mjs) as the closest config --
// which happens when running `yarn run lint` from
// /overleaf/server-ce/test/ -- patterns from baseConfig are
// resolved relative to /overleaf/server-ce/, so those cross-dir
// patterns don't match. Re-declare with paths relative to this
// config file.
files: [
'test/helpers/*.ts',
'test/cypress/support/*.{js,jsx,mjs,cjs,ts,tsx}',
'**/*.spec.ts',
],
...cypress.configs.recommended,
},
])
+108
View File
@@ -0,0 +1,108 @@
# App tier for the prod (verso namespace) instance: the Verso Deployment and
# Service. Matches what the deploy workflow applies, except OVERLEAF_NAV_TITLE
# is a static "Verso Alpha" here — the workflow overwrites it with the build
# number ("Verso V0.<n> Alpha") on each deploy.
#
# The image registry.alocoq.fr/verso:stable is produced by the prod workflow
# (push to the `prod` branch). If you apply this file before the first prod
# build, the pod will sit in ImagePullBackOff until that image exists — that's
# expected.
#
# kubectl apply -f server-ce/k8s/verso-prod-app.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: verso
namespace: verso
spec:
replicas: 1
# RWO data volume → can't run two pods at once; recreate on update.
strategy:
type: Recreate
selector:
matchLabels:
app: verso
template:
metadata:
labels:
app: verso
spec:
securityContext:
# App runs as www-data (uid/gid 33); make the data volume
# group-writable by it.
fsGroup: 33
initContainers:
- name: init-data-perms
image: busybox:latest
command: ["sh", "-c"]
args:
- |
set -eux
mkdir -p /data/template_files /data/user_files \
/data/compiles /data/cache /data/output /data/published
chown -R 33:33 /data
volumeMounts:
- name: verso-data
mountPath: /data
containers:
- name: verso
image: registry.alocoq.fr/verso:stable
# :stable is a fixed tag, so force a pull on every rollout to pick up
# the freshly built image.
imagePullPolicy: Always
ports:
- containerPort: 80
env:
- name: OVERLEAF_MONGO_URL
value: mongodb://mongo:27017/sharelatex?replicaSet=rs0
- name: OVERLEAF_REDIS_HOST
value: redis
- name: REDIS_HOST
value: redis
- name: OVERLEAF_APP_NAME
value: Verso
- name: OVERLEAF_NAV_TITLE
value: "Verso Alpha"
- name: OVERLEAF_SITE_URL
value: https://verso.alocoq.fr
- name: OVERLEAF_SITE_LANGUAGE
value: fr
# Allow anonymous visitors so public published-presentation links
# and read-only share links work without login.
- name: OVERLEAF_ALLOW_PUBLIC_ACCESS
value: "true"
# NB: anonymous read-AND-write sharing is intentionally NOT enabled
# (compiles are unsandboxed → only trusted accounts may trigger
# them). Public self-registration is also off (CE default).
- name: OVERLEAF_ENABLE_PROJECT_PYTHON_VENV
value: "true"
# SMTP for password-reset / invite emails. All OVERLEAF_EMAIL_* vars
# are loaded from the optional 'verso-smtp' Secret — its keys must be
# named exactly like these env vars (see the kubectl create secret
# command in the docs). Optional, so the app still boots before the
# secret exists; email just stays off.
envFrom:
- secretRef:
name: verso-smtp
optional: true
volumeMounts:
- name: verso-data
mountPath: /var/lib/overleaf/data
volumes:
- name: verso-data
persistentVolumeClaim:
claimName: verso-data
---
apiVersion: v1
kind: Service
metadata:
name: verso
namespace: verso
spec:
selector:
app: verso
ports:
- name: http
port: 80
targetPort: 80
+102
View File
@@ -0,0 +1,102 @@
# Data tier for the prod (verso namespace) instance: Mongo + Redis Deployments
# and Services. Identical to what the deploy workflow applies — provided as a
# standalone file so you can bootstrap and validate the namespace before the
# first prod build (and before granting the runner access).
#
# Order:
# 1. kubectl apply -f server-ce/k8s/verso-prod-pvcs.yaml (with storageClass)
# 2. kubectl apply -f server-ce/k8s/verso-prod-data.yaml (this file)
# 3. wait for mongo to be Ready, then initialise the replica set ONCE:
# kubectl -n verso exec deploy/mongo -- mongosh --quiet --eval \
# 'rs.initiate({_id:"rs0",members:[{_id:0,host:"mongo:27017"}]})'
# (the workflow also does this idempotently, so it's optional here)
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo
namespace: verso
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:8
command: ["mongod", "--replSet", "rs0", "--bind_ip_all"]
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-data
mountPath: /data/db
volumes:
- name: mongo-data
persistentVolumeClaim:
claimName: mongo-data
---
apiVersion: v1
kind: Service
metadata:
name: mongo
namespace: verso
spec:
selector:
app: mongo
ports:
- name: mongo
port: 27017
targetPort: 27017
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
namespace: verso
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:7
# AOF persistence so a restart doesn't drop in-flight edits before
# they're flushed to Mongo.
command: ["redis-server", "--appendonly", "yes"]
ports:
- containerPort: 6379
volumeMounts:
- name: redis-data
mountPath: /data
volumes:
- name: redis-data
persistentVolumeClaim:
claimName: redis-data
---
apiVersion: v1
kind: Service
metadata:
name: redis
namespace: verso
spec:
selector:
app: redis
ports:
- name: redis
port: 6379
targetPort: 6379
@@ -0,0 +1,44 @@
# Example Ingress for the prod (verso namespace) instance at verso.alocoq.fr.
#
# This is NOT applied by the deploy workflow on purpose: the test ingress is
# managed by hand, and TLS/annotations depend on your cluster's ingress
# controller (Traefik) and cert setup. Copy this, adapt it to match how
# test.alocoq.fr is wired, then `kubectl apply -f` it once.
#
# Prerequisites:
# - DNS: verso.alocoq.fr → your ingress/load-balancer IP.
# - A TLS cert for verso.alocoq.fr (cert-manager, or a manually created
# Secret referenced under tls.secretName).
#
# Adjust:
# - ingressClassName (e.g. "traefik") to match your controller.
# - annotations (cert-manager issuer, Traefik entrypoints/router, etc.) to
# match the test ingress.
# - the TLS block (cert-manager will create the secret; otherwise create it).
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: verso
namespace: verso
annotations:
# --- adapt these to match your test.alocoq.fr ingress ---
# cert-manager.io/cluster-issuer: letsencrypt-prod
# traefik.ingress.kubernetes.io/router.entrypoints: websecure
spec:
ingressClassName: traefik
tls:
- hosts:
- verso.alocoq.fr
secretName: verso-tls
rules:
- host: verso.alocoq.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: verso
port:
number: 80
+49
View File
@@ -0,0 +1,49 @@
# PersistentVolumeClaims for the prod (verso namespace) instance.
#
# Provisioned out of band (not by the deploy workflow) so the storageClass is
# under your control. Create them ONCE, before the first prod deploy:
#
# kubectl apply -f server-ce/k8s/verso-prod-pvcs.yaml
#
# Use a Ceph RBD (block) storageClass for all three — every volume here is
# single-writer ReadWriteOnce (Mongo, Redis, and the single app pod). Set
# storageClassName below to your RBD class (run `kubectl get storageclass` to
# find its name). Sizes are starting points; RBD supports online expansion.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongo-data
namespace: verso
spec:
accessModes: [ReadWriteOnce]
# storageClassName: ceph-rbd # <- set to your RBD (block) storageClass
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redis-data
namespace: verso
spec:
accessModes: [ReadWriteOnce]
# storageClassName: ceph-rbd # <- set to your RBD (block) storageClass
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: verso-data
namespace: verso
# verso-data is mounted at /var/lib/overleaf/data: user files, compiles, output
# cache, and published-presentation snapshots.
spec:
accessModes: [ReadWriteOnce]
# storageClassName: ceph-rbd # <- set to your RBD (block) storageClass
resources:
requests:
storage: 20Gi
+19 -4
View File
@@ -20,13 +20,28 @@ server {
access_log off;
# Ignore symlinks possibly created by users
disable_symlinks on;
# enable compression for tex auxiliary files, but not for pdf files
# enable compression for text-based output: tex auxiliary files, logs, and
# HTML/CSS/JS (RevealJS presentations). Already-compressed formats (pdf,
# png/jpeg/webp, woff/woff2) are deliberately omitted to avoid wasting CPU.
gzip on;
gzip_types text/plain;
gzip_types text/plain text/html text/css application/javascript application/json image/svg+xml;
gzip_proxied any;
# only compress responses worth compressing
gzip_min_length 1024;
types {
text/plain log blg aux stdout stderr;
application/pdf pdf;
text/html html htm;
text/css css;
application/javascript js;
application/json json;
image/svg+xml svg svgz;
image/png png;
image/jpeg jpeg jpg;
image/gif gif;
image/webp webp;
font/woff woff;
font/woff2 woff2;
application/pdf pdf;
text/plain log blg aux stdout stderr txt;
}
# handle output files for specific users
location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ {
+1 -1
View File
@@ -46,7 +46,7 @@ http {
gzip_disable "msie6";
gzip_proxied any; # allow upstream server to compress.
client_max_body_size 50m;
client_max_body_size 500m;
# gzip_vary on;
# gzip_proxied any;
+1
View File
@@ -11,6 +11,7 @@ export TEX_LIVE_DOCKER_IMAGE ?= us-east1-docker.pkg.dev/overleaf-ops/ol-docker/t
export ALL_TEX_LIVE_DOCKER_IMAGES ?= us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2023.1,us-east1-docker.pkg.dev/overleaf-ops/ol-docker/texlive-full:2022.1
export IMAGE_TAG_CE ?= sharelatex/sharelatex:main
export IMAGE_TAG_PRO ?= us-east1-docker.pkg.dev/overleaf-ops/ol-docker/pro:main
export IMAGE_TAG_GIT_BRIDGE ?= us-east1-docker.pkg.dev/overleaf-ops/ol-docker/git-bridge:main
export CYPRESS_SHARD ?=
export COMPOSE_PROJECT_NAME ?= test
export USER_UID=$(shell id -u)
+1
View File
@@ -245,6 +245,7 @@ describe('admin panel', function () {
'Deleted Projects',
'Audit Log',
'Sessions',
'Personal Access Tokens',
]
cy.findAllByRole('tab').should('have.length', tabs.length)
tabs.forEach(tabName => {
+7 -6
View File
@@ -78,12 +78,12 @@ services:
working_dir: $PWD
volumes:
- $PWD:$PWD
- $MONOREPO/libraries:$MONOREPO/libraries:ro
- $MONOREPO/node_modules:$MONOREPO/node_modules:ro
- $MONOREPO/.yarn:$MONOREPO/.yarn:ro
- $MONOREPO/.yarnrc.yml:$MONOREPO/.yarnrc.yml:ro
- $MONOREPO/package.json:$MONOREPO/package.json:ro
- $MONOREPO/yarn.lock:$MONOREPO/yarn.lock:ro
- $MONOREPO/libraries:$MONOREPO/libraries
- $MONOREPO/node_modules:$MONOREPO/node_modules
- $MONOREPO/.yarn:$MONOREPO/.yarn
- $MONOREPO/.yarnrc.yml:$MONOREPO/.yarnrc.yml
- $MONOREPO/package.json:$MONOREPO/package.json
- $MONOREPO/yarn.lock:$MONOREPO/yarn.lock
environment:
MONOREPO:
CYPRESS_SHARD:
@@ -130,6 +130,7 @@ services:
ALL_TEX_LIVE_DOCKER_IMAGES:
IMAGE_TAG_CE:
IMAGE_TAG_PRO:
IMAGE_TAG_GIT_BRIDGE:
healthcheck:
test: curl --fail http://localhost/status
interval: 3s
+2
View File
@@ -44,6 +44,7 @@ describe('editor', function () {
cy.log(`change project language to '${lng}'`)
cy.findByRole('button', { name: 'Settings' }).click()
cy.findByRole('dialog').within(() => {
cy.findByRole('tab', { name: 'Spelling and language' }).click()
cy.findByLabelText('Spellcheck language').select(lng)
})
cy.get('body').type('{esc}')
@@ -76,6 +77,7 @@ describe('editor', function () {
cy.log('remove word from dictionary')
cy.findByRole('button', { name: 'Settings' }).click()
cy.findByRole('dialog').within(() => {
cy.findByRole('tab', { name: 'Spelling and language' }).click()
cy.findByLabelText('Dictionary').click()
})
cy.findByTestId('dictionary-modal').within(() => {
+3 -2
View File
@@ -32,11 +32,12 @@ const PATHS = {
const IMAGES = {
CE: process.env.IMAGE_TAG_CE.replace(/:.+/, ''),
PRO: process.env.IMAGE_TAG_PRO.replace(/:.+/, ''),
GIT_BRIDGE: process.env.IMAGE_TAG_GIT_BRIDGE.replace(/:.+/, ''),
}
const LATEST = {
CE: process.env.IMAGE_TAG_CE.replace(/.+:/, '') || 'latest',
PRO: process.env.IMAGE_TAG_PRO.replace(/.+:/, '') || 'latest',
GIT_BRIDGE: 'latest', // TODO, build in CI?
GIT_BRIDGE: process.env.IMAGE_TAG_GIT_BRIDGE.replace(/.+:/, '') || 'latest',
}
function defaultDockerComposeOverride() {
@@ -242,7 +243,7 @@ function setVarsDockerCompose({
cfg.services.sharelatex.image = `${pro ? IMAGES.PRO : IMAGES.CE}:${version === 'latest' ? (pro ? LATEST.PRO : LATEST.CE) : version}`
cfg.services['git-bridge'].image =
`quay.io/sharelatex/git-bridge:${version === 'latest' ? LATEST.GIT_BRIDGE : version}`
`${IMAGES.GIT_BRIDGE}:${version === 'latest' ? LATEST.GIT_BRIDGE : version}`
cfg.services.sharelatex.environment = vars
+1 -1
View File
@@ -333,7 +333,7 @@ describe('SandboxedCompiles', function () {
})
// https://github.com/overleaf/internal/issues/20216
// eslint-disable-next-line mocha/no-skipped-tests
// eslint-disable-next-line mocha/no-pending-tests
describe.skip('unavailable in CE', function () {
if (isExcludedBySharding('CE_CUSTOM_1')) return
startWith({ pro: false, vars: enabledVars, resetData: true })
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+6 -2
View File
@@ -54,6 +54,10 @@ COMPOSE_PROJECT_NAME_TEST_UNIT ?= test_unit_$(BUILD_DIR_NAME)
DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_TEST_UNIT) $(DOCKER_COMPOSE)
.PHONY: print-branch-tag-safe
print-branch-tag-safe:
@echo $(BRANCH_NAME_TAG_SAFE)
clean:
-docker rmi $(IMAGE_CI)
-docker rmi $(IMAGE_REPO_FINAL)
@@ -66,8 +70,8 @@ clean:
RUN_LINTING = ../../bin/run -w /overleaf/services/$(PROJECT_NAME) monorepo yarn run --silent
RUN_LINTING_MONOREPO = ../../bin/run monorepo yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/chat/reports:/overleaf/services/chat/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/chat/reports:/overleaf/services/chat/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/chat/reports:/overleaf/services/chat/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/chat/reports:/overleaf/services/chat/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
SHELLCHECK_OPTS = \
--shell=bash \
+1
View File
@@ -1,5 +1,6 @@
chat
--dependencies=mongo
--deploy-pipeline=chat
--env-add=
--env-pass-through=
--esmock-loader=False
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+17 -3
View File
@@ -32,6 +32,7 @@ COPY libraries/overleaf-editor-core/package.json /overleaf/libraries/overleaf-ed
COPY libraries/promise-utils/package.json /overleaf/libraries/promise-utils/package.json
COPY libraries/settings/package.json /overleaf/libraries/settings/package.json
COPY libraries/stream-utils/package.json /overleaf/libraries/stream-utils/package.json
COPY libraries/validation-tools/package.json /overleaf/libraries/validation-tools/package.json
COPY services/clsi/package.json /overleaf/services/clsi/package.json
COPY .yarn/patches/ /overleaf/.yarn/patches/
@@ -45,13 +46,17 @@ COPY libraries/overleaf-editor-core/ /overleaf/libraries/overleaf-editor-core/
COPY libraries/promise-utils/ /overleaf/libraries/promise-utils/
COPY libraries/settings/ /overleaf/libraries/settings/
COPY libraries/stream-utils/ /overleaf/libraries/stream-utils/
COPY libraries/validation-tools/ /overleaf/libraries/validation-tools/
COPY services/clsi/ /overleaf/services/clsi/
FROM app AS with-texlive
FROM app AS with-quarto
ARG QUARTO_VERSION=1.6.39
RUN apt-get update \
&& apt-cache depends texlive-full | grep "Depends: " | grep -v -- "-doc" | grep -v -- "-lang-" | sed 's/Depends: //' | xargs apt-get install -y --no-install-recommends \
&& apt-get install -y --no-install-recommends fontconfig inkscape python3-pygments qpdf \
&& apt-get install -y --no-install-recommends curl ca-certificates \
&& curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb" -o /tmp/quarto.deb \
&& dpkg -i /tmp/quarto.deb \
&& rm /tmp/quarto.deb \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p cache compiles output \
@@ -60,6 +65,15 @@ RUN mkdir -p cache compiles output \
CMD ["node", "--expose-gc", "app.js"]
FROM app
ARG QUARTO_VERSION=1.6.39
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates \
&& curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb" -o /tmp/quarto.deb \
&& dpkg -i /tmp/quarto.deb \
&& rm /tmp/quarto.deb \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p cache compiles output \
&& chown node:node cache compiles output
+10 -4
View File
@@ -25,6 +25,7 @@ IMAGE_CACHE ?= $(IMAGE_REPO):cache-$(shell cat \
$(MONOREPO)/libraries/promise-utils/package.json \
$(MONOREPO)/libraries/settings/package.json \
$(MONOREPO)/libraries/stream-utils/package.json \
$(MONOREPO)/libraries/validation-tools/package.json \
$(MONOREPO)/services/clsi/package.json \
$(MONOREPO)/.yarn/patches/* \
| sha256sum | cut -d '-' -f1)
@@ -54,6 +55,10 @@ COMPOSE_PROJECT_NAME_TEST_UNIT ?= test_unit_$(BUILD_DIR_NAME)
DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_TEST_UNIT) $(DOCKER_COMPOSE)
.PHONY: print-branch-tag-safe
print-branch-tag-safe:
@echo $(BRANCH_NAME_TAG_SAFE)
clean:
-docker rmi $(IMAGE_CI)
-docker rmi $(IMAGE_REPO_FINAL)
@@ -67,8 +72,8 @@ clean:
RUN_LINTING = ../../bin/run -w /overleaf/services/$(PROJECT_NAME) monorepo yarn run --silent
RUN_LINTING_MONOREPO = ../../bin/run monorepo yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/clsi/reports:/overleaf/services/clsi/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/clsi/reports:/overleaf/services/clsi/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/clsi/reports:/overleaf/services/clsi/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/clsi/reports:/overleaf/services/clsi/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
SHELLCHECK_OPTS = \
--shell=bash \
@@ -165,8 +170,9 @@ test_acceptance_clean:
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0
test_acceptance_pre_run:
docker pull us-east1-docker.pkg.dev/overleaf-ops/ol-docker/pandoc:3.9
docker pull us-east1-docker.pkg.dev/overleaf-ops/ol-docker/pandoc-staging:3.9
-docker pull us-east1-docker.pkg.dev/overleaf-ops/ol-docker/pandoc:3.9
-docker pull us-east1-docker.pkg.dev/overleaf-ops/ol-docker/pandoc-staging:3.9
-cd ../../ && docker build -t us-east1-docker.pkg.dev/overleaf-ops/ol-docker/pdftocairo:24.02 dockerfiles/pdftocairo
ifneq (,$(wildcard test/acceptance/js/scripts/pre-run))
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run $(DC_RUN_FLAGS) test_acceptance test/acceptance/js/scripts/pre-run
endif
+5
View File
@@ -145,6 +145,11 @@ app.post(
bodyParser.json({ limit: Settings.compileSizeLimit }),
ConversionController.convertProjectToDocument
)
app.post(
'/convert/pdf-to-jpeg',
FileUploadMiddleware.multerMiddleware,
ConversionController.convertPDFToJPEG
)
if (process.env.NODE_ENV === 'development' && global.__coverage__) {
app.get('/coverage', (req, res) => {
+7 -1
View File
@@ -80,6 +80,10 @@ function compile(req, res, next) {
{ err: error, projectId: request.project_id },
'timeout running compile'
)
} else if (error?.typstCompileFailure) {
// Typst compiled but with errors — treat as a compile failure so
// the frontend shows the error log rather than the old PDF.
status = 'failure'
} else if (error) {
status = 'error'
code = 500
@@ -90,7 +94,9 @@ function compile(req, res, next) {
} else {
if (
outputFiles.some(
file => file.path === 'output.pdf' && file.size > 0
file =>
(file.path === 'output.pdf' && file.size > 0) ||
file.path === 'output.html'
)
) {
status = 'success'
+65 -69
View File
@@ -1,12 +1,13 @@
import fsPromises from 'node:fs/promises'
import os from 'node:os'
import Path from 'node:path'
import { callbackify } from 'node:util'
import Settings from '@overleaf/settings'
import logger from '@overleaf/logger'
import OError from '@overleaf/o-error'
import ResourceWriter from './ResourceWriter.js'
import QuartoRunner from './QuartoRunner.js'
import LatexRunner from './LatexRunner.js'
import TypstRunner from './TypstRunner.js'
import OutputFileFinder from './OutputFileFinder.js'
import OutputCacheManager from './OutputCacheManager.js'
import ClsiMetrics from './Metrics.js'
@@ -18,16 +19,12 @@ import CommandRunner from './CommandRunner.js'
import ContentCacheMetrics from './ContentCacheMetrics.js'
import SynctexOutputParser from './SynctexOutputParser.js'
import CLSICacheHandler from './CLSICacheHandler.js'
import StatsManager from './StatsManager.js'
import SafeReader from './SafeReader.js'
import LatexMetrics from './LatexMetrics.js'
import { callbackifyMultiResult } from '@overleaf/promise-utils'
import * as HistoryResourceWriter from './HistoryResourceWriter.js'
const { downloadLatestCompileCache, downloadOutputDotSynctexFromCompileCache } =
CLSICacheHandler
const { emitPdfStats } = ContentCacheMetrics
const { enableLatexMkMetrics, addLatexFdbMetrics } = LatexMetrics
const { shouldSkipMetrics } = ClsiMetrics
const KNOWN_LATEXMK_RULES = new Set([
@@ -44,6 +41,43 @@ const KNOWN_LATEXMK_RULES = new Set([
const LATEX_PASSES_RULES = new Set(['latex', 'lualatex', 'xelatex', 'pdflatex'])
// Quarto handles .qmd/.md/.Rmd sources; everything else (.tex, .ltx, .Rtex,
// .Rnw) is compiled with latexmk via LatexRunner. Dispatch is by the root
// file's extension, so LaTeX and Quarto projects can coexist on one server.
function _isQuartoFile(rootResourcePath) {
return /\.(qmd|md|rmd)$/i.test(rootResourcePath || '')
}
// A bare Typst source (.typ) compiles straight to PDF with the Typst that
// ships inside Quarto (see TypstRunner), separate from the Quarto pipeline.
function _isTypstFile(rootResourcePath) {
return /\.typ$/i.test(rootResourcePath || '')
}
// Return a runner with a uniform { run, isRunning, kill } interface so the
// rest of CompileManager doesn't need to know which engine is in use.
function _getRunner(rootResourcePath) {
if (_isTypstFile(rootResourcePath)) {
return {
run: (name, opts) => TypstRunner.promises.runTypst(name, opts),
isRunning: name => TypstRunner.isRunning(name),
kill: name => TypstRunner.promises.killTypst(name),
}
}
if (_isQuartoFile(rootResourcePath)) {
return {
run: (name, opts) => QuartoRunner.promises.runQuarto(name, opts),
isRunning: name => QuartoRunner.isRunning(name),
kill: name => QuartoRunner.promises.killQuarto(name),
}
}
return {
run: (name, opts) => LatexRunner.promises.runLatex(name, opts),
isRunning: name => LatexRunner.isRunning(name),
kill: name => LatexRunner.promises.killLatex(name),
}
}
function getCompileName(projectId, userId) {
if (userId != null) {
return `${projectId}-${userId}`
@@ -124,7 +158,11 @@ async function doCompile(request, stats, timings) {
)
// apply a series of file modifications/creations for draft mode and tikz
if (request.draft) {
// Draft mode injects LaTeX preamble commands — skip for Quarto files
const isLatexFile = /\.(tex|ltx|Rtex)$/i.test(
request.rootResourcePath || ''
)
if (request.draft && isLatexFile) {
await DraftModeManager.promises.injectDraftMode(
Path.join(compileDir, request.rootResourcePath)
)
@@ -196,18 +234,10 @@ async function doCompile(request, stats, timings) {
const compileName = getCompileName(request.project_id, request.user_id)
// Record latexmk -time stats for a subset of users
const recordPerformanceMetrics = StatsManager.sampleRequest(
request,
Settings.performanceLogSamplingPercentage
)
// Define a `latexmk` property on the stats object
// to collect latexmk -time stats.
enableLatexMkMetrics(stats)
const runner = _getRunner(request.rootResourcePath)
try {
await LatexRunner.promises.runLatex(compileName, {
await runner.run(compileName, {
directory: compileDir,
mainFile: request.rootResourcePath,
compiler: request.compiler,
@@ -217,6 +247,8 @@ async function doCompile(request, stats, timings) {
environment: env,
compileGroup: request.compileGroup,
stopOnFirstError: request.stopOnFirstError,
exportMode: request.exportMode,
allowPythonInstall: request.allowPythonInstall,
stats,
timings,
})
@@ -294,50 +326,13 @@ async function doCompile(request, stats, timings) {
})
timings.compileE2E = Date.now() - e2eCompileStart
const status = stats['latexmk-errors'] ? 'error' : 'success'
const status = 'success'
_emitMetrics(request, status, stats, timings)
if (stats['pdf-size'] && !shouldSkipMetrics(request)) {
emitPdfStats(stats, timings, request)
}
// Record compile performance for a subset of users
if (recordPerformanceMetrics) {
// Add fdb metrics if available
try {
const fdbFileContent = await _readFdbFile(compileDir)
if (fdbFileContent) {
addLatexFdbMetrics(fdbFileContent, stats)
}
} catch (err) {
// ignore errors reading fdb file
logger.warn(
{ err, projectId, userId },
'error reading fdb file for performance metrics'
)
}
const loadavg = typeof os.loadavg === 'function' ? os.loadavg() : undefined
logger.info(
{
userId: request.user_id,
projectId: request.project_id,
timeTaken: timings.compile,
clsiRequest: request,
stats,
timings,
// explicitly include latexmk stats to bypass the non-enumerable property
latexmk: stats.latexmk,
loadavg1m: loadavg?.[0],
loadavg5m: loadavg?.[1],
loadavg15m: loadavg?.[2],
samplingPercentage: Settings.performanceLogSamplingPercentage,
},
'sampled performance log'
)
}
return { outputFiles, buildId, baseHistoryVersion }
}
@@ -366,42 +361,43 @@ async function _saveOutputFiles({
return { outputFiles, allEntries, buildId }
}
// Set a maximum size for reading output.fdb_latexmk files
// This limit is chosen to prevent excessive memory usage and ensure performance,
// as fdb files are typically much smaller and only metrics are extracted from them.
const MAX_FDB_FILE_SIZE = 1024 * 1024 // 1 MB
async function _readFdbFile(compileDir) {
const fdbFile = Path.join(compileDir, 'output.fdb_latexmk')
const { result } = await SafeReader.promises.readFile(
fdbFile,
MAX_FDB_FILE_SIZE,
'utf8'
)
return result
}
async function stopCompile(projectId, userId) {
const compileName = getCompileName(projectId, userId)
// stopCompile has no root path, so check both runners — only one can be
// active for a given compileName at a time.
const isRunning =
QuartoRunner.isRunning(compileName) ||
LatexRunner.isRunning(compileName) ||
TypstRunner.isRunning(compileName)
const lock = LockManager.getExistingLock(getCompileDir(projectId, userId))
let lockReleased
if (lock) {
lockReleased = lock.waitForRelease()
} else {
if (!LatexRunner.isRunning(compileName)) return
if (!isRunning) return
logger.warn({ projectId, userId }, 'found running compile without lock')
lockReleased = Promise.resolve()
}
await QuartoRunner.promises.killQuarto(compileName)
await LatexRunner.promises.killLatex(compileName)
await TypstRunner.promises.killTypst(compileName)
await lockReleased
}
async function clearProject(projectId, userId) {
// Kill any live typst watcher before deleting its files.
const compileName = getCompileName(projectId, userId)
await TypstRunner.promises.killTypst(compileName)
const compileDir = getCompileDir(projectId, userId)
await fsPromises.rm(compileDir, { force: true, recursive: true })
}
async function clearProjectWithListing(projectId, userId, allEntries) {
// Kill any live typst watcher (e.g. timedout compile where killTypst
// was not already called) before removing files from under it.
const compileName = getCompileName(projectId, userId)
await TypstRunner.promises.killTypst(compileName)
const compileDir = getCompileDir(projectId, userId)
const exists = await _checkDirectory(compileDir)
@@ -14,10 +14,12 @@ import RequestParser from './RequestParser.js'
import { pipeline } from 'node:stream/promises'
import Settings from '@overleaf/settings'
import Path from 'node:path'
import { z } from '@overleaf/validation-tools'
const CONVERSION_CONFIGS = {
docx: { extension: 'docx' },
markdown: { extension: 'zip' },
html: { extension: 'zip' },
}
async function convertDocumentToLaTeX(req, res) {
@@ -77,6 +79,51 @@ async function convertDocumentToLaTeX(req, res) {
}
}
const PDFToJPEGQuerySchema = z.object({
mode: z.enum(['preview', 'thumbnail']),
})
async function convertPDFToJPEG(req, res) {
const { path } = req.file
if (!Settings.enablePdfConversions) {
await fs.unlink(path).catch(() => {})
return res.sendStatus(404)
}
const parsed = PDFToJPEGQuerySchema.safeParse(req.query)
if (!parsed.success) {
await fs.unlink(path).catch(() => {})
return res.sendStatus(400)
}
const { mode } = parsed.data
logger.debug({ path, mode }, 'received pdf for conversion to jpeg')
const conversionId = crypto.randomUUID()
let jpegPath
try {
jpegPath = await ConversionManager.promises.convertPDFToJPEGWithLock(
conversionId,
path,
mode
)
} finally {
await fs.unlink(path).catch(() => {})
}
try {
const jpegStat = await fs.stat(jpegPath)
res.setHeader('Content-Length', jpegStat.size)
res.attachment('output.jpg')
res.setHeader('X-Content-Type-Options', 'nosniff')
const readStream = fsSync.createReadStream(jpegPath)
await pipeline(readStream, res)
} finally {
await fs
.rm(Path.dirname(jpegPath), { recursive: true, force: true })
.catch(() => {})
}
}
async function convertProjectToDocument(req, res) {
if (!Settings.enablePandocConversions) {
return res.sendStatus(404)
@@ -207,4 +254,5 @@ async function convertProjectToDocument(req, res) {
export default {
convertDocumentToLaTeX: expressify(convertDocumentToLaTeX),
convertProjectToDocument: expressify(convertProjectToDocument),
convertPDFToJPEG: expressify(convertPDFToJPEG),
}
+92
View File
@@ -18,6 +18,18 @@ const CONVERSION_CONFIGS = {
},
}
const PDF_TO_JPEG_CONFIGS = {
preview: { width: 794, quality: 90 },
thumbnail: { width: 190, quality: 50 },
}
const PDF_TO_JPEG_INPUT_FILENAME = 'input.pdf'
const PDF_TO_JPEG_OUTPUT_FILENAME = 'output.jpg'
const PDF_TO_JPEG_OUTPUT_BASENAME = Path.basename(
PDF_TO_JPEG_OUTPUT_FILENAME,
'.jpg'
)
async function convertToLaTeXWithLock(conversionId, inputPath, conversionType) {
const conversionDir = Path.join(Settings.path.compilesDir, conversionId)
const lock = LockManager.acquire(conversionDir)
@@ -150,6 +162,19 @@ const LATEX_EXPORT_CONFIGS = {
'markdown',
],
},
html: {
fileExtension: 'html',
compressOutput: true,
getPandocArgs: ({ outputPath }) => [
'--output',
outputPath,
'--from',
'latex',
'--to',
'html',
'--standalone',
],
},
}
async function convertLaTeXToDocumentInDirWithLock(
@@ -298,9 +323,76 @@ async function convertLaTeXToDocumentInDir(
return Path.join(compileDir, finalOutputName)
}
async function convertPDFToJPEGWithLock(conversionId, inputPath, mode) {
const conversionDir = Path.join(Settings.path.compilesDir, conversionId)
const lock = LockManager.acquire(conversionDir)
try {
return await convertPDFToJPEG(conversionId, conversionDir, inputPath, mode)
} finally {
lock.release()
}
}
async function convertPDFToJPEG(conversionId, conversionDir, inputPath, mode) {
const config = PDF_TO_JPEG_CONFIGS[mode]
await fs.mkdir(conversionDir, { recursive: true })
const newSourcePath = Path.join(conversionDir, PDF_TO_JPEG_INPUT_FILENAME)
await fs.copyFile(inputPath, newSourcePath)
const dstPath = Path.join(conversionDir, PDF_TO_JPEG_OUTPUT_FILENAME)
try {
const { stdout, stderr, exitCode } = await CommandRunner.promises.run(
conversionId,
[
'pdftocairo',
'-jpeg',
'-jpegopt',
`quality=${config.quality}`,
'-singlefile',
'-scale-to-x',
config.width.toString(),
'-scale-to-y',
'-1', // maintain aspect ratio
PDF_TO_JPEG_INPUT_FILENAME,
PDF_TO_JPEG_OUTPUT_BASENAME,
],
conversionDir,
Settings.pdftocairoImage,
Settings.conversionTimeoutSeconds * 1000,
{},
'conversions',
null
)
if (exitCode !== 0) {
throw new OError('Non-zero exit code from pdftocairo', {
exitCode,
stderr,
})
}
logger.debug(
{ stdout, stderr, exitCode },
'pdf-to-jpeg conversion completed'
)
const stat = await fs.lstat(dstPath)
if (!stat.isFile()) {
throw new OError('output.jpg is not a regular file', { stat })
}
// Clean up the source PDF to leave only the conversion result
await fs.unlink(newSourcePath).catch(() => {})
} catch (error) {
await fs.rm(conversionDir, { force: true, recursive: true }).catch(() => {})
throw new OError('pdf-to-jpeg conversion failed').withCause(error)
}
return dstPath
}
export default {
promises: {
convertToLaTeXWithLock,
convertLaTeXToDocumentInDirWithLock,
convertPDFToJPEGWithLock,
},
}
+7 -7
View File
@@ -197,13 +197,13 @@ function _buildLatexCommand(mainFile, opts = {}) {
command.push(...opts.flags)
}
// TeX Engine selection
const compilerFlag = COMPILER_FLAGS[opts.compiler]
if (compilerFlag) {
command.push(compilerFlag)
} else {
throw new Error(`unknown compiler: ${opts.compiler}`)
}
// TeX Engine selection. A .tex project may carry a non-LaTeX compiler value
// (e.g. 'quarto', the fork-wide default for Project.compiler) because the
// runner is chosen by file extension, not by this setting. In that case fall
// back to pdfLaTeX rather than throwing — throwing here surfaces as an opaque
// HTTP 500 with no compile log.
const compilerFlag = COMPILER_FLAGS[opts.compiler] || COMPILER_FLAGS.pdflatex
command.push(compilerFlag)
// We want to run latexmk on the tex file which we will automatically
// generate from the Rtex/Rmd/md file.
+2 -1
View File
@@ -89,9 +89,10 @@ export default CommandRunner = {
err.terminated = true
return callback(err)
} else if (code === 1) {
// exit status from chktex
// exit status from chktex (and any compiler that exits 1 on failure)
err = new Error('exited')
err.code = code
err.stdout = stdout // preserve captured output for callers
return callback(err)
} else {
return callback(null, { stdout, exitCode: code })
+14 -1
View File
@@ -20,16 +20,29 @@ async function walkFolder(compileDir, d, files, allEntries) {
}
}
// Media that an HTML/RevealJS deck references at runtime (img/video/audio).
// These are usually project *input* files, which would normally be excluded
// from the output set — but for HTML output the browser fetches them from the
// output path, so they must be served. (For PDF output they are embedded, so
// the exclusion still applies.)
const MEDIA_REGEX =
/\.(png|jpe?g|gif|svg|webp|avif|bmp|ico|mp4|webm|ogg|ogv|mov|m4v|mp3|wav|m4a|woff2?|ttf|otf)$/i
async function findOutputFiles(resources, directory) {
const files = []
const allEntries = []
await walkFolder(directory, '', files, allEntries)
const incomingResources = new Set(resources.map(resource => resource.path))
// For HTML output (Quarto/RevealJS), referenced media must be served even
// though it is an input file; see MEDIA_REGEX above.
const hasHtmlOutput = files.includes('output.html')
const outputFiles = []
for (const path of files) {
if (incomingResources.has(path)) continue
if (incomingResources.has(path)) {
if (!(hasHtmlOutput && MEDIA_REGEX.test(path))) continue
}
if (path === '.project-sync-state') continue
outputFiles.push({
path,
+365
View File
@@ -0,0 +1,365 @@
import Path from 'node:path'
import { promisify } from 'node:util'
import logger from '@overleaf/logger'
import CommandRunner from './CommandRunner.js'
import fs from 'node:fs'
// Maps currently-running Quarto jobs: compileName → PID (or docker container id)
const ProcessTable = {}
function runQuarto(compileName, options, callback) {
const { directory, mainFile, image, environment, compileGroup } = options
const timeout = options.timeout || 60000
logger.debug(
{ directory, timeout, mainFile, compileGroup },
'starting quarto compile'
)
// For the standalone-HTML export we must render a deck whose frontmatter
// carries embed-resources (it cannot be set from the CLI: Quarto only honours
// embed-resources when it is nested under the format, and a document's own
// format block fully overrides project/CLI metadata). So write a temporary
// copy of the root .qmd with the options injected and render that instead.
let renderTarget = mainFile
if (options.exportMode === 'html-standalone') {
renderTarget = _writeStandaloneVariant(directory, mainFile)
}
// Where cached per-project venvs live (shared across projects, keyed by the
// requirements.vrf hash). Must be on a persistent volume in production.
const venvBaseDir =
process.env.PYTHON_VENVS_DIR || '/var/lib/overleaf/data/python-venvs'
const command = _buildQuartoCommand(
renderTarget,
options.exportMode,
Boolean(options.allowPythonInstall),
venvBaseDir
)
ProcessTable[compileName] = CommandRunner.run(
compileName,
command,
directory,
image,
timeout,
environment || {},
compileGroup,
null,
function (error, output) {
delete ProcessTable[compileName]
// Propagate real process-level errors (killed, timed out) but NOT
// ordinary non-zero exit codes from Quarto itself. A Quarto compile
// failure (exit code 1) is not a server error — the absence of
// output.pdf is sufficient for CompileController to return 'failure'.
if (error && (error.terminated || error.timedout)) {
return callback(error)
}
// On exit-code-1 errors LocalCommandRunner attaches stdout to the
// error object; merge it so _writeLogOutput can persist it.
const combined = output || (error ? { stdout: error.stdout || '' } : null)
_writeLogOutput(compileName, directory, combined, () =>
_appendMissingResourceWarnings(directory, () =>
callback(null, combined)
)
)
}
)
}
function _buildQuartoCommand(
renderTarget,
exportMode,
allowPythonInstall,
venvBaseDir
) {
// Run through a POSIX shell so stderr is merged into stdout (2>&1).
// LocalCommandRunner replaces $COMPILE_DIR before the shell sees it.
//
// We do NOT pass --to or --output: let the YAML frontmatter decide the
// output format (typst → output.pdf, revealjs → output.html, etc.).
//
// For a normal preview compile we do NOT embed resources. A self-contained
// single-file HTML breaks reveal.js plugins that load/store resources at
// runtime (e.g. chalkboard, multiplex) and is slow to transfer. Instead
// Quarto emits the HTML plus a sibling "<basename>_files/" asset directory;
// the HTML references it with relative paths. Both the html and the asset
// dir are served from the same .../output/ path, so the relative links
// resolve. For the 'html-standalone' export, runQuarto instead renders a
// temporary copy of the deck (renderTarget) whose frontmatter enables
// embed-resources, producing a single portable file.
//
// After render we rename the produced top-level file to output.pdf or
// output.html. The asset directory keeps its "<basename>_files" name; the
// renamed output.html still points at it via the unchanged relative refs.
//
// The extension merge (cp -rn, no-clobber so user extensions win) and the
// trailing semicolon (so a missing /opt/quarto-extensions doesn't abort)
// are kept. mv uses relative paths because LocalCommandRunner.replace()
// only substitutes the FIRST $COMPILE_DIR and the shell CWD is the dir.
const inputPath = `$COMPILE_DIR/${renderTarget}`
const baseName = renderTarget.replace(/\.[^/.]+$/, '') // strip extension
let tail =
`(mv ${baseName}.pdf output.pdf 2>/dev/null || ` +
`mv ${baseName}.html output.html 2>/dev/null)`
if (exportMode === 'pdf-slides') {
// After producing output.html, print it to output-slides.pdf with decktape
// (headless Chromium via Puppeteer). The CLSI runtime user has no writable
// HOME, so Chromium's crashpad can't create its database and the browser
// dies on launch ("chrome_crashpad_handler: --database is required").
// Point HOME / XDG dirs / the Chromium user-data-dir at a fresh writable
// temp dir to give it somewhere to write.
// --no-sandbox: Chromium can't sandbox as a non-root container user
// --disable-dev-shm-usage: a tiny container /dev/shm crashes Chromium
// --disable-gpu: there is no GPU in the container
tail +=
` && CHROME_HOME="$(mktemp -d)" && ` +
`HOME="$CHROME_HOME" XDG_CONFIG_HOME="$CHROME_HOME" ` +
`XDG_CACHE_HOME="$CHROME_HOME" decktape ` +
`--chrome-arg=--no-sandbox ` +
`--chrome-arg=--disable-dev-shm-usage ` +
`--chrome-arg=--disable-gpu ` +
`--chrome-arg=--user-data-dir="$CHROME_HOME/data" ` +
`"$(pwd)/output.html" output-slides.pdf 2>&1`
}
// For the standalone export, remove the temporary render copy afterwards so
// it can't be mistaken for a project file or picked up by a later preview
// compile. Runs regardless of render success (";").
const cleanup =
exportMode === 'html-standalone'
? `; rm -rf ${baseName}.qmd ${baseName}_files`
: ''
const venvPrep = allowPythonInstall ? _pythonVenvPrep(venvBaseDir) : ''
const cmd =
`mkdir -p _extensions && ` +
`cp -rn /opt/quarto-extensions/_extensions/. _extensions/ 2>/dev/null; ` +
venvPrep +
`quarto render ${inputPath} 2>&1 && ` +
tail +
cleanup
return ['/bin/sh', '-c', cmd]
}
// Shell snippet (run before `quarto render`, in the compile dir) that installs
// a project's requirements.vrf into a venv cached by the file's sha256 and
// points Quarto at it via QUARTO_PYTHON. Notes:
// - The venv is shared across projects/compiles (keyed by content hash), so
// identical dependency sets are built once.
// - --system-site-packages keeps the bundled scientific stack + ipykernel
// visible, so only the *extra* packages are installed.
// - A per-hash flock serialises concurrent compiles building the same venv.
// - Everything is merged to stdout so pip output/errors land in output.log;
// on failure QUARTO_PYTHON is left unset and the render falls back to the
// base interpreter (the missing-package error then surfaces normally).
// - Only $-shell vars / $(...) are used (no ${...}) to avoid clashing with
// JS template interpolation; only ${venvBaseDir} is substituted by JS.
function _pythonVenvPrep(venvBaseDir) {
return (
`if [ -f requirements.vrf ]; then ` +
`VBASE="${venvBaseDir}"; ` +
`RHASH=$(sha256sum requirements.vrf 2>/dev/null | cut -d" " -f1); ` +
`if [ -n "$RHASH" ]; then ` +
`VDIR="$VBASE/$RHASH"; mkdir -p "$VBASE" 2>/dev/null; ` +
`( flock 9 || exit 0; ` +
`if [ ! -f "$VDIR/.verso-ready" ]; then ` +
`echo "Installing Python packages from requirements.vrf..."; rm -rf "$VDIR"; ` +
`python3 -m venv --system-site-packages "$VDIR" ` +
`&& "$VDIR/bin/pip" install --no-input --disable-pip-version-check -r requirements.vrf ` +
// Register a python3 kernelspec INSIDE the venv (argv -> the venv's python)
// so Quarto runs the kernel in the venv, not the base /usr/bin/python3 from
// the global kernelspec. ipykernel is visible via --system-site-packages.
`&& "$VDIR/bin/python3" -m ipykernel install --sys-prefix --name python3 --display-name "Python 3" ` +
`&& touch "$VDIR/.verso-ready" ` +
`|| echo "ERROR: Failed to install Python packages from requirements.vrf"; ` +
`fi ` +
`) 9>"$VBASE/.$RHASH.lock" 2>&1; ` +
`if [ -f "$VDIR/.verso-ready" ]; then export QUARTO_PYTHON="$VDIR/bin/python3"; fi; ` +
`fi; ` +
`fi; `
)
}
// Write a temporary copy of the root .qmd with embed-resources enabled in its
// frontmatter, returning the temp filename to render. On any problem (no
// frontmatter, not a nested revealjs deck, read/write error) it falls back to
// the original mainFile — the export then just isn't self-contained, which is
// no worse than before. The temp file lives in the same directory so relative
// resources (images, _extensions) still resolve.
function _writeStandaloneVariant(directory, mainFile) {
try {
const content = fs.readFileSync(Path.join(directory, mainFile), 'utf8')
const transformed = _injectRevealjsStandaloneOptions(content)
if (!transformed) return mainFile
const base = mainFile.replace(/\.[^/.]+$/, '')
const tempName = `${base}.verso-standalone.qmd`
fs.writeFileSync(Path.join(directory, tempName), transformed)
return tempName
} catch (err) {
logger.warn({ err, directory, mainFile }, 'could not prepare standalone qmd')
return mainFile
}
}
// Inject the self-contained options into the `revealjs:` block of a deck's
// YAML frontmatter. embed-resources/self-contained-math inline all CSS/JS/
// images/MathJax into one portable file; chalkboard must be off (it is
// incompatible with embed-resources and would error the render). Keys already
// present in the block are overwritten in place (so we never create duplicate
// YAML keys, e.g. an existing `chalkboard: true`); missing keys are inserted.
// Returns the new document text, or null if it isn't a nested-revealjs deck we
// can safely edit.
function _injectRevealjsStandaloneOptions(content) {
const fmMatch = content.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)/)
if (!fmMatch) return null
const [, open, body, close] = fmMatch
const lines = body.split('\n')
const revealIdx = lines.findIndex(l => /^\s*revealjs:\s*$/.test(l))
if (revealIdx === -1) return null // not a `format:\n revealjs:` deck
const revealIndent = lines[revealIdx].match(/^(\s*)/)[1]
// Determine the block's child indent (from the first more-indented line) and
// where the block ends (the first later line indented at/under revealjs:).
let childIndent = revealIndent + ' '
let blockEnd = lines.length
let seenChild = false
for (let i = revealIdx + 1; i < lines.length; i++) {
if (lines[i].trim() === '') continue
const indent = lines[i].match(/^(\s*)/)[1]
if (indent.length <= revealIndent.length) {
blockEnd = i
break
}
if (!seenChild) {
childIndent = indent
seenChild = true
}
}
const desired = {
'embed-resources': 'true',
'self-contained-math': 'true',
chalkboard: 'false',
}
const present = new Set()
for (let i = revealIdx + 1; i < blockEnd; i++) {
const km = lines[i].match(/^\s*([A-Za-z0-9_-]+):/)
if (km && Object.prototype.hasOwnProperty.call(desired, km[1])) {
lines[i] = `${childIndent}${km[1]}: ${desired[km[1]]}`
present.add(km[1])
}
}
const additions = Object.keys(desired)
.filter(k => !present.has(k))
.map(k => `${childIndent}${k}: ${desired[k]}`)
if (additions.length) lines.splice(revealIdx + 1, 0, ...additions)
return open + lines.join('\n') + close + content.slice(fmMatch[0].length)
}
function _writeLogOutput(compileName, directory, output, callback) {
const content = (output && output.stdout) || ''
if (!content) return callback()
// Write to output.log so the PDF-preview log panel picks it up
const logFile = Path.join(directory, 'output.log')
fs.unlink(logFile, () => {
fs.writeFile(logFile, content, { flag: 'wx' }, err => {
if (err) {
logger.error({ err, compileName, logFile }, 'error writing quarto log')
}
callback()
})
})
}
// Quarto's HTML/RevealJS output is NOT self-contained (we deliberately dropped
// --embed-resources so reveal plugins like chalkboard work). A side effect is
// that pandoc no longer tries to fetch referenced media, so a missing image or
// video produces no compile-time warning — it just renders broken in the
// browser. To restore that feedback, scan the produced output.html for local
// media references and emit a [WARNING] for any that don't exist on disk. The
// [WARNING] prefix is understood by the Quarto/Typst log parser on the web
// side, so these surface in the Warnings tab like any other.
//
// Only HTML output is scanned: PDF output (Typst) already hard-errors on a
// missing image, so it needs no extra check.
function _appendMissingResourceWarnings(directory, callback) {
const htmlFile = Path.join(directory, 'output.html')
fs.readFile(htmlFile, 'utf8', (err, html) => {
if (err) return callback() // no HTML output (e.g. a PDF compile)
const missing = _extractLocalMediaRefs(html).filter(ref => {
try {
return !fs.existsSync(Path.join(directory, decodeURIComponent(ref)))
} catch {
return false
}
})
if (missing.length === 0) return callback()
const warnings =
missing
.map(
ref =>
`[WARNING] Missing resource: ${ref} (referenced in the document ` +
`but not found in the project — it will appear broken)`
)
.join('\n') + '\n'
fs.appendFile(Path.join(directory, 'output.log'), '\n' + warnings, () =>
callback()
)
})
}
// Pull local media references (img/video/audio/iframe src, poster, RevealJS
// data-background-*) out of the rendered HTML. External URLs, data URIs and
// in-page anchors are ignored; Quarto's own generated assets (under
// <basename>_files/) exist on disk, so they never get flagged.
function _extractLocalMediaRefs(html) {
const refs = new Set()
const attrRegex =
/(?:src|poster|data-background-image|data-background-video)\s*=\s*["']([^"']+)["']/gi
let match
while ((match = attrRegex.exec(html)) !== null) {
const url = match[1].trim()
if (!url) continue
// Skip absolute URLs, protocol-relative, data/blob URIs and anchors.
if (/^(?:[a-z]+:|\/\/|\/|#|data:|blob:)/i.test(url)) continue
const clean = url.split(/[?#]/)[0] // drop query string / fragment
if (clean) refs.add(clean)
}
return [...refs]
}
function isRunning(compileName) {
return ProcessTable[compileName] != null
}
function killQuarto(compileName, callback) {
logger.debug({ compileName }, 'killing running quarto compile')
if (!isRunning(compileName)) {
logger.warn({ compileName }, 'no such compile to kill')
return callback(null)
}
CommandRunner.kill(ProcessTable[compileName], callback)
}
export default {
isRunning,
runQuarto,
killQuarto,
promises: {
runQuarto: promisify(runQuarto),
killQuarto: promisify(killQuarto),
},
}
+24 -3
View File
@@ -2,7 +2,14 @@ import { promisify } from 'node:util'
import settings from '@overleaf/settings'
import OutputCacheManager from './OutputCacheManager.js'
const VALID_COMPILERS = ['pdflatex', 'latex', 'xelatex', 'lualatex']
const VALID_COMPILERS = [
'quarto',
'typst',
'pdflatex',
'latex',
'xelatex',
'lualatex',
]
const MAX_TIMEOUT = 600
const EDITOR_ID_REGEX = /^[a-f0-9-]{36}$/ // UUID
const HISTORY_ID_REGEX = /^([0-9a-f]{24}|[1-9][0-9]{0,9})$/ // mongo id or postgres id
@@ -36,7 +43,7 @@ function parse(body, callback) {
}
response.compiler = _parseAttribute('compiler', compile.options.compiler, {
validValues: VALID_COMPILERS,
default: 'pdflatex',
default: 'quarto',
type: 'string',
})
response.compileFromClsiCache = _parseAttribute(
@@ -95,6 +102,20 @@ function parse(body, callback) {
response.check = _parseAttribute('check', compile.options.check, {
type: 'string',
})
// Verso: on-demand presentation export ('html-standalone' | 'pdf-slides'),
// honoured by QuartoRunner; empty for a normal preview compile.
response.exportMode = _parseAttribute(
'exportMode',
compile.options.exportMode,
{ default: '', type: 'string' }
)
// Verso: whether QuartoRunner may install the project's requirements.txt
// into a cached venv (gated by privilege on the web side).
response.allowPythonInstall = _parseAttribute(
'allowPythonInstall',
compile.options.allowPythonInstall,
{ default: false, type: 'boolean' }
)
response.flags = _parseAttribute('flags', compile.options.flags, {
default: [],
type: 'object',
@@ -180,7 +201,7 @@ function parse(body, callback) {
'rootResourcePath',
compile.rootResourcePath,
{
default: 'main.tex',
default: 'main.qmd',
type: 'string',
}
)
+8
View File
@@ -209,8 +209,16 @@ export default ResourceWriter = {
return callback(error)
}
// Project input resources are in outputFiles only to be served from
// the output cache (HTML media exception in OutputFileFinder). They
// must never be deleted here — incremental compiles don't re-sync
// unchanged binary files, so deleting them would leave them missing
// for Quarto and for _appendMissingResourceWarnings.
const incomingPaths = new Set(resources.map(r => r.path))
const jobs = []
for (const { path } of outputFiles || []) {
if (incomingPaths.has(path)) continue
const shouldDelete = ResourceWriter.isExtraneousFile(path)
if (shouldDelete) {
jobs.push(callback =>
+493
View File
@@ -0,0 +1,493 @@
import Path from 'node:path'
import { spawn } from 'node:child_process'
import { promisify } from 'node:util'
import logger from '@overleaf/logger'
import Settings from '@overleaf/settings'
import CommandRunner from './CommandRunner.js'
import fs from 'node:fs'
// ---------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------
// Max lines kept from the current compile cycle (prevents unbounded growth
// for documents that produce many warnings).
const MAX_LOG_LINES = 500
// How long to wait for the watcher process to emit its first output.
const WATCH_START_TIMEOUT_MS = 15_000
// Matches the start-of-compile marker typst watch emits before each cycle:
// "[HH:MM:SS] compiling ..."
// Used to reset the line buffer so stale output from a failed compile that
// didn't emit a "compiled with errors" footer cannot bleed into the next log.
const COMPILE_START_RE = /^\[\d{2}:\d{2}:\d{2}\] compiling/
// Matches the three terminal lines that typst watch emits at the end of each
// compile cycle regardless of outcome:
// "[HH:MM:SS] compiled successfully in 42ms"
// "[HH:MM:SS] compiled with warnings in 42ms"
// "[HH:MM:SS] compiled with errors"
const COMPILE_DONE_RE = /compiled (successfully|with (errors|warnings))/
// Signals FileId exhaustion in a long-lived typst process (typst issue #7434).
const FILE_ID_EXHAUSTION_RE = /ran out of file ids/i
// Proactively restart the watcher before FileId exhaustion.
// Typst uses ~65 IDs per compile; 1000 compiles ≈ 65 000 — safely under 65 535.
const MAX_COMPILES_BEFORE_RESTART = 1000
// typst watch emits the "[HH:MM:SS] compiled with errors" status line FIRST,
// then the full diagnostic output (file:line:col, code snippets) AFTERWARDS.
// We buffer post-done lines and resolve after this delay if no new compile
// cycle starts sooner. 150 ms is well above the ~1 chunk latency for typst's
// diagnostic flush and imperceptible on top of a typical compile time.
const FLUSH_DELAY_MS = 150
// ---------------------------------------------------------------------------
// State (module-level, never exported)
// ---------------------------------------------------------------------------
// Active cold-start compile jobs (Docker fallback): compileName → PID
const ProcessTable = {}
// Long-lived watcher processes: compileName → WatchEntry
// WatchEntry shape:
// proc ChildProcess
// directory compile dir (absolute path)
// mainFile root .typ filename
// environment env vars passed to the runner
// compilationCount total successful compile cycles on this watcher
// restartPending flag to restart at the next runTypst call
// accumulator incomplete trailing line from the last data chunk
// currentLines lines accumulated in the current phase (pre-done or
// post-done, see _onWatcherData for the two-phase logic)
// doneResult { preLines, compiledWithErrors } held between the
// COMPILE_DONE_RE line and the post-done diagnostic flush;
// null when not in post-done phase
// flushTimeout timeout handle that finalises doneResult when no next
// compile cycle starts within FLUSH_DELAY_MS
// pendingResolvers Array<{resolve, reject, timeoutHandle}>
// pendingResult compile result cached when typst finished before a
// resolver was registered (race-condition safety net)
const WatchTable = {}
// PIDs we have intentionally killed, so the close handler can distinguish
// an expected exit from an unexpected crash.
const _killedWatchPids = new Set()
// ---------------------------------------------------------------------------
// Public entry point
// ---------------------------------------------------------------------------
async function runTypstAsync(compileName, options) {
// Docker / sandboxed mode: fall back to a cold-start compile per request.
if (Settings.clsi?.dockerRunner) {
return _runColdStart(compileName, options)
}
const timeout = options.timeout || 60_000
const entry = WatchTable[compileName]
const needsStart =
!entry ||
entry.restartPending ||
entry.proc.exitCode !== null
if (needsStart) {
if (entry) _killWatchEntry(compileName)
// _startWatcher spawns the process, registers all handlers, then calls
// _waitForNextCompile synchronously — the resolver is in pendingResolvers
// before any I/O event can fire, eliminating the race condition.
const result = await _startWatcher(compileName, options)
await _writeLogOutputAsync(compileName, options.directory, result)
if (result.compiledWithErrors) {
throw Object.assign(new Error('typst-compile-failure'), {
typstCompileFailure: true,
})
}
return result
}
// Watcher is alive. _waitForNextCompile adds the resolver synchronously
// inside the Promise constructor, before this function yields — safe.
const result = await _waitForNextCompile(compileName, timeout)
await _writeLogOutputAsync(compileName, options.directory, result)
if (result.compiledWithErrors) {
throw Object.assign(new Error('typst-compile-failure'), {
typstCompileFailure: true,
})
}
return result
}
// ---------------------------------------------------------------------------
// Watcher lifecycle
// ---------------------------------------------------------------------------
async function _startWatcher(compileName, options) {
const { directory, mainFile, environment } = options
const timeout = options.timeout || 60_000
const absInput = Path.join(directory, mainFile)
const absOutput = Path.join(directory, 'output.pdf')
const env = { ...process.env, ...(environment || {}) }
logger.debug({ compileName, absInput }, 'starting typst watcher')
const proc = spawn(
'/bin/sh',
['-c', `typst watch "${absInput}" "${absOutput}" 2>&1`],
{
cwd: directory,
env,
stdio: ['ignore', 'pipe', 'ignore'],
detached: true,
}
)
const entry = {
proc,
directory,
mainFile,
environment,
compilationCount: 0,
restartPending: false,
accumulator: '',
currentLines: [],
doneResult: null,
flushTimeout: null,
pendingResolvers: [],
pendingResult: null,
}
WatchTable[compileName] = entry
// Register handlers synchronously — before any I/O events can fire.
proc.stdout.setEncoding('utf8')
proc.stdout.on('data', chunk => _onWatcherData(compileName, chunk))
proc.on('error', err => {
logger.error({ err, compileName }, 'typst watcher process error')
_rejectAllPending(
compileName,
Object.assign(err, { terminated: true })
)
if (WatchTable[compileName]?.proc === proc) {
delete WatchTable[compileName]
}
})
proc.on('close', (code, signal) => {
logger.warn({ code, signal, compileName }, 'typst watcher exited')
const wasKilled = _killedWatchPids.delete(proc.pid)
if (!wasKilled) {
_rejectAllPending(
compileName,
Object.assign(new Error('typst watcher exited unexpectedly'), {
terminated: true,
})
)
}
if (WatchTable[compileName]?.proc === proc) {
delete WatchTable[compileName]
}
})
// typst watch performs an initial compile immediately on startup.
// _waitForNextCompile adds the resolver synchronously here (inside the
// Promise constructor) before we yield, so it will catch that first event.
return _waitForNextCompile(compileName, timeout + WATCH_START_TIMEOUT_MS)
}
function _killWatchEntry(compileName) {
const entry = WatchTable[compileName]
if (!entry) return
clearTimeout(entry.flushTimeout)
delete WatchTable[compileName]
try {
_killedWatchPids.add(entry.proc.pid)
process.kill(-entry.proc.pid) // kill entire process group
} catch (err) {
_killedWatchPids.delete(entry.proc.pid)
logger.warn({ err, compileName }, 'error killing typst watcher process group')
}
}
// ---------------------------------------------------------------------------
// Stdout parsing
// ---------------------------------------------------------------------------
function _onWatcherData(compileName, chunk) {
const entry = WatchTable[compileName]
if (!entry) return
entry.accumulator += chunk
const lines = entry.accumulator.split('\n')
entry.accumulator = lines.pop() // keep the incomplete trailing fragment
for (const line of lines) {
if (COMPILE_START_RE.test(line)) {
// A new compile cycle is starting. If we were in the post-done phase
// (collecting diagnostic lines that typst emits AFTER the status line),
// finalise the previous result now — all diagnostics have arrived.
if (entry.doneResult) {
_finalizeCompile(compileName)
}
// Start fresh for the new cycle.
entry.currentLines = [line]
continue
}
entry.currentLines.push(line)
if (entry.currentLines.length > MAX_LOG_LINES) {
entry.currentLines.shift()
}
if (FILE_ID_EXHAUSTION_RE.test(line)) {
logger.warn({ compileName }, 'typst watcher: FileId exhaustion detected')
entry.restartPending = true
}
if (COMPILE_DONE_RE.test(line)) {
entry.compilationCount++
if (entry.compilationCount >= MAX_COMPILES_BEFORE_RESTART) {
logger.info(
{ compileName, compilationCount: entry.compilationCount },
'typst watcher: scheduling restart (FileId threshold)'
)
entry.restartPending = true
}
// typst watch outputs the "[HH:MM:SS] compiled with errors" status
// line FIRST, then the full diagnostics (file:line:col, code snippets)
// AFTERWARDS. Enter post-done phase: keep accumulating into currentLines
// and flush after FLUSH_DELAY_MS (or immediately when the next compile
// cycle's COMPILE_START_RE arrives, whichever comes first).
entry.doneResult = {
preLines: entry.currentLines,
compiledWithErrors: /compiled with errors/.test(line),
}
entry.currentLines = []
clearTimeout(entry.flushTimeout)
entry.flushTimeout = setTimeout(
() => _finalizeCompile(compileName),
FLUSH_DELAY_MS
)
}
}
}
// Combines the pre-done lines (up to/including the status line) with any
// post-done diagnostic lines and resolves all pending waiters.
function _finalizeCompile(compileName) {
const entry = WatchTable[compileName]
if (!entry || !entry.doneResult) return
clearTimeout(entry.flushTimeout)
entry.flushTimeout = null
const { preLines, compiledWithErrors } = entry.doneResult
entry.doneResult = null
// Merge: status line(s) first, then the post-done diagnostics.
const allLines = preLines.concat(entry.currentLines)
entry.currentLines = []
_resolveAllPending(compileName, {
stdout: allLines.join('\n'),
compiledWithErrors,
})
}
// ---------------------------------------------------------------------------
// Resolver helpers
// ---------------------------------------------------------------------------
function _waitForNextCompile(compileName, timeout) {
return new Promise((resolve, reject) => {
const entry = WatchTable[compileName]
if (!entry) {
return reject(new Error('no typst watcher for ' + compileName))
}
// If typst finished a compile cycle before this resolver was registered
// (race: ResourceWriter wrote files → typst compiled → runTypst called),
// consume the cached result immediately instead of waiting for a timeout.
if (entry.pendingResult) {
const result = entry.pendingResult
entry.pendingResult = null
return resolve(result)
}
// Push synchronously inside the Promise constructor — before the first
// await in the caller, so no data event can fire in the gap.
const timeoutHandle = setTimeout(() => {
entry.pendingResolvers = entry.pendingResolvers.filter(r => r !== resolver)
reject(
Object.assign(new Error('typst compile timed out'), { timedout: true })
)
}, timeout)
const resolver = { resolve, reject, timeoutHandle }
entry.pendingResolvers.push(resolver)
})
}
function _resolveAllPending(compileName, result) {
const entry = WatchTable[compileName]
if (!entry) return
const resolvers = entry.pendingResolvers.splice(0)
if (resolvers.length === 0) {
// typst compiled before a resolver was registered — cache the result so
// the next _waitForNextCompile call can consume it immediately.
entry.pendingResult = result
return
}
for (const { resolve, timeoutHandle } of resolvers) {
clearTimeout(timeoutHandle)
resolve(result)
}
}
function _rejectAllPending(compileName, err) {
const entry = WatchTable[compileName]
if (!entry) return
for (const { reject, timeoutHandle } of entry.pendingResolvers.splice(0)) {
clearTimeout(timeoutHandle)
reject(err)
}
}
// ---------------------------------------------------------------------------
// Log output
// ---------------------------------------------------------------------------
async function _writeLogOutputAsync(compileName, directory, output) {
const content = (output && output.stdout) || ''
if (!content) return
// Write to output.log so the PDF-preview log panel picks it up.
const logFile = Path.join(directory, 'output.log')
try {
await fs.promises.unlink(logFile)
} catch (err) {
if (err.code !== 'ENOENT') {
logger.error({ err, compileName, logFile }, 'error removing typst log')
}
}
try {
await fs.promises.writeFile(logFile, content, { flag: 'wx' })
} catch (err) {
if (err.code !== 'EEXIST') {
logger.error({ err, compileName, logFile }, 'error writing typst log')
}
}
}
// ---------------------------------------------------------------------------
// Cold-start fallback (Docker / sandboxed mode)
// ---------------------------------------------------------------------------
function _runColdStart(compileName, options) {
return new Promise((resolve, reject) => {
const { directory, mainFile, image, environment, compileGroup } = options
const timeout = options.timeout || 60_000
logger.debug({ directory, mainFile, compileGroup }, 'typst cold-start compile')
const inputPath = `$COMPILE_DIR/${mainFile}`
const command = ['/bin/sh', '-c', `typst compile ${inputPath} output.pdf 2>&1`]
ProcessTable[compileName] = CommandRunner.run(
compileName,
command,
directory,
image,
timeout,
environment || {},
compileGroup,
null,
function (error, output) {
delete ProcessTable[compileName]
if (error && (error.terminated || error.timedout)) {
return reject(error)
}
const combined =
output || (error ? { stdout: error.stdout || '' } : null)
_writeLogOutputAsync(compileName, directory, combined).then(
() => {
if (error && combined?.stdout) {
// Non-zero exit with output = typst compile error (not a
// system/infra error). Signal failure so the log panel opens.
reject(
Object.assign(new Error('typst-compile-failure'), {
typstCompileFailure: true,
})
)
} else if (error) {
reject(error)
} else {
resolve(combined)
}
},
reject
)
}
)
})
}
// ---------------------------------------------------------------------------
// Public interface
// ---------------------------------------------------------------------------
function isRunning(compileName) {
return (
ProcessTable[compileName] != null ||
(WatchTable[compileName]?.pendingResolvers.length > 0)
)
}
function killTypst(compileName, callback) {
logger.debug({ compileName }, 'killing typst (watcher + any active compile)')
// Cold-start fallback path
if (ProcessTable[compileName] != null) {
CommandRunner.kill(ProcessTable[compileName], () => {})
delete ProcessTable[compileName]
}
// Reject any in-flight waiters and tear down the watcher process
_rejectAllPending(
compileName,
Object.assign(new Error('terminated'), { terminated: true })
)
_killWatchEntry(compileName)
callback(null)
}
// Kill all watcher processes when the CLSI Node process exits.
process.on('exit', () => {
for (const compileName of Object.keys(WatchTable)) {
_killWatchEntry(compileName)
}
})
const runTypst = (compileName, options, callback) => {
runTypstAsync(compileName, options).then(
result => callback(null, result),
err => callback(err)
)
}
export default {
isRunning,
runTypst,
killTypst,
promises: {
runTypst: runTypstAsync,
killTypst: promisify(killTypst),
},
}
+1 -1
View File
@@ -1,7 +1,7 @@
clsi
--data-dirs=cache,compiles,output
--dependencies=
--env-add=DOWNLOAD_HOST=http://clsi-nginx:8080,ALLOWED_COMPILE_GROUPS=clsi-perf simple-latex-file,ENABLE_PDF_CACHING=true,PDF_CACHING_ENABLE_WORKER_POOL=true,ALLOWED_IMAGES=quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1 quay.io/sharelatex/pandoc:3.9,TEXLIVE_IMAGE=quay.io/sharelatex/texlive-full:2025.1,TEX_LIVE_IMAGE_NAME_OVERRIDE=us-east1-docker.pkg.dev/overleaf-ops/ol-docker,TEXLIVE_IMAGE_USER=tex,SANDBOXED_COMPILES=true,SANDBOXED_COMPILES_HOST_DIR_COMPILES=$PWD/compiles,SANDBOXED_COMPILES_HOST_DIR_OUTPUT=$PWD/output,ENABLE_PANDOC_CONVERSIONS=true
--env-add=DOWNLOAD_HOST=http://clsi-nginx:8080,ALLOWED_COMPILE_GROUPS=clsi-perf simple-latex-file,ENABLE_PDF_CACHING=true,PDF_CACHING_ENABLE_WORKER_POOL=true,ALLOWED_IMAGES=quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1 quay.io/sharelatex/pandoc:3.9 quay.io/sharelatex/pdftocairo:24.02,TEXLIVE_IMAGE=quay.io/sharelatex/texlive-full:2025.1,TEX_LIVE_IMAGE_NAME_OVERRIDE=us-east1-docker.pkg.dev/overleaf-ops/ol-docker,TEXLIVE_IMAGE_USER=tex,SANDBOXED_COMPILES=true,SANDBOXED_COMPILES_HOST_DIR_COMPILES=$PWD/compiles,SANDBOXED_COMPILES_HOST_DIR_OUTPUT=$PWD/output,ENABLE_PANDOC_CONVERSIONS=true,ENABLE_PDF_CONVERSIONS=true
--env-pass-through=
--esmock-loader=False
--node-version=24.14.1
@@ -31,6 +31,9 @@ module.exports = {
parseInt(process.env.CLSI_CONVERSION_TIMEOUT_SECONDS, 10) || 60,
pandocImage: process.env.PANDOC_IMAGE || 'quay.io/sharelatex/pandoc:3.9',
enablePandocConversions: process.env.ENABLE_PANDOC_CONVERSIONS === 'true',
pdftocairoImage:
process.env.PDFTOCAIRO_IMAGE || 'quay.io/sharelatex/pdftocairo:24.02',
enablePdfConversions: process.env.ENABLE_PDF_CONVERSIONS === 'true',
maxUploadSize: 50 * 1024 * 1024,
internal: {
+2 -1
View File
@@ -30,7 +30,7 @@ services:
ALLOWED_COMPILE_GROUPS: clsi-perf simple-latex-file
ENABLE_PDF_CACHING: true
PDF_CACHING_ENABLE_WORKER_POOL: true
ALLOWED_IMAGES: quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1 quay.io/sharelatex/pandoc:3.9
ALLOWED_IMAGES: quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1 quay.io/sharelatex/pandoc:3.9 quay.io/sharelatex/pdftocairo:24.02
TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2025.1
TEX_LIVE_IMAGE_NAME_OVERRIDE: us-east1-docker.pkg.dev/overleaf-ops/ol-docker
TEXLIVE_IMAGE_USER: tex
@@ -38,6 +38,7 @@ services:
SANDBOXED_COMPILES_HOST_DIR_COMPILES: $PWD/compiles
SANDBOXED_COMPILES_HOST_DIR_OUTPUT: $PWD/output
ENABLE_PANDOC_CONVERSIONS: true
ENABLE_PDF_CONVERSIONS: true
volumes:
- ./reports:/overleaf/services/clsi/reports
- ./compiles:/overleaf/services/clsi/compiles
+2 -1
View File
@@ -53,7 +53,7 @@ services:
ALLOWED_COMPILE_GROUPS: clsi-perf simple-latex-file
ENABLE_PDF_CACHING: true
PDF_CACHING_ENABLE_WORKER_POOL: true
ALLOWED_IMAGES: quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1 quay.io/sharelatex/pandoc:3.9
ALLOWED_IMAGES: quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1 quay.io/sharelatex/pandoc:3.9 quay.io/sharelatex/pdftocairo:24.02
TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2025.1
TEX_LIVE_IMAGE_NAME_OVERRIDE: us-east1-docker.pkg.dev/overleaf-ops/ol-docker
TEXLIVE_IMAGE_USER: tex
@@ -61,6 +61,7 @@ services:
SANDBOXED_COMPILES_HOST_DIR_COMPILES: $PWD/compiles
SANDBOXED_COMPILES_HOST_DIR_OUTPUT: $PWD/output
ENABLE_PANDOC_CONVERSIONS: true
ENABLE_PDF_CONVERSIONS: true
depends_on:
clsi-nginx:
condition: service_started
+1 -1
View File
@@ -23,6 +23,7 @@
"@overleaf/promise-utils": "workspace:*",
"@overleaf/settings": "workspace:*",
"@overleaf/stream-utils": "workspace:*",
"@overleaf/validation-tools": "workspace:*",
"archiver": "5.3.2",
"async": "^3.2.5",
"body-parser": "1.20.4",
@@ -45,7 +46,6 @@
"mocha": "^11.1.0",
"mocha-junit-reporter": "^2.2.1",
"mocha-multi-reporters": "^1.5.1",
"mock-fs": "^5.1.2",
"node-fetch": "^2.7.0",
"nyc": "^17.1.0",
"sinon": "~9.0.1",
@@ -0,0 +1,83 @@
import Client from './helpers/Client.js'
import ClsiApp from './helpers/ClsiApp.js'
import Path from 'node:path'
import fs from 'node:fs/promises'
import { promisify } from 'node:util'
import { execFile as execFileCb } from 'node:child_process'
import { expect } from 'chai'
const execFile = promisify(execFileCb)
const FIXTURE_PDF = Path.join(import.meta.dirname, '../fixtures/minimal.pdf')
const MODE_EXPECTATIONS = {
preview: { width: 794 },
thumbnail: { width: 190 },
}
async function writeResponseToTempfile(response) {
const buffer = Buffer.from(await response.arrayBuffer())
const tmpPath = `/tmp/clsi-acceptance-pdf-to-jpeg-${crypto.randomUUID()}.jpg`
await fs.writeFile(tmpPath, buffer)
return { tmpPath, buffer }
}
describe('pdf-to-jpeg conversion', function () {
before(async function () {
await ClsiApp.ensureRunning()
})
for (const [mode, { width: expectedWidth }] of Object.entries(
MODE_EXPECTATIONS
)) {
describe(`with mode=${mode}`, function () {
let response
let tmpPath
let buffer
before(async function () {
response = await Client.convertPdfToJpeg(FIXTURE_PDF, mode)
expect(response.status).to.equal(200)
;({ tmpPath, buffer } = await writeResponseToTempfile(response))
})
after(async function () {
if (tmpPath) {
await fs.unlink(tmpPath).catch(() => {})
}
})
it('returns a JPEG (per `file`)', async function () {
const { stdout } = await execFile('file', ['--brief', tmpPath])
expect(stdout).to.match(/JPEG image data/)
})
it(`has the expected width of ${expectedWidth}px`, async function () {
const { stdout } = await execFile('identify', [
'-format',
'%w %h',
tmpPath,
])
const [width, height] = stdout.trim().split(' ').map(Number)
expect(width).to.equal(expectedWidth)
// A4 portrait is taller than wide; height must be positive and
// larger than the width (so the aspect ratio was preserved).
expect(height).to.be.greaterThan(width)
})
it('returns a non-empty body matching Content-Length', function () {
expect(buffer.length).to.be.greaterThan(0)
expect(buffer.length).to.equal(
Number(response.headers.get('content-length'))
)
})
})
}
describe('with an unsupported mode', function () {
it('returns 400', async function () {
const response = await Client.convertPdfToJpeg(FIXTURE_PDF, 'not-a-mode')
expect(response.status).to.equal(400)
})
})
})
@@ -53,6 +53,16 @@ async function convertDocument(path, type) {
}
}
async function convertPdfToJpeg(path, mode) {
const formData = new FormData()
formData.append('qqfile', await fsPromises.readFile(path), 'input.pdf')
return await fetch(`${host}/convert/pdf-to-jpeg?mode=${mode}`, {
method: 'POST',
headers: formData.getHeaders(),
body: formData.getBuffer(),
})
}
async function convertProjectToDocument(
projectId,
userId,
@@ -239,6 +249,7 @@ export default {
compile,
convertProjectToDocument,
convertDocument,
convertPdfToJpeg,
stopCompile,
clearCache,
getOutputFile,
@@ -18,6 +18,7 @@ describe('ConversionController', function () {
ctx.documentStat = { size: 5678 }
ctx.Settings = {
enablePandocConversions: true,
enablePdfConversions: true,
path: {
compilesDir: '/compiles',
outputDir: '/output',
@@ -591,6 +592,37 @@ describe('ConversionController', function () {
})
})
describe('with conversionType=html', function () {
beforeEach(async function (ctx) {
ctx.req.query = { type: 'html' }
ctx.fs.stat.resolves(ctx.documentStat)
await ctx.ConversionController.convertProjectToDocument(
ctx.req,
ctx.res,
sinon.stub()
)
})
it('should call convertLaTeXToDocumentInDirWithLock with type=html', function (ctx) {
sinon.assert.calledWith(
ctx.ConversionManager.promises.convertLaTeXToDocumentInDirWithLock,
sinon.match(
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
),
sinon.match(
/^\/compiles\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
),
'main.tex',
'html'
)
})
it('should set the attachment filename with .zip extension', function (ctx) {
sinon.assert.calledWith(ctx.res.attachment, 'output.zip')
})
})
describe('when conversion fails', function () {
beforeEach(async function (ctx) {
ctx.next = sinon.stub()
@@ -77,6 +77,24 @@ const LATEX_TO_DOCUMENT_CASES = [
'--extract-media=.',
],
},
{
type: 'html',
extension: 'html',
compressOutput: true,
pandocArgs: outputId => [
'pandoc',
Path.join('..', 'main.tex'),
'--output',
'main.html',
'--from',
'latex',
'--to',
'html',
'--standalone',
'--resource-path=..',
'--extract-media=.',
],
},
]
describe('ConversionManager', function () {
@@ -1,7 +1,8 @@
import { vi, expect, describe, beforeEach, afterEach, it } from 'vitest'
import Path from 'node:path'
import fs from 'node:fs'
import fsPromises from 'node:fs/promises'
import mockFs from 'mock-fs'
import os from 'node:os'
const MODULE_PATH = Path.join(
import.meta.dirname,
@@ -15,20 +16,19 @@ describe('DraftModeManager', () => {
}))
ctx.DraftModeManager = (await import(MODULE_PATH)).default
ctx.filename = '/mock/filename.tex'
ctx.tmpDir = fs.mkdtempSync(Path.join(os.tmpdir(), 'draft-mode-test-'))
ctx.filename = Path.join(ctx.tmpDir, 'filename.tex')
ctx.contents = `\
\\documentclass{article}
\\begin{document}
Hello world
\\end{document}\
`
mockFs({
[ctx.filename]: ctx.contents,
})
fs.writeFileSync(ctx.filename, ctx.contents)
})
afterEach(() => {
mockFs.restore()
afterEach(ctx => {
fs.rmSync(ctx.tmpDir, { recursive: true })
})
describe('injectDraftMode', () => {
@@ -1,6 +1,6 @@
import sinon from 'sinon'
import { expect, describe, beforeEach, afterEach, it } from 'vitest'
import mockFs from 'mock-fs'
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
const modulePath = path.join(
@@ -8,30 +8,40 @@ const modulePath = path.join(
'../../../app/js/OutputFileFinder'
)
function createTree(base, tree) {
fs.mkdirSync(base, { recursive: true })
for (const [name, content] of Object.entries(tree)) {
const fullPath = path.join(base, name)
if (Buffer.isBuffer(content) || typeof content === 'string') {
fs.writeFileSync(fullPath, content)
} else if (content && content.symlink) {
fs.symlinkSync(content.symlink, fullPath)
} else {
createTree(fullPath, content)
}
}
}
describe('OutputFileFinder', function () {
beforeEach(async function (ctx) {
ctx.OutputFileFinder = (await import(modulePath)).default
ctx.directory = '/test/dir'
ctx.callback = sinon.stub()
mockFs({
[ctx.directory]: {
resource: {
'path.tex': 'a source file',
},
'output.pdf': 'a generated pdf file',
extra: {
'file.tex': 'a generated tex file',
},
'sneaky-file': mockFs.symlink({
path: '../foo',
}),
ctx.directory = fs.mkdtempSync(
path.join(os.tmpdir(), 'output-finder-test-')
)
createTree(ctx.directory, {
resource: {
'path.tex': 'a source file',
},
'output.pdf': 'a generated pdf file',
extra: {
'file.tex': 'a generated tex file',
},
'sneaky-file': { symlink: '../foo' },
})
})
afterEach(function () {
mockFs.restore()
afterEach(function (ctx) {
fs.rmSync(ctx.directory, { recursive: true })
})
describe('findOutputFiles', function () {
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+6 -2
View File
@@ -56,6 +56,10 @@ COMPOSE_PROJECT_NAME_TEST_UNIT ?= test_unit_$(BUILD_DIR_NAME)
DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_TEST_UNIT) $(DOCKER_COMPOSE)
.PHONY: print-branch-tag-safe
print-branch-tag-safe:
@echo $(BRANCH_NAME_TAG_SAFE)
clean:
-docker rmi $(IMAGE_CI)
-docker rmi $(IMAGE_REPO_FINAL)
@@ -68,8 +72,8 @@ clean:
RUN_LINTING = ../../bin/run -w /overleaf/services/$(PROJECT_NAME) monorepo yarn run --silent
RUN_LINTING_MONOREPO = ../../bin/run monorepo yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/docstore/reports:/overleaf/services/docstore/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/docstore/reports:/overleaf/services/docstore/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/docstore/reports:/overleaf/services/docstore/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/docstore/reports:/overleaf/services/docstore/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
SHELLCHECK_OPTS = \
--shell=bash \
+1
View File
@@ -1,5 +1,6 @@
docstore
--dependencies=mongo,gcs
--deploy-pipeline=docstore
--env-add=
--env-pass-through=
--esmock-loader=False
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+6 -2
View File
@@ -57,6 +57,10 @@ COMPOSE_PROJECT_NAME_TEST_UNIT ?= test_unit_$(BUILD_DIR_NAME)
DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_TEST_UNIT) $(DOCKER_COMPOSE)
.PHONY: print-branch-tag-safe
print-branch-tag-safe:
@echo $(BRANCH_NAME_TAG_SAFE)
clean:
-docker rmi $(IMAGE_CI)
-docker rmi $(IMAGE_REPO_FINAL)
@@ -69,8 +73,8 @@ clean:
RUN_LINTING = ../../bin/run -w /overleaf/services/$(PROJECT_NAME) monorepo yarn run --silent
RUN_LINTING_MONOREPO = ../../bin/run monorepo yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/document-updater/reports:/overleaf/services/document-updater/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/document-updater/reports:/overleaf/services/document-updater/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/document-updater/reports:/overleaf/services/document-updater/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/document-updater/reports:/overleaf/services/document-updater/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
SHELLCHECK_OPTS = \
--shell=bash \
@@ -1,5 +1,6 @@
document-updater
--dependencies=mongo,redis
--deploy-pipeline=document-updater
--env-add=
--env-pass-through=
--esmock-loader=False
+3
View File
@@ -0,0 +1,3 @@
declare module 'mongodb-legacy' {
export * from 'mongodb'
}
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+6 -2
View File
@@ -53,6 +53,10 @@ COMPOSE_PROJECT_NAME_TEST_UNIT ?= test_unit_$(BUILD_DIR_NAME)
DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_TEST_UNIT) $(DOCKER_COMPOSE)
.PHONY: print-branch-tag-safe
print-branch-tag-safe:
@echo $(BRANCH_NAME_TAG_SAFE)
clean:
-docker rmi $(IMAGE_CI)
-docker rmi $(IMAGE_REPO_FINAL)
@@ -66,8 +70,8 @@ clean:
RUN_LINTING = ../../bin/run -w /overleaf/services/$(PROJECT_NAME) monorepo yarn run --silent
RUN_LINTING_MONOREPO = ../../bin/run monorepo yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/filestore/reports:/overleaf/services/filestore/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/filestore/reports:/overleaf/services/filestore/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/filestore/reports:/overleaf/services/filestore/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/filestore/reports:/overleaf/services/filestore/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
SHELLCHECK_OPTS = \
--shell=bash \
+1
View File
@@ -1,6 +1,7 @@
filestore
--data-dirs=uploads,template_files
--dependencies=s3,gcs
--deploy-pipeline=filestore-readonly
--env-add=ENABLE_CONVERSIONS=true,USE_PROM_METRICS=true,AWS_S3_USER_FILES_STORAGE_CLASS=REDUCED_REDUNDANCY,AWS_S3_USER_FILES_BUCKET_NAME=fake-user-files,AWS_S3_USER_FILES_DEK_BUCKET_NAME=fake-user-files-dek,AWS_S3_TEMPLATE_FILES_BUCKET_NAME=fake-template-files,GCS_USER_FILES_BUCKET_NAME=fake-gcs-user-files,GCS_TEMPLATE_FILES_BUCKET_NAME=fake-gcs-template-files
--env-pass-through=
--esmock-loader=False
+4
View File
@@ -15,6 +15,10 @@ IMAGE_REPO_BRANCH ?= $(IMAGE_REPO):$(BRANCH_NAME_TAG_SAFE)
IMAGE_REPO_MAIN ?= $(IMAGE_REPO):main
IMAGE_REPO_FINAL ?= $(IMAGE_REPO_BRANCH)-$(BUILD_NUMBER)
.PHONY: print-branch-tag-safe
print-branch-tag-safe:
@echo $(BRANCH_NAME_TAG_SAFE)
runtime-conf:
/opt/envsubst < conf/envsubst_template.json > conf/runtime.json
@@ -5,6 +5,10 @@ import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -107,15 +111,18 @@ public class Oauth2Filter implements Filter {
// fail later (for example, in the unlikely event that the token
// expired between the two requests). In that case, JGit will
// return a 401 without a custom error message.
int statusCode = checkAccessToken(this.oauth2Server, password, getClientIp(request));
if (statusCode == 429) {
AccessTokenCheck check = checkAccessToken(this.oauth2Server, password, getClientIp(request));
if (check.statusCode == 429) {
handleRateLimit(projectId, username, request, response);
return;
} else if (statusCode == 401) {
} else if (check.statusCode == 401 && "token_expired".equals(check.errorCode)) {
handleExpiredAccessToken(projectId, request, response);
return;
} else if (check.statusCode == 401) {
handleBadAccessToken(projectId, request, response);
return;
} else if (statusCode >= 400) {
handleUnknownOauthServerError(projectId, statusCode, request, response);
} else if (check.statusCode >= 400) {
handleUnknownOauthServerError(projectId, check.statusCode, request, response);
return;
}
cred.setAccessToken(password);
@@ -229,8 +236,52 @@ public class Oauth2Filter implements Filter {
"https://www.overleaf.com/learn/how-to/Git_integration"));
}
private int checkAccessToken(String oauth2Server, String accessToken, String clientIp)
private void handleExpiredAccessToken(
String projectId, HttpServletRequest request, HttpServletResponse response)
throws IOException {
Log.debug("[{}] Expired access token, ip={}", projectId, getClientIp(request));
sendResponse(
response,
401,
Arrays.asList(
"Your Overleaf Git authentication token has expired.",
"",
"Generate a new authentication token in your Overleaf Account Settings,",
"then run the git command again."));
}
static class AccessTokenCheck {
final int statusCode;
final String errorCode;
AccessTokenCheck(int statusCode, String errorCode) {
this.statusCode = statusCode;
this.errorCode = errorCode;
}
}
static String parseErrorCode(String body) {
if (body == null || body.isEmpty()) {
return null;
}
try {
JsonElement element = new Gson().fromJson(body, JsonElement.class);
if (element == null || !element.isJsonObject()) {
return null;
}
JsonObject obj = element.getAsJsonObject();
JsonElement codeElement = obj.get("error_code");
if (codeElement == null || codeElement.isJsonNull()) {
return null;
}
return codeElement.getAsString();
} catch (JsonSyntaxException | UnsupportedOperationException e) {
return null;
}
}
private AccessTokenCheck checkAccessToken(
String oauth2Server, String accessToken, String clientIp) throws IOException {
GenericUrl url = new GenericUrl(oauth2Server + "/oauth/token/info?client_ip=" + clientIp);
HttpRequest request = Instance.httpRequestFactory.buildGetRequest(url);
HttpHeaders headers = new HttpHeaders();
@@ -239,8 +290,12 @@ public class Oauth2Filter implements Filter {
request.setThrowExceptionOnExecuteError(false);
HttpResponse response = request.execute();
int statusCode = response.getStatusCode();
String errorCode = null;
if (statusCode >= 400 && statusCode < 500) {
errorCode = parseErrorCode(response.parseAsString());
}
response.disconnect();
return statusCode;
return new AccessTokenCheck(statusCode, errorCode);
}
private void handleUnknownOauthServerError(
@@ -0,0 +1,51 @@
package uk.ac.ic.wlgitbridge.server;
import org.junit.Assert;
import org.junit.Test;
public class Oauth2FilterTest {
@Test
public void parseErrorCode_returnsTokenExpired_whenBodyContainsIt() {
String body = "{\"error\":\"invalid_token\",\"error_code\":\"token_expired\"}";
Assert.assertEquals("token_expired", Oauth2Filter.parseErrorCode(body));
}
@Test
public void parseErrorCode_returnsTokenInvalid_whenBodyContainsIt() {
String body = "{\"error\":\"invalid_token\",\"error_code\":\"token_invalid\"}";
Assert.assertEquals("token_invalid", Oauth2Filter.parseErrorCode(body));
}
@Test
public void parseErrorCode_returnsNull_whenErrorCodeFieldIsMissing() {
String body = "{\"error\":\"invalid_token\"}";
Assert.assertNull(Oauth2Filter.parseErrorCode(body));
}
@Test
public void parseErrorCode_returnsNull_whenBodyIsNull() {
Assert.assertNull(Oauth2Filter.parseErrorCode(null));
}
@Test
public void parseErrorCode_returnsNull_whenBodyIsEmpty() {
Assert.assertNull(Oauth2Filter.parseErrorCode(""));
}
@Test
public void parseErrorCode_returnsNull_whenBodyIsNotJson() {
Assert.assertNull(Oauth2Filter.parseErrorCode("not json at all"));
}
@Test
public void parseErrorCode_returnsNull_whenBodyIsJsonArray() {
Assert.assertNull(Oauth2Filter.parseErrorCode("[1, 2, 3]"));
}
@Test
public void parseErrorCode_returnsNull_whenErrorCodeFieldIsJsonNull() {
String body = "{\"error\":\"invalid_token\",\"error_code\":null}";
Assert.assertNull(Oauth2Filter.parseErrorCode(body));
}
}
-2
View File
@@ -1,2 +0,0 @@
archive/
+1 -1
View File
@@ -1,7 +1,7 @@
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporter: '/overleaf/node_modules/mocha-multi-reporters',
reporter: require.resolve('mocha-multi-reporters'),
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
}
}
+6 -2
View File
@@ -59,6 +59,10 @@ COMPOSE_PROJECT_NAME_TEST_UNIT ?= test_unit_$(BUILD_DIR_NAME)
DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_TEST_UNIT) $(DOCKER_COMPOSE)
.PHONY: print-branch-tag-safe
print-branch-tag-safe:
@echo $(BRANCH_NAME_TAG_SAFE)
clean:
-docker rmi $(IMAGE_CI)
-docker rmi $(IMAGE_REPO_FINAL)
@@ -71,8 +75,8 @@ clean:
RUN_LINTING = ../../bin/run -w /overleaf/services/$(PROJECT_NAME) monorepo yarn run --silent
RUN_LINTING_MONOREPO = ../../bin/run monorepo yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/history-v1/reports:/overleaf/services/history-v1/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/history-v1/reports:/overleaf/services/history-v1/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/history-v1/reports:/overleaf/services/history-v1/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/eslint.config.mjs:/overleaf/eslint.config.mjs --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc.cjs:/overleaf/.prettierrc.cjs --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/history-v1/reports:/overleaf/services/history-v1/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
SHELLCHECK_OPTS = \
--shell=bash \
+1
View File
@@ -1,5 +1,6 @@
history-v1
--dependencies=postgres,gcs,mongo,redis,s3
--deploy-pipeline=history-v1
--env-add=
--env-pass-through=
--esmock-loader=False
+1 -1
View File
@@ -109,7 +109,7 @@ services:
- mongo:127.0.0.1
postgres:
image: postgres:10
image: postgres:14
environment:
POSTGRES_USER: overleaf
POSTGRES_PASSWORD: overleaf
+1 -1
View File
@@ -124,7 +124,7 @@ services:
- mongo:127.0.0.1
postgres:
image: postgres:10
image: postgres:14
environment:
POSTGRES_USER: overleaf
POSTGRES_PASSWORD: overleaf
+2 -1
View File
@@ -44,7 +44,8 @@
"temp": "^0.8.3",
"throng": "^4.0.0",
"tsscmp": "^1.0.6",
"utf-8-validate": "^5.0.4"
"utf-8-validate": "^5.0.4",
"zip-stream": "^7.0.2"
},
"devDependencies": {
"@overleaf/migrations": "workspace:*",
@@ -185,13 +185,30 @@ class BackupBlobStore {
*/
/**
* @typedef {(import('archiver').Archiver)} Archiver
* @typedef {(import('zip-stream').default)} ZipStream
*/
/**
* @typedef {(import('overleaf-editor-core').FileMap)} FileMap
*/
/**
* Promisified wrapper for ZipStream's entry method.
*
* @param {ZipStream} archive
* @param {Buffer|NodeJS.ReadableStream|string} source
* @param {{ name: string }} data
* @return {Promise<void>}
*/
function addEntry(archive, source, data) {
return new Promise((resolve, reject) => {
archive.entry(source, data, err => {
if (err) reject(err)
else resolve()
})
})
}
/**
*
* @param historyId
@@ -254,14 +271,15 @@ async function fetchBlob(historyId, hash, persistor) {
/**
* @typedef {object} AddChunkOptions
* @property {string} [prefix] Should include trailing slash (if length > 0)
* @property {string} [prefix]
* @property {boolean} [useBackupGlobalBlobs]
* @property {boolean} [verbose]
*/
/**
*
* @param {History} history
* @param {Archiver} archive
* @param {ZipStream} archive
* @param {CachedPerProjectEncryptedS3Persistor} projectCache
* @param {string} historyId
* @param {AddChunkOptions} [options]
@@ -272,7 +290,7 @@ async function addChunkToArchive(
archive,
projectCache,
historyId,
{ prefix = '', useBackupGlobalBlobs = false } = {}
{ prefix = '', useBackupGlobalBlobs = false, verbose = false } = {}
) {
const chunkBlobs = new Set()
history.findBlobHashes(chunkBlobs)
@@ -334,9 +352,16 @@ async function addChunkToArchive(
}
content = await blobStore.getStream(hash)
}
archive.append(content, {
if (content == null) {
logger.error({ filePath }, 'File content is empty')
continue
}
await addEntry(archive, content, {
name: `${prefix}${filePath}`,
})
if (verbose) {
logger.info({ filePath: `${prefix}${filePath}` }, 'added to archive')
}
}
})
}
@@ -358,17 +383,20 @@ async function findStartVersionOfLatestChunk(historyId) {
/**
* Restore a project from the latest snapshot
*
* There is an assumption that the database backup has been restored.
* There is an assumption that the database backup
* has been restored.
*
* @param {Archiver} archive
* @param {ZipStream} archive
* @param {string} historyId
* @param {boolean} [useBackupGlobalBlobs]
* @param {boolean} [verbose]
* @return {Promise<void>}
*/
export async function archiveLatestChunk(
archive,
historyId,
useBackupGlobalBlobs = false
useBackupGlobalBlobs = false,
verbose = false
) {
logger.info({ historyId, useBackupGlobalBlobs }, 'Archiving latest chunk')
@@ -386,20 +414,28 @@ export async function archiveLatestChunk(
await addChunkToArchive(backedUpChunk, archive, projectCache, historyId, {
useBackupGlobalBlobs,
verbose,
})
return archive
}
/**
* Fetches all raw blobs from the project and adds them to the archive.
* Fetches all raw blobs from the project and adds
* them to the archive.
*
* @param {string} historyId
* @param {Archiver} archive
* @param {ZipStream} archive
* @param {CachedPerProjectEncryptedS3Persistor} projectCache
* @param {boolean} [verbose]
* @return {Promise<void>}
*/
async function addRawBlobsToArchive(historyId, archive, projectCache) {
async function addRawBlobsToArchive(
historyId,
archive,
projectCache,
verbose = false
) {
const blobKeys = await projectCache.listDirectoryKeys(
projectBlobsBucket,
projectKey.format(historyId)
@@ -411,9 +447,13 @@ async function addRawBlobsToArchive(historyId, archive, projectCache) {
key,
{ autoGunzip: true }
)
archive.append(stream, {
name: path.join(historyId, 'blobs', key),
const entryName = path.join(historyId, 'blobs', key)
await addEntry(archive, stream, {
name: entryName,
})
if (verbose) {
logger.info({ entryName }, 'added to archive')
}
} catch (err) {
logger.warn({ err, path: key }, 'Failed to append blob to archive')
}
@@ -425,17 +465,20 @@ async function addRawBlobsToArchive(historyId, archive, projectCache) {
*
* This can work without the database being backed up.
*
* It will split the project into chunks per directory and download the blobs alongside the chunk.
* It will split the project into chunks per directory
* and download the blobs alongside the chunk.
*
* @param {Archiver} archive
* @param {ZipStream} archive
* @param {string} historyId
* @param {boolean} [useBackupGlobalBlobs]
* @param {boolean} [verbose]
* @return {Promise<void>}
*/
export async function archiveRawProject(
archive,
historyId,
useBackupGlobalBlobs = false
useBackupGlobalBlobs = false,
verbose = false
) {
const projectCache = await getProjectPersistor(historyId)
@@ -454,11 +497,15 @@ export async function archiveRawProject(
const { buffer } = await loadChunkByKey(projectCache, key)
archive.append(buffer, {
name: `${historyId}/chunks/${chunkId}/chunk.json`,
const entryName = `${historyId}/chunks/${chunkId}/chunk.json`
await addEntry(archive, buffer, {
name: entryName,
})
if (verbose) {
logger.info({ entryName }, 'added to archive')
}
}
await addRawBlobsToArchive(historyId, archive, projectCache)
await addRawBlobsToArchive(historyId, archive, projectCache, verbose)
}
export class BackupPersistorError extends OError {}
+4 -4
View File
@@ -6,19 +6,19 @@
*/
'use strict'
const Stream = require('node:stream')
const { pipeline } = require('node:stream/promises')
const zlib = require('node:zlib')
const { WritableBuffer } = require('@overleaf/stream-utils')
/**
* Create a promise for the result of reading a stream to a buffer.
*
* @param {Stream.Readable} readStream
* @param {import('node:stream').Readable} readStream
* @return {Promise<Buffer>}
*/
async function readStreamToBuffer(readStream) {
const bufferStream = new WritableBuffer()
await Stream.promises.pipeline(readStream, bufferStream)
await pipeline(readStream, bufferStream)
return bufferStream.contents()
}
@@ -33,7 +33,7 @@ exports.readStreamToBuffer = readStreamToBuffer
async function gunzipStreamToBuffer(readStream) {
const gunzip = zlib.createGunzip()
const bufferStream = new WritableBuffer()
await Stream.promises.pipeline(readStream, gunzip, bufferStream)
await pipeline(readStream, gunzip, bufferStream)
return bufferStream.contents()
}
@@ -19,7 +19,7 @@ const LAG_TIME_BUCKETS_HRS = [
] // hours
// Configure backup settings to match worker concurrency
configureBackup({ concurrency: UPLOAD_CONCURRENCY, useSecondary: true })
configureBackup({ concurrency: UPLOAD_CONCURRENCY })
let gracefulShutdownInitiated = false
@@ -0,0 +1,129 @@
// Finalise the current chunk for a project and start a new empty chunk
// whose starting snapshot is the end snapshot of the (now-closed) current
// chunk.
//
// This is intended as a recovery tool for projects whose current chunk has
// become corrupted in such a way that further changes can no longer be
// persisted, but where the end snapshot of the current chunk can still be
// computed.
import logger from '@overleaf/logger'
import commandLineArgs from 'command-line-args'
import { Change, Chunk, History, NoOperation } from 'overleaf-editor-core'
import * as redis from '../lib/redis.js'
import knex from '../lib/knex.js'
import knexReadOnly from '../lib/knex_read_only.js'
import { client as mongoClient } from '../lib/mongodb.js'
import chunkStore from '../lib/chunk_store/index.js'
import redisBackend from '../lib/chunk_store/redis.js'
import { loadGlobalBlobs } from '../lib/blob_store/index.js'
import { fileURLToPath } from 'node:url'
import { EventEmitter } from 'node:events'
EventEmitter.defaultMaxListeners = 20
logger.initialize('finalise-chunk')
const optionDefinitions = [
{ name: 'historyId', type: String },
{ name: 'dry-run', alias: 'd', type: Boolean },
]
const options = commandLineArgs(optionDefinitions)
const HISTORY_ID = options.historyId
const DRY_RUN = options['dry-run'] || false
if (!HISTORY_ID) {
console.error('Usage: finalise_chunk.mjs --historyId <id> [--dry-run]')
process.exit(2)
}
async function finaliseCurrentChunk(historyId) {
// Validates the history id and selects the backend (postgres or mongo).
chunkStore.getBackend(historyId)
await loadGlobalBlobs()
const currentChunk = await chunkStore.loadLatest(historyId, {
persistedOnly: true,
})
const startVersion = currentChunk.getStartVersion()
const endVersion = currentChunk.getEndVersion()
const numChanges = currentChunk.getChanges().length
logger.info(
{ historyId, startVersion, endVersion, numChanges },
'loaded current chunk'
)
if (endVersion === startVersion) {
throw new Error(
`current chunk for history ${historyId} is already empty (no changes); refusing to create another empty chunk`
)
}
let nonPersistedChanges
try {
nonPersistedChanges = await redisBackend.getNonPersistedChanges(
historyId,
endVersion
)
} catch (err) {
throw new Error(
`unable to read non-persisted changes from redis for history ${historyId}: ${err.message}`
)
}
if (nonPersistedChanges.length > 0) {
throw new Error(
`history ${historyId} has ${nonPersistedChanges.length} non-persisted change(s) in redis; persist or expire them before running this script`
)
}
const endSnapshot = currentChunk.getSnapshot().clone()
endSnapshot.applyAll(currentChunk.getChanges())
// The chunks table has a unique constraint on (doc_id, end_version), so the
// new chunk cannot share an end_version with the chunk we are closing. Add a
// single NoOperation change to bump end_version by 1 without mutating the
// snapshot.
const recoveryChange = new Change([new NoOperation()], new Date(), [])
const newChunk = new Chunk(
new History(endSnapshot, [recoveryChange]),
endVersion
)
if (DRY_RUN) {
logger.info(
{ historyId, endVersion },
'dry run: would close current chunk and create new empty chunk'
)
return
}
await chunkStore.create(historyId, newChunk)
logger.info(
{ historyId, endVersion },
'closed current chunk and created new empty chunk'
)
}
async function main() {
try {
await finaliseCurrentChunk(HISTORY_ID)
} catch (err) {
logger.fatal({ err, historyId: HISTORY_ID }, 'failed to finalise chunk')
process.exitCode = 1
} finally {
await redis.disconnect()
await mongoClient.close()
await knex.destroy()
await knexReadOnly.destroy()
}
}
const currentScriptPath = fileURLToPath(import.meta.url)
if (process.argv[1] === currentScriptPath) {
main()
}
export { finaliseCurrentChunk }
@@ -17,9 +17,10 @@ const fs = require('node:fs')
const os = require('node:os')
const path = require('node:path')
const util = require('node:util')
const { pipeline } = require('node:stream/promises')
// Something is registering 11 listeners, over the limit of 10, which generates
// a lot of warning noise.
// Something is registering 11 listeners, over the limit
// of 10, which generates a lot of warning noise.
require('node:events').EventEmitter.defaultMaxListeners = 11
const config = require('config')
@@ -27,11 +28,23 @@ const config = require('config')
// eslint-disable-next-line import/no-extraneous-dependencies
const { Storage } = require('@google-cloud/storage')
const isValidUtf8 = require('utf-8-validate')
// zip-stream@7 uses ESM default export
const ZipStream = require('zip-stream').default
function createStorage() {
const opts = {}
if (config.has('persistor.gcs.endpoint.apiEndpoint')) {
opts.apiEndpoint = config.get('persistor.gcs.endpoint.apiEndpoint')
}
if (config.has('persistor.gcs.endpoint.projectId')) {
opts.projectId = config.get('persistor.gcs.endpoint.projectId')
}
return new Storage(opts)
}
const core = require('overleaf-editor-core')
const projectKey = require('@overleaf/object-persistor/src/ProjectKey.js')
const streams = require('../lib/streams')
const ProjectArchive = require('../lib/project_archive')
const {
values: { verbose: VERBOSE },
@@ -53,7 +66,7 @@ if (HISTORY_IDS.length === 0) {
async function listDeletedChunks(historyId) {
const bucketName = config.get('chunkStore.bucket')
const storage = new Storage()
const storage = createStorage()
const [files] = await storage.bucket(bucketName).getFiles({
prefix: projectKey.format(historyId),
versions: true,
@@ -137,7 +150,7 @@ class RecoveryBlobStore {
if (VERBOSE) console.log('fetching blob', hash)
const bucketName = config.get('blobStore.projectBucket')
const storage = new Storage()
const storage = createStorage()
const [files] = await storage.bucket(bucketName).getFiles({
prefix: this.makeProjectBlobKey(hash),
versions: true,
@@ -158,7 +171,7 @@ class RecoveryBlobStore {
async fetchGlobalBlob(hash, destination) {
const bucketName = config.get('blobStore.globalBucket')
const storage = new Storage()
const storage = createStorage()
const file = storage.bucket(bucketName).file(this.makeGlobalBlobKey(hash))
await file.download({ destination })
}
@@ -203,9 +216,18 @@ class RecoveryBlobStore {
async function uploadZip(historyId, zipPathname) {
const bucketName = config.get('zipStore.bucket')
const deadline = 24 * 3600 * 1000 // lifecycle limit on the zips bucket
const storage = new Storage()
const storage = createStorage()
const destination = `${historyId}-recovered.zip`
await storage.bucket(bucketName).upload(zipPathname, { destination })
await storage.bucket(bucketName).upload(zipPathname, {
destination,
resumable: false,
})
if (config.has('persistor.gcs.endpoint.apiEndpoint')) {
// In emulator mode, signed URLs aren't available
const apiEndpoint = config.get('persistor.gcs.endpoint.apiEndpoint')
return `${apiEndpoint}/storage/v1/b/${bucketName}/o/${encodeURIComponent(destination)}?alt=media`
}
const signedUrls = await storage
.bucket(bucketName)
@@ -219,6 +241,23 @@ async function uploadZip(historyId, zipPathname) {
return signedUrls[0]
}
/**
* Promisified wrapper for ZipStream's entry method.
*
* @param {ZipStream} archive
* @param {Buffer|NodeJS.ReadableStream|string} source
* @param {{ name: string }} data
* @return {Promise<void>}
*/
function addEntry(archive, source, data) {
return new Promise((resolve, reject) => {
archive.entry(source, data, err => {
if (err) reject(err)
else resolve()
})
})
}
async function restoreProject(historyId) {
const tmp = await fs.promises.mkdtemp(
path.join(os.tmpdir(), historyId.toString())
@@ -237,9 +276,40 @@ async function restoreProject(historyId) {
if (VERBOSE) console.log('zipping', historyId)
const zipPathname = path.join(tmp, `${historyId}.zip`)
const zipTimeoutMs = 60 * 1000
const archive = new ProjectArchive(snapshot, zipTimeoutMs)
await archive.writeZip(blobStore, zipPathname)
const outputFile = fs.createWriteStream(zipPathname)
const archive = new ZipStream()
const pipelinePromise = pipeline(archive, outputFile)
for (const pathname of snapshot.getFilePathnames()) {
const file = snapshot.getFile(pathname)
if (!file) continue
await file.load('eager', blobStore)
let content = file.getContent({
filterTrackedDeletes: true,
})
if (content === null) {
const hash = file.getHash()
content = await blobStore.getStream(hash)
}
if (content == null) continue
if (typeof content === 'string') {
content = Buffer.from(content)
}
await addEntry(archive, content, { name: pathname })
if (VERBOSE) console.log(`${pathname} added`)
}
archive.finalize()
await pipelinePromise
if (VERBOSE) {
console.log(`Wrote ${archive.getBytesWritten()} bytes`)
}
if (VERBOSE) console.log('uploading', historyId)
@@ -252,4 +322,7 @@ async function main() {
console.log(signedUrl)
}
}
main().catch(console.error)
main().catch(err => {
console.error(err)
process.exit(1)
})
@@ -4,6 +4,7 @@ import commandLineArgs from 'command-line-args'
import assert from '../lib/assert.js'
import fs from 'node:fs'
import { setTimeout } from 'node:timers/promises'
import { pipeline } from 'node:stream/promises'
import {
archiveLatestChunk,
archiveRawProject,
@@ -11,17 +12,13 @@ import {
} from '../lib/backupArchiver.mjs'
import knex from '../lib/knex.js'
import { client } from '../lib/mongodb.js'
import archiver from 'archiver'
import Events from 'node:events'
import ZipStream from 'zip-stream'
import { Chunk } from 'overleaf-editor-core'
import _ from 'lodash'
// Silence warning.
Events.setMaxListeners(20)
const SUPPORTED_MODES = ['raw', 'latest']
// Pads the mode name to a fixed length for better alignment in output.
// Pads the mode name to a fixed length for alignment.
const padModeName = _.partialRight(
_.padEnd,
Math.max(...SUPPORTED_MODES.map(mode => mode.length))
@@ -65,25 +62,6 @@ function usage() {
})
}
/**
* @typedef {import('archiver').ZipArchive} ZipArchive
*/
/**
* @typedef {import('archiver').ProgressData} ProgressData
*/
/**
* @typedef {import('archiver').EntryData} EntryData
*/
/**
* @typedef {Object} ArchiverError
* @property {string} message
* @property {string} code
* @property {Object} data
*/
let historyId, help, mode, output, useBackupGlobalBlobs, verbose
try {
@@ -136,80 +114,37 @@ await loadGlobalBlobs()
outputFile = fs.createWriteStream(output)
const archive = archiver.create('zip', {})
const archive = new ZipStream()
archive.on('close', function () {
console.log(archive.pointer() + ' total bytes')
console.log(`Wrote ${output}`)
shutdown().catch(e => console.error('Error shutting down', e))
archive.on('error', function (e) {
console.error(`Error writing archive: ${e.message}`)
})
archive.on(
'error',
/**
*
* @param {ArchiverError} e
*/
function (e) {
console.error(`Error writing archive: ${e.message}`)
}
)
archive.on('end', function () {
console.log(`Wrote ${archive.pointer()} total bytes to ${output}`)
shutdown().catch(e => console.error('Error shutting down', e))
})
archive.on(
'progress',
/**
*
* @param {ProgressData} progress
*/
function (progress) {
if (verbose) {
console.log(
`${progress.entries.processed} processed out of ${progress.entries.total}`
)
}
}
)
archive.on(
'entry',
/**
*
* @param {EntryData} entry
*/
function (entry) {
if (verbose) {
console.log(`${entry.name} added`)
}
}
)
archive.on(
'warning',
/**
*
* @param {ArchiverError} warning
*/
function (warning) {
console.warn(`Warning encountered when writing archive: ${warning.message}`)
}
)
try {
// Pipe archive to the output file before adding entries.
// pipeline handles backpressure and will resolve when
// the archive stream ends.
const pipelinePromise = pipeline(archive, outputFile)
switch (mode) {
case 'latest':
await archiveLatestChunk(archive, historyId, useBackupGlobalBlobs)
await archiveLatestChunk(
archive,
historyId,
useBackupGlobalBlobs,
verbose
)
break
case 'raw':
default:
await archiveRawProject(archive, historyId, useBackupGlobalBlobs)
await archiveRawProject(archive, historyId, useBackupGlobalBlobs, verbose)
break
}
archive.pipe(outputFile)
archive.finalize()
await pipelinePromise
console.log(`Wrote ${archive.getBytesWritten()} total bytes to ${output}`)
} catch (error) {
if (error instanceof BackupPersistorError) {
console.error(error.message)
@@ -222,12 +157,7 @@ try {
} else {
console.error('Error encountered when writing archive')
}
} finally {
await Promise.race([
await archive.finalize(),
setTimeout(10000).then(() => {
console.error('Archive did not finalize in time')
return shutdown(1)
}),
])
await shutdown(1)
}
await shutdown(0)
@@ -507,7 +507,7 @@ describe('project controller', function () {
})
})
// eslint-disable-next-line mocha/no-skipped-tests
// eslint-disable-next-line mocha/no-pending-tests
describe.skip('getLatestContent', function () {
// TODO: remove this endpoint entirely, see
// https://github.com/overleaf/write_latex/pull/5120#discussion_r244291862

Some files were not shown because too many files have changed in this diff Show More