Compare commits

..
Author SHA1 Message Date
EthanHealy01 df00d61480 feat(settings): remove custom accent-colour picker (presets + Default only)
Drop the custom-hue ColorInput from the accent picker in settings — users pick
from the preset swatches or Default, no arbitrary hues. Removes the ColorInput
usage and its now-dead deps (draft state, clampAccentChoice, DEFAULT_ACCENT_COLOR,
ColorInput import). The preset grid + Default cell (shared ColorGridPicker) and
everything else are unchanged.
2026-07-14 15:58:40 +01:00
EthanHealy01 562166419b chore(lint): remove now-dead manager.tsx import exemption
Follow-up to removing .storybook/manager.tsx — the one-file no-restricted-imports
exemption pointed at a file that no longer exists.
2026-07-14 13:49:29 +01:00
EthanHealy01 2b77fb345a chore(storybook): remove accent-picker manager addon + its lint exemption
The .storybook/manager.tsx accent toolbar was the only thing importing editor
code into Storybook's (alias-less, esbuild) manager bundle, forcing a lint
exemption. Remove the addon and the exemption entirely. preview.tsx still
declares accentLight/accentDark globals (default accent) so stories are
unaffected; the swatch picker toolbar is just gone.

eslint clean + storybook build passes, no import overrides remain.
2026-07-14 13:49:29 +01:00
EthanHealy01 bedf797f46 fix(storybook): manager.tsx imports relatively (esbuild manager has no aliases)
The prior change aliased manager.tsx to @core, but Storybook's manager bundle
(esbuild) doesn't resolve aliases — only the preview/Vite bundle does — so the
storybook build failed. Revert manager.tsx to a relative import and scope a
one-file no-restricted-imports exemption to .storybook/manager.tsx (the only
file that genuinely can't use an alias). preview.tsx keeps @public (Vite-built).

Verified: eslint clean + storybook build succeeds.
2026-07-14 13:35:20 +01:00
EthanHealy01andGitHub 86378dbc64 Merge branch 'UI/consolidate-theme-variables' into UI/color-token-migration 2026-07-14 12:18:07 +01:00
EthanHealy01 d560335a6c chore(lint): drop blanket no-restricted-imports:off for node scripts
Removing the nodeGlobs 'off' (it masked a real violation) and fixing the two
imports it was hiding, so the relative-import ban applies to build tooling too:
- .storybook/manager.tsx: relative editor/src import -> @core/constants/theme
- .storybook/preview.tsx: relative public-asset import -> new @public/* alias
  (wired in main.ts viteFinal + .storybook/tsconfig paths), since no src alias
  covers public/. No eslint-disable / suppressions.

Node globals for the nodeGlobs layer are kept.
2026-07-14 12:09:05 +01:00
EthanHealy01 73704feb10 chore(lint): drop blanket no-restricted-imports:off for node scripts
Removing the nodeGlobs 'off' (it masked a real violation) and fixing the two
imports it was hiding, so the relative-import ban applies to build tooling too:
- .storybook/manager.tsx: relative editor/src import -> @core/constants/theme
- .storybook/preview.tsx: relative public-asset import -> new @public/* alias
  (wired in main.ts viteFinal + .storybook/tsconfig paths), since no src alias
  covers public/. No eslint-disable / suppressions.

Node globals for the nodeGlobs layer are kept.
2026-07-14 12:08:31 +01:00
EthanHealy01andGitHub b49b04bd68 Merge branch 'main' into UI/consolidate-theme-variables 2026-07-14 11:37:39 +01:00
EthanHealy01 873caf5172 merge main 2026-07-14 11:34:49 +01:00
EthanHealy01 193b096495 fix(theme): restore --color-hero-navy for the white hero CTA text
The main merge dropped --color-hero-navy from tokens.css on the assumption
nothing referenced it, but the white hero CTA text (EditorStatusCard.css /
WelcomeBanner.css) still uses it — leaving it undefined (invisible text on the
white button). Restore the token; the hero *background* stays accent-responsive.
2026-07-14 01:10:24 +01:00
EthanHealy01 1cdecfaf58 Merge remote-tracking branch 'origin/main' into UI/consolidate-theme-variables 2026-07-14 00:02:26 +01:00
EthanHealy01 c6f8ed43fd refactor(ui): extract shared ColorGridPicker for the accent picker
Per review on #7009: move the accent swatch grid out of GeneralSection into a
reusable core/ui/ColorGridPicker (swatch trigger + popover + radiogroup grid
with an optional default/unset icon cell + a footer slot). GeneralSection now
renders <ColorGridPicker> and passes the presets, default option and the
custom-colour ColorInput as the footer.

Removes the three raw-<button> eslint-disables from GeneralSection; the raw
elements now live in the DS layer (core/ui/), which the lint rule exempts.
Markup/styles preserved verbatim, so the control is unchanged visually.
2026-07-13 19:09:26 +01:00
EthanHealy01 05de5d7e2d chore(i18n): drop em-dash from theme accent description
Per review on #7009 — avoid em-dashes in UI copy.
2026-07-13 18:58:53 +01:00
EthanHealy01 449353150d feat(lint): make contrast check blocking + fix dark subtle-text AA
Per review on #7009: the contrast check was warn-only and opt-in, so it would
never catch regressions. Enforce it here (the follow-up PR):
- theme-lint.mjs `contrast` mode now exits non-zero on any sub-floor pair
- wired into `task frontend:lint:colors` (runs in the blocking lint gate)
- fixed the two failing pairs: --c-text-subtle on dark/portal-dark surfaces
  (3.36/3.67 → 4.74/5.18) by adding --p-zinc-250 and pointing dark subtle at it

All text-on-surface / on-primary pairs now clear WCAG AA per theme.
2026-07-13 18:49:46 +01:00
EthanHealy01 0f6f5b4e0b feat(lint): enforce no hardcoded colour in TS/TSX DOM code (code-colors)
Add a blocking 'code-colors' mode to theme-lint: default-deny with layered
exemptions (structural; var()/readColor/canvas/pdf-lib contexts; a
// theme-allow-color opt-out; exempt paths for rendering/vendor/config/
illustration areas). File list from 'git ls-files' (no directory walk).
Wired into 'task frontend:lint:colors'; README + script header updated.

Also removes the temporary color-migration-audit.md scratch file.
2026-07-13 17:42:21 +01:00
EthanHealy01 941dc35cda refactor(ui): route TS/TSX inline-style colours through the palette
Migrate hardcoded colour literals in DOM inline styles to tokens:
- auth screens (OAuthConsent/LoggedInState) + Login/Signup -> fixed --p-*
  (AuthLayout forces light; semantic --c-* would break there)
- FileCard/LanguagePicker/ErrorBoundary/ToolStep/etc -> --c-* / --p-*
- Payg avatar palette + DesktopOnboardingModal gradient -> exact --p-*
- rgba tints -> color-mix(in srgb, var(--p-*) N%, transparent)

Canvas/PDF rendering, colour pickers, vendor brand and self-contained docs
keep numeric colour by design.
2026-07-13 17:40:43 +01:00
EthanHealy01 93bc796e2f add primatives and remove the rgb codes and hex codes that we can remove 2026-07-13 16:36:12 +01:00
EthanHealy01 544a1f02eb feat(lint): enforce zero hardcoded colour across all source CSS
Add a blocking 'css-colors' mode to theme-lint that flags any hardcoded
colour in source .css under editor/src (primitives.css + generated
output.css exempt). File list is sourced from 'git ls-files' rather than a
directory walk, so there's no readdir→readFile path; comments and structural
black/white/transparent are ignored. Wired into 'task frontend:lint:colors'.

Update theme README + script header for the expanded palette and the now
app-wide enforcement.
2026-07-13 15:08:03 +01:00
EthanHealy01 6800db8029 refactor(css): migrate all hardcoded colours to primitives (CSS → zero literals)
Move every non-structural colour literal in source CSS into the primitive
palette and reference via var(--p-*):
- 194 hex + 139 rgba() across 38 files replaced
- 90 new primitives added (brand azure/red, violet/indigo, cyan, pink,
  emerald, slate, navy, Notion paper, illustration art, vendor/OS-media)
- near-duplicate neutrals snapped to existing ramp values
- coloured rgba() alpha tints -> color-mix(in srgb, var(--p-*) N%, transparent)
- structural rgba(0,0,0/255,255,255) and comment breadcrumbs left intact

Source CSS now contains zero hardcoded colour outside primitives.css.
Build + theme-lint pass; every var(--p-*) reference resolves.
2026-07-13 15:03:44 +01:00
EthanHealy01 2748fe3157 refactor(css): consolidate redundant status/brand colours to tokens
- billing status chips (FULL/WARNED/DEGRADED) -> adaptive --c-success/
  warning/danger(-subtle); now theme-aware instead of fixed pale literals
- unify saas guest-button red #9c2f30 -> #af3434 (single Stirling red)
- unify SpendCapControl dark accent #7ab4ff -> #66b8ff (match billing azure)
- disabled plan-button grey #7e7e7e -> var(--p-gray-500)

Distinct non-structural CSS hex: 95 -> 86.
2026-07-13 14:43:02 +01:00
EthanHealy01 b7bcbc9f45 refactor(css): merge adjacent duplicate rulesets into grouped selectors
Merge only ADJACENT rules (consecutive, whitespace-only gap, same nesting) with
identical declaration blocks — cascade-safe (non-adjacent merges can reorder the
cascade, so left alone). 22 merges across 14 files, net -104 lines. Build +
theme-lint green.
2026-07-13 11:47:15 +01:00
EthanHealy01 d7f51d7f72 feat(theme): add --c-warning + subtle status tokens; migrate auth alerts
Adds --c-warning (amber, per-theme) and --c-success/danger/warning-subtle
(pale status surfaces) to colors.css — the recurring tokens the consolidation
agents flagged as missing. Migrates the auth error/success alert boxes onto
them. Remaining status-colour consumers tracked in color-migration-audit.md.
2026-07-13 10:58:56 +01:00
EthanHealy01 2c0728c1a7 refactor(theme): collapse dark-override blocks to adaptive --c-* (agents)
Six parallel passes across component CSS: collapsed manual light/dark override
blocks to the adaptive --c-* tokens (navy overrides → neutral surfaces, per the
neutral-dark direction), migrated semantic colours to --c-*, stripped dead
--c-*/--p-* fallbacks, removed a duplicate ruleset. Brand/data-viz/illustration
colours kept and catalogued in color-migration-audit.md with the --c-* tokens
still needed to finish. Build + theme-lint green.
2026-07-13 10:55:38 +01:00
EthanHealy01 cca8c700d3 refactor(theme): strip dead --c-primary hex fallbacks (partial)
Removes the dead #6366f1 fallback from var(--c-primary, #6366f1) in 4 files
(--c-primary is always defined). Partial progress on the colour consolidation;
the full override-collapse pass is pending (agent fan-out blocked).
2026-07-13 09:41:07 +01:00
EthanHealy01 17b0fae153 refactor(theme): tokenize exact-match hardcoded colours (script)
Auto-replaced 48 hardcoded hex colours that match a primitive within Δ≤2
(visually identical) with var(--p-*), across all component CSS. Generated
color-migration-audit.md listing the 50 near-matches and 93 genuinely-unique
colours for the follow-up agent consolidation pass. Build + theme-lint green.
2026-07-13 02:02:33 +01:00
EthanHealy01 c5fbf85035 refactor(theme): tokenize matching hex + remove dead legacy tokens
- theme.css: convert the 5 hardcoded UI colours that exactly match a primitive
  to var(--p-*) / color-mix(var(--p-*)); bespoke logo/illustration fills, brand
  azure/gradients and the deliberate flash-yellow have no primitive equivalent
  and are left.
- Remove 11 verified-dead legacy tokens (--text-always-*, --landing-drop-*,
  --link-*) — 0 refs and not built dynamically (excluded all --color-*/--accent-*
  since those prefixes ARE constructed at runtime). theme.css 902 → 865 lines.
Build + theme-lint green.
2026-07-13 01:50:36 +01:00
EthanHealy01 ee6684f6a4 refactor(theme): delete compat.css — components reference --c-* directly
Migrated all remaining legacy-alias consumers (incl. stories/tests) to --c-*
(199 refs / 58 files), promoted the computed aliases to first-class tokens
(--c-accent-fg made universal on :root; --c-primary-tint / --c-primary-border
added), then removed compat.css, its @import, and its linter entry. No legacy
colour-alias layer remains; build + theme-lint green.

The larger theme.css/tokens.css legacy definition files are a separate cleanup.
2026-07-13 01:25:38 +01:00
EthanHealy01 925caf6d11 refactor(theme): drop 71 now-dead compat aliases
After migrating consumers to --c-* (prior commit), 71 of the 93 1:1 compat
aliases have zero references anywhere (verified across src + tailwind.config +
index.html; the 22 that remain are kept alive by stories/portal mantine theme).
Removing the dead ones cuts compat.css roughly in half — the real consolidation
payoff, not just a rename.
2026-07-13 01:14:13 +01:00
EthanHealy01 a70f80279a chore: remove one-shot compat-colour codemod after applying it
The migration is permanent in the committed files; the throwaway walker isn't
referenced anywhere and tripped Aikido's readdir→readFile heuristic.
2026-07-13 01:10:39 +01:00
EthanHealy01 99be0ae3c6 fix(theme): loading splash follows theme (no white flash in dark mode)
LoadingFallback renders inside Suspense before MantineProvider sets its colour
scheme, so --mantine-color-body was still Mantine's light default (white flash
when the portal/app splash appears in dark mode). Switch to --c-bg/--c-text,
which are driven by the pre-paint attributes on <html> and are correct from the
first frame.
2026-07-13 00:56:51 +01:00
EthanHealy01andGitHub d8599e2c6f Merge branch 'main' into UI/consolidate-theme-variables 2026-07-13 00:51:20 +01:00
EthanHealy01 7b43bb483e refactor(theme): migrate hardcoded hex in component CSS to tokens
Per-area passes replaced hardcoded surface/text/border/status hex in component
stylesheets with semantic --c-* tokens (--p-* only where an exact value had to
be preserved). Left intentionally: structural black/white/transparent, OAuth
brand colours, deliberate multi-hue gradients, data-viz/status hues without a
semantic fit, and dead var(--c-*, #fallback) fallbacks. ~90 sites across 17
files. Build + theme-lint green.
2026-07-13 00:48:40 +01:00
EthanHealy01 5f6b88005e refactor(theme): migrate compat colour aliases to --c-* tokens
Codemod (editor/scripts/migrate-compat-colors.mjs) rewrites every var(--legacy)
reference to the canonical --c-* token it maps to in compat.css (1:1 aliases
only; computed color-mix/fallback aliases left in place). 218 files, 1947
references. Pure rename — compat.css already guarantees each alias equals its
--c-* target, so no behaviour change.
2026-07-13 00:36:08 +01:00
EthanHealy01 41f507a9f0 chore(theme): dedupe default-blue literal in theme constants
Collapse the two #3b82f6 occurrences (DEFAULT_ACCENT_COLOR + first preset) into
a single documented BLUE_500 const. The accent hexes stay JS literals by
necessity — stored verbatim and parsed by deriveAccessiblePrimary, so CSS
var(--p-*) refs can't be used; theme-lint scopes to CSS only.
2026-07-13 00:25:56 +01:00
EthanHealy01 ffc0755b37 chore(storybook): use DEFAULT_ACCENT_COLOR instead of hardcoded #3b82f6
Replace the literal blue in preview.tsx globalTypes/fallback and manager.tsx
with the DEFAULT_ACCENT_COLOR constant from constants/theme.
2026-07-13 00:23:30 +01:00
EthanHealy01 91e0815f93 fix(theme): lift dark canvas ~2% off pure black (#0a0a0b → #0f0f10)
Dark mode's darkest surface (--c-bg / --p-zinc-950) read as near-black. Lift
it ~2% lighter across every representation (primitive, Tailwind --gray-50/
--background channels, Mantine dark-7) so the canvas is a deep charcoal, never
pure black — consistent, not a one-off override.
2026-07-13 00:04:26 +01:00
EthanHealy01 e3b4bc2412 chore(theme-lint): read a fixed file list, not readdir→readFile
Static scanners (Aikido) flag the directory-listing→file-read flow as a
file-inclusion risk. Read a fixed THEME_FILES list via constant paths instead
(matching the other unflagged scripts); readdir is now only used to fail if a
new theme .css isn't registered, so coverage still can't lapse.
2026-07-12 23:59:31 +01:00
EthanHealy01 e9785b6b2f chore(theme): harden lint script, trim comments, fix CI lint/format
- theme-lint.mjs: resolve root, skip symlinks, refuse reads outside the
  theme dir (addresses Aikido file-inclusion finding)
- remove unused eslint-disable in .storybook/preview.tsx (frontend-validation
  --max-warnings=0)
- condense multi-line comments to one line; drop style-choice CSS comments
- prettier formatting
2026-07-12 23:54:26 +01:00
EthanHealy01 31b7c0069d fix comment 2026-07-12 23:18:33 +01:00
EthanHealy01 a8a5f3a88f initial colors and theme improvements 2026-07-12 23:17:37 +01:00
398 changed files with 9626 additions and 9548 deletions
+16
View File
@@ -203,6 +203,22 @@ tasks:
cmds:
- task: lint:eslint
- task: lint:dpdm
- task: lint:colors
lint:colors:
desc: "Enforce theme tokens — all CSS colours route through the palette"
deps: [install]
cmds:
- node editor/scripts/lint/theme-lint.mjs
- node editor/scripts/lint/theme-lint.mjs css-colors
- node editor/scripts/lint/theme-lint.mjs code-colors
- node editor/scripts/lint/theme-lint.mjs contrast
contrast:
desc: "Check theme token pairs clear WCAG AA contrast per theme"
deps: [install]
cmds:
- node editor/scripts/lint/theme-lint.mjs contrast
lint:eslint:
desc: "Run ESLint linting"
+2
View File
@@ -155,6 +155,8 @@ The project structure is defined in `engine/pyproject.toml`. Any new dependencie
For a broader explanation of the frontend layering and override architecture, read @frontend/editor/DeveloperGuide.md
Before touching colours or theming (tokens, dark mode, accent colours), read @frontend/editor/src/core/theme/README.md — it explains the palette/`--c-*` token system and the rule that literal colours live only in `primitives.css`.
```typescript
// ✅ CORRECT - Use @app/* for all imports
import { AppLayout } from "@app/components/AppLayout";
-12
View File
@@ -208,18 +208,6 @@
"moduleName": ".*",
"moduleLicense": "The W3C License"
},
{
"moduleName": "com.google.re2j:re2j",
"moduleLicense": "Go License"
},
{
"moduleName": "com.hubspot:algebra",
"moduleLicense": null
},
{
"moduleName": "com.hubspot.immutables:immutables-exceptions",
"moduleLicense": null
},
{
"moduleName": ".*",
"moduleLicense": "UnRar License"
-14
View File
@@ -66,20 +66,6 @@ dependencies {
implementation "com.google.code.gson:gson:${gsonVersion}"
// jinjava/jjwt transitively request older Jackson 2 versions; declare the current
// version directly so it is selected consistently (root build.gradle pins are the fallback).
runtimeOnly "com.fasterxml.jackson.core:jackson-core:${jackson2Version}"
runtimeOnly "com.fasterxml.jackson.core:jackson-databind:${jackson2Version}"
implementation("com.hubspot.jinjava:jinjava:${jinjavaVersion}") {
// Compile-time-only annotation artifacts (class-retention annotations, not needed at
// runtime) whose declared licences (LGPL / none) fail the licence compatibility check.
exclude group: 'com.google.code.findbugs', module: 'annotations'
exclude group: 'org.derive4j', module: 'derive4j-annotation'
exclude group: 'com.hubspot.immutables', module: 'hubspot-style'
exclude group: 'com.hubspot.immutables', module: 'immutable-collection-encodings'
}
api 'io.micrometer:micrometer-registry-prometheus'
api "io.jsonwebtoken:jjwt-api:${jwtVersion}"
@@ -1,61 +0,0 @@
package stirling.software.proprietary.classification;
import java.io.InputStream;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
import stirling.software.proprietary.classification.model.ClassificationLabel;
import stirling.software.proprietary.classification.model.ClassificationLabels;
import tools.jackson.databind.ObjectMapper;
/**
* Supplies the classification vocabulary the classify tool sends to the AI engine. The set is a
* fixed, built-in list bundled with the application ({@code
* classification/classification-labels.json}) and shared by everyone — there is no per-team
* customization or database. Loaded once at startup.
*/
@Slf4j
@Component
public class ClassificationLabelProvider {
private static final String RESOURCE = "classification/classification-labels.json";
private final List<ClassificationLabel> labels;
// Explicit @Autowired: the class has a second (private) constructor for tests, so Spring
// can't infer which to use without it.
@Autowired
public ClassificationLabelProvider(ObjectMapper objectMapper) {
this(load(objectMapper));
}
private ClassificationLabelProvider(List<ClassificationLabel> labels) {
this.labels = List.copyOf(labels);
}
/** Build a provider with an explicit label set (tests). */
public static ClassificationLabelProvider withLabels(List<ClassificationLabel> labels) {
return new ClassificationLabelProvider(labels);
}
/** The built-in vocabulary, in file order. */
public List<ClassificationLabel> labels() {
return labels;
}
private static List<ClassificationLabel> load(ObjectMapper objectMapper) {
try (InputStream in = new ClassPathResource(RESOURCE).getInputStream()) {
ClassificationLabels parsed = objectMapper.readValue(in, ClassificationLabels.class);
return parsed.labels();
} catch (Exception e) {
log.error("Failed to load classification labels from {}", RESOURCE, e);
return List.of();
}
}
}
@@ -0,0 +1,136 @@
package stirling.software.proprietary.classification;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.service.UserServiceInterface;
import stirling.software.proprietary.classification.model.ClassificationLabels;
import stirling.software.proprietary.classification.model.LabelsValidator;
import stirling.software.proprietary.classification.store.ClassificationLabelStore;
import stirling.software.proprietary.classification.store.TeamLabelsEntity;
import stirling.software.proprietary.policy.config.PolicyManagementAuthority;
/**
* Read/write the team's classification label set — the flat vocabulary the document classifier runs
* against. Shared and team-scoped exactly like policies: every user reads their own team's labels,
* and only a user who may edit policies (a team leader on SaaS, the global admin self-hosted; see
* {@link PolicyManagementAuthority}) may change it — gated only when login is enabled, since
* single-user deployments trust the local operator. A team with no stored labels reads as {@code
* 204}; that team has no vocabulary, so its documents are not classified (there is no built-in
* default on the backend or the engine — the label data lives only in the frontend).
*/
@RestController
@RequestMapping("/api/v1/classification/labels")
@Hidden
@RequiredArgsConstructor
@Tag(name = "Classification", description = "Team-scoped document-classification labels")
@ConditionalOnBooleanProperty(name = "policies.enabled")
public class ClassificationLabelsController {
private final ClassificationLabelStore labelStore;
private final PolicyManagementAuthority policyManagementAuthority;
private final ApplicationProperties applicationProperties;
private final UserServiceInterface userService;
@GetMapping
@Operation(
summary = "Get the team's classification labels",
description =
"Returns the caller's team label set, or 204 when the team has none (its"
+ " documents are then not classified).")
public ResponseEntity<ClassificationLabels> getTeamLabels() {
return labelStore
.findByTeam(currentTeamId())
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.noContent().build());
}
@PutMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(
summary = "Save the team's classification labels",
description =
"Validates and stores the label set for the caller's team, shared by everyone"
+ " on the team. Requires the policy-editor role for the team.")
public ResponseEntity<ClassificationLabels> saveTeamLabels(
@RequestBody ClassificationLabels labels) {
requireEditingAllowed();
validate(labels);
ClassificationLabels saved = labelStore.save(currentTeamId(), labels, currentUsername());
return ResponseEntity.ok(saved);
}
@DeleteMapping
@Operation(
summary = "Reset the team's classification labels",
description =
"Removes the team's stored label set; its documents are then not classified"
+ " until labels are saved again. Requires the policy-editor role for the"
+ " team.")
public ResponseEntity<Void> resetTeamLabels() {
requireEditingAllowed();
labelStore.deleteByTeam(currentTeamId());
return ResponseEntity.noContent().build();
}
private static void validate(ClassificationLabels labels) {
try {
LabelsValidator.validate(labels);
} catch (IllegalArgumentException e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
}
}
/**
* Editing the team labels requires the editor role for the caller's team — the same gate
* policies use (team leader on SaaS, global admin self-hosted). Single-user deployments (login
* disabled) have no such role, so they trust the local operator.
*/
private void requireEditingAllowed() {
if (!applicationProperties.getSecurity().isEnableLogin()) {
return;
}
if (!policyManagementAuthority.canEditPolicies()) {
throw new ResponseStatusException(
HttpStatus.FORBIDDEN,
"The team classification labels may only be changed by a team leader");
}
}
/**
* The caller's team key. With login disabled the single operator owns the {@link
* TeamLabelsEntity#NO_TEAM} sentinel row; with login enabled a caller with no resolvable team
* is an error rather than being dropped into the shared sentinel bucket (which would let
* unteamed users read and overwrite each other's "team" labels).
*/
private Long currentTeamId() {
Long teamId = policyManagementAuthority.currentUserTeamId();
if (teamId != null) {
return teamId;
}
if (!applicationProperties.getSecurity().isEnableLogin()) {
return TeamLabelsEntity.NO_TEAM;
}
throw new ResponseStatusException(
HttpStatus.UNAUTHORIZED, "Could not resolve the current user's team");
}
private String currentUsername() {
return userService == null ? null : userService.getCurrentUsername();
}
}
@@ -3,10 +3,10 @@ package stirling.software.proprietary.classification.model;
import java.util.List;
/**
* A flat multi-label classification vocabulary — the set of labels a document may be assigned. The
* classifier runs against these label names. The vocabulary is a fixed, built-in set shared by
* everyone (see {@link stirling.software.proprietary.classification.ClassificationLabelProvider});
* this record is the JSON parse target for that bundled resource.
* A flat multi-label classification vocabulary — the set of labels a document may be assigned.
* Stored per team (admin-edited, shared by everyone on the team); the classifier runs against these
* label names. A team with no stored set has no vocabulary, so its documents are not classified —
* neither the backend nor the engine holds a default of its own.
*/
public record ClassificationLabels(List<ClassificationLabel> labels) {
@@ -0,0 +1,71 @@
package stirling.software.proprietary.classification.model;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.regex.Pattern;
/**
* Structural validation for a user- or admin-supplied label set, run before it is stored so a
* malformed vocabulary can never reach the classifier. Mirrors the invariants the engine relies on:
* non-blank ids and names, each unique within the set (ids exactly, names case-insensitively).
*/
public final class LabelsValidator {
private LabelsValidator() {}
// Generous upper bounds so a legitimate label set is never blocked, but a single team or user
// can't store an unbounded blob that would bloat the row, balloon the classifier prompt, or
// exhaust memory on deserialize.
static final int MAX_LABELS = 500;
static final int MAX_TEXT_LENGTH = 128;
// Icon is a Material Symbols key (lowercase, digits, hyphens). Enforce the SHAPE server-side —
// the exact allowlist lives in the frontend — so a client bypassing the UI can't store
// arbitrary
// text that would render as garbage (or worse) in every teammate's sidebar.
private static final Pattern ICON_KEY = Pattern.compile("^[a-z0-9-]+$");
/**
* @throws IllegalArgumentException with a human-readable message when the label set is invalid.
*/
public static void validate(ClassificationLabels labels) {
if (labels == null || labels.labels() == null) {
throw new IllegalArgumentException("Labels are required");
}
if (labels.labels().size() > MAX_LABELS) {
throw new IllegalArgumentException("Too many labels (max " + MAX_LABELS + ")");
}
Set<String> ids = new HashSet<>();
Set<String> names = new HashSet<>();
for (ClassificationLabel label : labels.labels()) {
requireText(label.id(), "Label id");
requireText(label.name(), "Label name");
if (label.icon() != null && !label.icon().isEmpty()) {
if (label.icon().length() > MAX_TEXT_LENGTH) {
throw new IllegalArgumentException(
"Label icon is too long (max " + MAX_TEXT_LENGTH + " characters)");
}
if (!ICON_KEY.matcher(label.icon()).matches()) {
throw new IllegalArgumentException("Invalid label icon: " + label.icon());
}
}
if (!ids.add(label.id().trim())) {
throw new IllegalArgumentException("Duplicate label id: " + label.id());
}
if (!names.add(label.name().trim().toLowerCase(Locale.ROOT))) {
throw new IllegalArgumentException("Duplicate label name: " + label.name());
}
}
}
private static void requireText(String value, String field) {
if (value == null || value.isBlank()) {
throw new IllegalArgumentException(field + " must not be blank");
}
if (value.trim().length() > MAX_TEXT_LENGTH) {
throw new IllegalArgumentException(
field + " is too long (max " + MAX_TEXT_LENGTH + " characters)");
}
}
}
@@ -0,0 +1,22 @@
package stirling.software.proprietary.classification.store;
import java.util.Optional;
import stirling.software.proprietary.classification.model.ClassificationLabels;
/**
* Stores one {@link ClassificationLabels} set per team. A {@code null} teamId addresses the
* unteamed set (login disabled / no resolvable team), mirroring how the policy store treats a null
* team.
*/
public interface ClassificationLabelStore {
/** The team's stored labels, or empty when it has none (callers then skip classification). */
Optional<ClassificationLabels> findByTeam(Long teamId);
/** Create or replace the team's labels. Returns the stored value. */
ClassificationLabels save(Long teamId, ClassificationLabels labels, String updatedBy);
/** Remove the team's labels (reset to default). Returns whether a set existed. */
boolean deleteByTeam(Long teamId);
}
@@ -0,0 +1,36 @@
package stirling.software.proprietary.classification.store;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import stirling.software.proprietary.classification.model.ClassificationLabels;
/**
* In-memory {@link ClassificationLabelStore} for tests and any future no-database mode. {@link
* JpaClassificationLabelStore} is the runtime bean.
*/
public class InProcessClassificationLabelStore implements ClassificationLabelStore {
private final Map<Long, ClassificationLabels> byTeam = new ConcurrentHashMap<>();
@Override
public Optional<ClassificationLabels> findByTeam(Long teamId) {
return Optional.ofNullable(byTeam.get(key(teamId)));
}
@Override
public ClassificationLabels save(Long teamId, ClassificationLabels labels, String updatedBy) {
byTeam.put(key(teamId), labels);
return labels;
}
@Override
public boolean deleteByTeam(Long teamId) {
return byTeam.remove(key(teamId)) != null;
}
private static long key(Long teamId) {
return teamId == null ? TeamLabelsEntity.NO_TEAM : teamId;
}
}
@@ -0,0 +1,76 @@
package stirling.software.proprietary.classification.store;
import java.time.Instant;
import java.util.Optional;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import stirling.software.proprietary.classification.model.ClassificationLabels;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.ObjectMapper;
/**
* Durable {@link ClassificationLabelStore} backed by JPA; the runtime store. Gated on {@code
* policies.enabled} — stored labels only matter when the Classification policy can run — so it
* shares the policy subsystem's on/off switch. Each label set is persisted as JSON via {@link
* TeamLabelsEntity}.
*/
@Slf4j
@Service
@RequiredArgsConstructor
@ConditionalOnBooleanProperty(name = "policies.enabled")
public class JpaClassificationLabelStore implements ClassificationLabelStore {
private final TeamLabelsRepository teamRepository;
private final ObjectMapper objectMapper;
@Override
public Optional<ClassificationLabels> findByTeam(Long teamId) {
return teamRepository
.findById(key(teamId))
.flatMap(entity -> parse(entity.getLabelsJson(), "team " + teamId));
}
@Override
public ClassificationLabels save(Long teamId, ClassificationLabels labels, String updatedBy) {
TeamLabelsEntity entity = new TeamLabelsEntity();
entity.setTeamId(key(teamId));
entity.setLabelsJson(objectMapper.writeValueAsString(labels));
entity.setUpdatedAt(Instant.now());
entity.setUpdatedBy(updatedBy);
teamRepository.save(entity);
return labels;
}
@Override
public boolean deleteByTeam(Long teamId) {
long id = key(teamId);
if (!teamRepository.existsById(id)) {
return false;
}
teamRepository.deleteById(id);
return true;
}
private Optional<ClassificationLabels> parse(String json, String owner) {
try {
return Optional.of(objectMapper.readValue(json, ClassificationLabels.class));
} catch (JacksonException e) {
// A stored label set that no longer parses (corruption / manual DB edit) must not break
// classification: drop it so the caller treats the team as having no labels (and skips
// classification) rather than surfacing a 500 on every upload.
log.warn("Discarding unparseable stored labels for {}: {}", owner, e.getMessage());
return Optional.empty();
}
}
/** Map the nullable team id onto the entity's non-null key (sentinel for the unteamed case). */
private static long key(Long teamId) {
return teamId == null ? TeamLabelsEntity.NO_TEAM : teamId;
}
}
@@ -0,0 +1,47 @@
package stirling.software.proprietary.classification.store;
import java.io.Serializable;
import java.time.Instant;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* JPA row for a team's classification labels — one row per team. The label set lives as JSON in
* {@code labelsJson} (authoritative on read). {@code teamId} is the natural key; the sentinel
* {@link #NO_TEAM} stands in for the unteamed (login-disabled / self-hosted single-team) case,
* since a primary key can't be null (policies store a nullable {@code team_id}, but this table is
* keyed one-per-team). Kept decoupled from the security entities — {@code teamId} is a plain value,
* not a foreign key — so classification can be enabled or disabled without touching them.
*/
@Entity
@Table(name = "classification_labels")
@NoArgsConstructor
@Getter
@Setter
public class TeamLabelsEntity implements Serializable {
private static final long serialVersionUID = 1L;
/** Sentinel key for the unteamed label set (login disabled / no resolvable team). */
public static final long NO_TEAM = 0L;
@Id
@Column(name = "team_id")
private long teamId;
@Column(name = "labels_json", columnDefinition = "text")
private String labelsJson;
@Column(name = "updated_at")
private Instant updatedAt;
@Column(name = "updated_by")
private String updatedBy;
}
@@ -0,0 +1,7 @@
package stirling.software.proprietary.classification.store;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface TeamLabelsRepository extends JpaRepository<TeamLabelsEntity, Long> {}
@@ -31,9 +31,10 @@ import stirling.software.common.service.PdfMetadataService;
import stirling.software.common.service.UserServiceInterface;
import stirling.software.common.util.TempFileManager;
import stirling.software.common.util.WebResponseUtils;
import stirling.software.proprietary.classification.ClassificationLabelProvider;
import stirling.software.proprietary.classification.model.ClassificationLabel;
import stirling.software.proprietary.classification.store.ClassificationLabelStore;
import stirling.software.proprietary.model.api.ai.AiPageText;
import stirling.software.proprietary.policy.config.PolicyManagementAuthority;
import stirling.software.proprietary.service.AiEngineClient;
import stirling.software.proprietary.service.PdfContentExtractor;
@@ -45,7 +46,7 @@ import tools.jackson.databind.node.ObjectNode;
* Dispatchable tool that classifies a PDF and writes the result into its metadata.
*
* <p>Runs as a Classification-policy pipeline step: it reads a bounded page window, asks the AI
* engine to classify the document against the built-in label set, and stores the engine's JSON
* engine to classify the document against the caller's team label set, and stores the engine's JSON
* answer — minus the transport-only {@code outcome} field — in the custom Info-dictionary key
* {@link PdfMetadataService#CLASSIFICATION_KEY}. Returns the labelled PDF. Not intended for direct
* client use.
@@ -71,9 +72,13 @@ public class ClassifyLabelController {
private final UserServiceInterface userService;
/**
* The fixed, built-in vocabulary shared by everyone — see {@link ClassificationLabelProvider}.
* Present only when the policy subsystem is enabled ({@code policies.enabled}); the store and
* team authority are gated on it. Null otherwise, in which case there are no team labels to
* classify against and the document is passed through unlabelled.
*/
private final ClassificationLabelProvider labelProvider;
private final ClassificationLabelStore labelStore;
private final PolicyManagementAuthority policyManagementAuthority;
public ClassifyLabelController(
CustomPDFDocumentFactory pdfDocumentFactory,
@@ -82,16 +87,18 @@ public class ClassifyLabelController {
PdfMetadataService pdfMetadataService,
AiEngineClient aiEngineClient,
ObjectMapper objectMapper,
ClassificationLabelProvider labelProvider,
@Autowired(required = false) UserServiceInterface userService) {
@Autowired(required = false) UserServiceInterface userService,
@Autowired(required = false) ClassificationLabelStore labelStore,
@Autowired(required = false) PolicyManagementAuthority policyManagementAuthority) {
this.pdfDocumentFactory = pdfDocumentFactory;
this.tempFileManager = tempFileManager;
this.pdfContentExtractor = pdfContentExtractor;
this.pdfMetadataService = pdfMetadataService;
this.aiEngineClient = aiEngineClient;
this.objectMapper = objectMapper;
this.labelProvider = labelProvider;
this.userService = userService;
this.labelStore = labelStore;
this.policyManagementAuthority = policyManagementAuthority;
}
@PostMapping(value = "/classify-and-label", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@@ -109,9 +116,9 @@ public class ClassifyLabelController {
List<EngineLabel> allowed = resolveAllowedLabels();
if (allowed.isEmpty()) {
// No vocabulary to classify against: pass the file through unlabelled rather than
// ask the engine to classify against nothing.
log.debug("[classify-and-label] {} has no labels; skipping", fileName);
// No vocabulary to classify against (the team stored no labels): pass the file
// through unlabelled rather than ask the engine to classify against nothing.
log.debug("[classify-and-label] {} has no team labels; skipping", fileName);
return WebResponseUtils.pdfDocToWebResponse(document, fileName, tempFileManager);
}
@@ -168,13 +175,24 @@ public class ClassifyLabelController {
}
/**
* The built-in vocabulary as {@code {id, name}} pairs, de-duplicated by id. The engine shows
* the model the names and returns the ids (icons are presentational and never sent). The engine
* holds no default vocabulary of its own, so this bundled set is the only source.
* The allowed labels for the caller's team as {@code {id, name}} pairs, de-duplicated by id.
* The engine shows the model the names and returns the ids (icons are presentational and never
* sent). Returns an empty list — the caller then skips classification — when the policy
* subsystem is disabled (no store) or the team has no stored labels. The engine holds no
* default vocabulary of its own, so a team's stored labels are the only source.
*/
private List<EngineLabel> resolveAllowedLabels() {
if (labelStore == null) {
return List.of();
}
Long teamId =
policyManagementAuthority == null
? null
: policyManagementAuthority.currentUserTeamId();
Map<String, EngineLabel> byId = new LinkedHashMap<>();
collectLabels(labelProvider.labels(), byId);
labelStore.findByTeam(teamId).ifPresent(labels -> collectLabels(labels.labels(), byId));
return List.copyOf(byId.values());
}
@@ -8,14 +8,12 @@ import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
import io.github.pixee.security.Filenames;
import io.swagger.v3.oas.annotations.Hidden;
@@ -26,24 +24,18 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import stirling.software.common.configuration.RuntimePathConfig;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.ProcessExecutor;
import stirling.software.common.util.TempFile;
import stirling.software.common.util.TempFileManager;
import stirling.software.common.util.WebResponseUtils;
import stirling.software.proprietary.model.api.ai.create.AiDocument;
import stirling.software.proprietary.service.AiDocumentHtmlRenderer;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.ObjectMapper;
/**
* Dispatchable tool that converts an AI-generated document model to a PDF via WeasyPrint.
* Dispatchable tool that converts an AI-generated HTML string to a PDF via WeasyPrint.
*
* <p>Called by {@link stirling.software.proprietary.service.AiWorkflowService} when the engine
* emits a {@code CREATE_PDF_FROM_HTML_AGENT} plan step. The engine supplies the document as
* structured fields; the HTML is built here from a fixed template.
* emits a {@code CREATE_PDF_FROM_HTML_AGENT} plan step. The HTML comes from a trusted Jinja
* template so sanitization is intentionally skipped.
*/
@Slf4j
@Hidden
@@ -56,9 +48,6 @@ public class CreatePdfAgentController {
private final TempFileManager tempFileManager;
private final CustomPDFDocumentFactory pdfDocumentFactory;
private final RuntimePathConfig runtimePathConfig;
private final ApplicationProperties applicationProperties;
private final ObjectMapper objectMapper;
private final AiDocumentHtmlRenderer htmlRenderer;
/**
* Returns true only when WeasyPrint is definitively unavailable — either the binary could not
@@ -85,42 +74,32 @@ public class CreatePdfAgentController {
value = "/create-pdf-from-html-agent",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Operation(
summary = "Convert an AI-generated document to a PDF",
summary = "Convert AI-generated HTML to a PDF",
description =
"Accepts a structured document as a JSON parameter and returns a PDF. This"
+ " endpoint is dispatched by the AI workflow orchestrator as a plan"
+ " step; it is not intended for direct client use.")
public ResponseEntity<Resource> createPdf(
@RequestParam("document") String document, @RequestParam("filename") String filename)
"Accepts an HTML document as a plain-text parameter and returns a PDF."
+ " This endpoint is dispatched by the AI workflow orchestrator as a"
+ " plan step; it is not intended for direct client use.")
public ResponseEntity<Resource> createPdfFromHtml(
@RequestParam("htmlContent") String htmlContent,
@RequestParam("filename") String filename)
throws Exception {
if (!applicationProperties.getAiEngine().isEnabled()) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND);
}
AiDocument model;
try {
model = objectMapper.readValue(document, AiDocument.class);
} catch (JacksonException e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
}
String html = htmlRenderer.render(model);
log.info(
"[create-pdf-agent] converting document to PDF via WeasyPrint — html_bytes={}",
html.length());
"[create-pdf-agent] converting HTML to PDF via WeasyPrint — html_bytes={}",
htmlContent.length());
try (TempFile htmlFile = tempFileManager.createManagedTempFile(".html");
TempFile pdfFile = tempFileManager.createManagedTempFile(".pdf")) {
Files.writeString(htmlFile.getPath(), html, StandardCharsets.UTF_8);
Files.writeString(htmlFile.getPath(), htmlContent, StandardCharsets.UTF_8);
List<String> command = new ArrayList<>();
command.add(runtimePathConfig.getWeasyPrintPath());
command.add("-e");
command.add("utf-8");
command.add("-v");
// SSRF: the HTML is self-contained and the engine validates style colours, so no
// external url() reaches WeasyPrint. For full isolation, run it network-isolated.
command.add(htmlFile.getAbsolutePath());
command.add(pdfFile.getAbsolutePath());
@@ -147,8 +126,8 @@ public class CreatePdfAgentController {
// avoids materialising the whole document as a byte[] twice (read-all + re-serialise),
// which matters for large generated documents.
TempFile tempOut = tempFileManager.createManagedTempFile(".pdf");
try (PDDocument pdDocument = pdfDocumentFactory.load(pdfFile.getPath())) {
pdDocument.save(tempOut.getPath().toFile());
try (PDDocument document = pdfDocumentFactory.load(pdfFile.getPath())) {
document.save(tempOut.getPath().toFile());
} catch (Exception e) {
tempOut.close();
throw e;
@@ -1,35 +0,0 @@
package stirling.software.proprietary.model.api.ai.create;
import java.util.List;
import lombok.Data;
@Data
public class AiDocument {
private String title;
private String subtitle;
private String referenceNumber;
private Style style;
private List<Section> sections;
@Data
public static class Style {
private String primaryColor;
private String backgroundColor;
private String bodyTextColor;
}
@Data
public static class Section {
private String type;
private String heading;
private String body;
private List<List<String>> pairs;
private List<String> columns;
private List<List<String>> rows;
private List<String> totalRow;
private List<String> items;
private List<String> signatories;
}
}
@@ -37,7 +37,8 @@ import stirling.software.common.model.exception.UnsupportedProviderException;
"stirling.software.proprietary.policy.ledger",
"stirling.software.proprietary.accountlink",
"stirling.software.proprietary.access.repository",
"stirling.software.proprietary.integration.repository"
"stirling.software.proprietary.integration.repository",
"stirling.software.proprietary.classification.store"
})
@EntityScan({
"stirling.software.proprietary.security.model",
@@ -49,7 +50,8 @@ import stirling.software.common.model.exception.UnsupportedProviderException;
"stirling.software.proprietary.policy.ledger",
"stirling.software.proprietary.accountlink",
"stirling.software.proprietary.access.model",
"stirling.software.proprietary.integration.model"
"stirling.software.proprietary.integration.model",
"stirling.software.proprietary.classification.store"
})
public class DatabaseConfig {
@@ -1,135 +0,0 @@
package stirling.software.proprietary.service;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
import com.hubspot.jinjava.Jinjava;
import com.hubspot.jinjava.JinjavaConfig;
import stirling.software.proprietary.model.api.ai.create.AiDocument;
/** Renders an {@link AiDocument} to HTML using a Jinja template loaded from the classpath. */
@Component
public class AiDocumentHtmlRenderer {
private static final String TEMPLATE_PATH = "templates/ai/create/document.html.jinja2";
private static final Pattern SAFE_COLOR = Pattern.compile("^#[0-9a-fA-F]{6}$");
private final Jinjava jinjava;
private final String template;
public AiDocumentHtmlRenderer() {
JinjavaConfig config =
JinjavaConfig.newBuilder().withNestedInterpretationEnabled(false).build();
this.jinjava = new Jinjava(config);
this.template = loadTemplate();
}
public String render(AiDocument doc) {
return jinjava.render(template, buildContext(doc));
}
private static Map<String, Object> buildContext(AiDocument doc) {
Map<String, Object> context = new LinkedHashMap<>();
context.put("title", doc.getTitle());
context.put("subtitle", doc.getSubtitle());
context.put("reference_number", doc.getReferenceNumber());
AiDocument.Style style = doc.getStyle();
if (style != null) {
context.put("style_primary", safeColor(style.getPrimaryColor()));
context.put("style_background", safeColor(style.getBackgroundColor()));
context.put("style_body", safeColor(style.getBodyTextColor()));
}
List<Map<String, Object>> sections = new ArrayList<>();
if (doc.getSections() != null) {
for (AiDocument.Section section : doc.getSections()) {
if (section != null && section.getType() != null) {
sections.add(buildSection(section));
}
}
}
context.put("sections", sections);
return context;
}
private static Map<String, Object> buildSection(AiDocument.Section section) {
Map<String, Object> node = new LinkedHashMap<>();
node.put("type", section.getType());
node.put("heading", section.getHeading());
switch (section.getType()) {
case "text" -> node.put("paragraphs", paragraphs(section.getBody()));
case "key_value" -> node.put("pairs", pairs(section.getPairs()));
case "line_items" -> {
node.put("columns", orEmpty(section.getColumns()));
node.put("rows", orEmptyRows(section.getRows()));
node.put("total_row", emptyToNull(section.getTotalRow()));
}
case "bullet_list" -> node.put("items", orEmpty(section.getItems()));
case "signature" -> node.put("signatories", orEmpty(section.getSignatories()));
default -> {}
}
return node;
}
private static List<String> paragraphs(String body) {
String text = body == null ? "" : body;
List<String> out = new ArrayList<>();
for (String paragraph : text.split("\n\n")) {
out.add(paragraph.replace("\n", " "));
}
return out;
}
private static List<Map<String, String>> pairs(List<List<String>> pairs) {
List<Map<String, String>> out = new ArrayList<>();
if (pairs != null) {
for (List<String> pair : pairs) {
Map<String, String> node = new LinkedHashMap<>();
node.put("label", pair.isEmpty() ? "" : pair.get(0));
node.put("value", pair.size() < 2 ? "" : pair.get(1));
out.add(node);
}
}
return out;
}
private static List<String> orEmpty(List<String> values) {
return values == null ? List.of() : values;
}
private static List<List<String>> orEmptyRows(List<List<String>> rows) {
return rows == null ? List.of() : rows;
}
private static List<String> emptyToNull(List<String> values) {
return values == null || values.isEmpty() ? null : values;
}
private static String safeColor(String value) {
if (value == null) {
return null;
}
String trimmed = value.trim();
return SAFE_COLOR.matcher(trimmed).matches() ? trimmed : null;
}
private static String loadTemplate() {
try {
return new ClassPathResource(TEMPLATE_PATH).getContentAsString(StandardCharsets.UTF_8);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,133 @@
package stirling.software.proprietary.classification;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.when;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.server.ResponseStatusException;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.service.UserServiceInterface;
import stirling.software.proprietary.classification.model.ClassificationLabel;
import stirling.software.proprietary.classification.model.ClassificationLabels;
import stirling.software.proprietary.classification.store.ClassificationLabelStore;
import stirling.software.proprietary.classification.store.InProcessClassificationLabelStore;
import stirling.software.proprietary.policy.config.PolicyManagementAuthority;
@ExtendWith(MockitoExtension.class)
@DisplayName("ClassificationLabelsController")
class ClassificationLabelsControllerTest {
private static final Long TEAM = 7L;
@Mock private PolicyManagementAuthority policyManagementAuthority;
@Mock private UserServiceInterface userService;
private ClassificationLabelStore store;
private ApplicationProperties applicationProperties;
private ClassificationLabelsController controller;
@BeforeEach
void setUp() {
store = new InProcessClassificationLabelStore();
applicationProperties = new ApplicationProperties();
controller =
new ClassificationLabelsController(
store, policyManagementAuthority, applicationProperties, userService);
}
private static ClassificationLabels sample() {
return new ClassificationLabels(
List.of(
new ClassificationLabel("invoice", "Invoice", "receipt-long"),
new ClassificationLabel("contract", "Contract", null)));
}
private void loginEnabled(boolean enabled) {
applicationProperties.getSecurity().setEnableLogin(enabled);
}
@Test
@DisplayName("GET returns 204 when the team has no labels")
void getEmpty() {
when(policyManagementAuthority.currentUserTeamId()).thenReturn(TEAM);
ResponseEntity<ClassificationLabels> response = controller.getTeamLabels();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}
@Test
@DisplayName("PUT then GET round-trips the team's labels (login disabled)")
void saveThenGet() {
loginEnabled(false);
when(policyManagementAuthority.currentUserTeamId()).thenReturn(TEAM);
controller.saveTeamLabels(sample());
ResponseEntity<ClassificationLabels> got = controller.getTeamLabels();
assertThat(got.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(got.getBody()).isNotNull();
assertThat(got.getBody().labels()).hasSize(2);
assertThat(got.getBody().labels().getFirst().name()).isEqualTo("Invoice");
assertThat(got.getBody().labels().getFirst().icon()).isEqualTo("receipt-long");
}
@Test
@DisplayName("PUT is scoped per team")
void perTeam() {
loginEnabled(false);
when(policyManagementAuthority.currentUserTeamId()).thenReturn(TEAM);
controller.saveTeamLabels(sample());
when(policyManagementAuthority.currentUserTeamId()).thenReturn(99L);
assertThat(controller.getTeamLabels().getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}
@Test
@DisplayName("PUT is rejected for a non-editor when login is enabled")
void putForbiddenForNonEditor() {
loginEnabled(true);
when(policyManagementAuthority.canEditPolicies()).thenReturn(false);
assertThatThrownBy(() -> controller.saveTeamLabels(sample()))
.isInstanceOf(ResponseStatusException.class)
.hasFieldOrPropertyWithValue("statusCode", HttpStatus.FORBIDDEN);
}
@Test
@DisplayName("PUT rejects an invalid label set with 400")
void putInvalid() {
loginEnabled(false);
ClassificationLabels duplicate =
new ClassificationLabels(
List.of(
new ClassificationLabel("invoice", "Invoice", null),
new ClassificationLabel("invoice", "Invoice", null)));
assertThatThrownBy(() -> controller.saveTeamLabels(duplicate))
.isInstanceOf(ResponseStatusException.class)
.hasFieldOrPropertyWithValue("statusCode", HttpStatus.BAD_REQUEST);
}
@Test
@DisplayName("DELETE resets the team back to no stored labels")
void deleteResets() {
loginEnabled(false);
when(policyManagementAuthority.currentUserTeamId()).thenReturn(TEAM);
controller.saveTeamLabels(sample());
ResponseEntity<Void> response = controller.resetTeamLabels();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
assertThat(controller.getTeamLabels().getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}
}
@@ -0,0 +1,146 @@
package stirling.software.proprietary.classification.model;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.List;
import java.util.Locale;
import java.util.stream.IntStream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@DisplayName("LabelsValidator")
class LabelsValidatorTest {
private static ClassificationLabels labels(ClassificationLabel... labels) {
return new ClassificationLabels(List.of(labels));
}
private static ClassificationLabel label(String name) {
return new ClassificationLabel(slug(name), name, null);
}
private static String slug(String name) {
return name.trim()
.toLowerCase(Locale.ROOT)
.replaceAll("[^a-z0-9]+", "-")
.replaceAll("(^-|-$)", "");
}
@Test
@DisplayName("accepts a well-formed label set")
void acceptsValid() {
ClassificationLabels set =
labels(
new ClassificationLabel("invoice", "Invoice", "receipt-long"),
label("Contract"));
assertThatCode(() -> LabelsValidator.validate(set)).doesNotThrowAnyException();
}
@Test
@DisplayName("accepts an empty label set (reads as: use the default)")
void acceptsEmpty() {
assertThatCode(() -> LabelsValidator.validate(labels())).doesNotThrowAnyException();
}
@Test
@DisplayName("rejects a null label set")
void rejectsNull() {
assertThatThrownBy(() -> LabelsValidator.validate(null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Labels are required");
}
@Test
@DisplayName("rejects duplicate names (distinct ids)")
void rejectsDuplicateNames() {
ClassificationLabels set =
labels(
new ClassificationLabel("invoice-a", "Invoice", null),
new ClassificationLabel("invoice-b", "Invoice", null));
assertThatThrownBy(() -> LabelsValidator.validate(set))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Duplicate label name");
}
@Test
@DisplayName("rejects duplicate names differing only by case")
void rejectsDuplicateNamesCaseInsensitive() {
ClassificationLabels set =
labels(
new ClassificationLabel("invoice-a", "Invoice", null),
new ClassificationLabel("invoice-b", "INVOICE", null));
assertThatThrownBy(() -> LabelsValidator.validate(set))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Duplicate label name");
}
@Test
@DisplayName("rejects duplicate ids")
void rejectsDuplicateIds() {
ClassificationLabels set =
labels(
new ClassificationLabel("invoice", "Invoice", null),
new ClassificationLabel("invoice", "Sales invoice", null));
assertThatThrownBy(() -> LabelsValidator.validate(set))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Duplicate label id");
}
@Test
@DisplayName("rejects a blank name")
void rejectsBlankName() {
ClassificationLabels set = labels(new ClassificationLabel("blank", " ", null));
assertThatThrownBy(() -> LabelsValidator.validate(set))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Label name must not be blank");
}
@Test
@DisplayName("rejects a blank id")
void rejectsBlankId() {
ClassificationLabels set = labels(new ClassificationLabel(" ", "Invoice", null));
assertThatThrownBy(() -> LabelsValidator.validate(set))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Label id must not be blank");
}
@Test
@DisplayName("rejects an over-long name")
void rejectsOverLongName() {
ClassificationLabels set =
labels(
new ClassificationLabel(
"x", "x".repeat(LabelsValidator.MAX_TEXT_LENGTH + 1), null));
assertThatThrownBy(() -> LabelsValidator.validate(set))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("too long");
}
@Test
@DisplayName("rejects an over-long icon (a null icon is fine)")
void rejectsOverLongIcon() {
ClassificationLabels set =
labels(
new ClassificationLabel(
"invoice",
"Invoice",
"x".repeat(LabelsValidator.MAX_TEXT_LENGTH + 1)));
assertThatThrownBy(() -> LabelsValidator.validate(set))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("icon is too long");
}
@Test
@DisplayName("rejects more labels than the cap")
void rejectsTooManyLabels() {
List<ClassificationLabel> tooMany =
IntStream.rangeClosed(0, LabelsValidator.MAX_LABELS)
.mapToObj(i -> label("label" + i))
.toList();
assertThatThrownBy(() -> LabelsValidator.validate(new ClassificationLabels(tooMany)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Too many labels");
}
}
@@ -14,6 +14,7 @@ import static org.mockito.Mockito.when;
import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
@@ -26,8 +27,10 @@ import org.springframework.web.multipart.MultipartFile;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.service.PdfMetadataService;
import stirling.software.common.util.TempFileManager;
import stirling.software.proprietary.classification.ClassificationLabelProvider;
import stirling.software.proprietary.classification.model.ClassificationLabel;
import stirling.software.proprietary.classification.model.ClassificationLabels;
import stirling.software.proprietary.classification.store.InProcessClassificationLabelStore;
import stirling.software.proprietary.policy.config.PolicyManagementAuthority;
import stirling.software.proprietary.service.AiEngineClient;
import stirling.software.proprietary.service.PdfContentExtractor;
@@ -39,16 +42,22 @@ import tools.jackson.databind.json.JsonMapper;
@MockitoSettings(strictness = Strictness.LENIENT)
class ClassifyLabelControllerTest {
private static final Long TEAM = 7L;
@Mock private CustomPDFDocumentFactory pdfDocumentFactory;
@Mock private TempFileManager tempFileManager;
@Mock private PdfContentExtractor pdfContentExtractor;
@Mock private PdfMetadataService pdfMetadataService;
@Mock private AiEngineClient aiEngineClient;
@Mock private PolicyManagementAuthority policyManagementAuthority;
private final ObjectMapper objectMapper = JsonMapper.builder().build();
private InProcessClassificationLabelStore labelStore;
private ClassifyLabelController controller;
private void withLabels(List<ClassificationLabel> labels) {
@BeforeEach
void setUp() {
labelStore = new InProcessClassificationLabelStore();
controller =
new ClassifyLabelController(
pdfDocumentFactory,
@@ -57,8 +66,9 @@ class ClassifyLabelControllerTest {
pdfMetadataService,
aiEngineClient,
objectMapper,
ClassificationLabelProvider.withLabels(labels),
null);
null,
labelStore,
policyManagementAuthority);
}
private void stubSinglePageDocument() throws Exception {
@@ -88,7 +98,12 @@ class ClassifyLabelControllerTest {
@Test
void classifyAndLabel_writesClassificationWithoutOutcome() throws Exception {
withLabels(List.of(new ClassificationLabel("invoice", "Invoice", null)));
when(policyManagementAuthority.currentUserTeamId()).thenReturn(TEAM);
labelStore.save(
TEAM,
new ClassificationLabels(
List.of(new ClassificationLabel("invoice", "Invoice", null))),
"admin");
stubSinglePageDocument();
@@ -103,12 +118,16 @@ class ClassifyLabelControllerTest {
}
@Test
void classifyAndLabel_sendsLabelIdsAndNames() throws Exception {
withLabels(
List.of(
new ClassificationLabel("invoice", "Invoice", "receipt-long"),
new ClassificationLabel("contract", "Contract", null),
new ClassificationLabel("timesheet", "Timesheet", null)));
void classifyAndLabel_sendsTeamLabelIdsAndNames() throws Exception {
when(policyManagementAuthority.currentUserTeamId()).thenReturn(TEAM);
labelStore.save(
TEAM,
new ClassificationLabels(
List.of(
new ClassificationLabel("invoice", "Invoice", "receipt-long"),
new ClassificationLabel("contract", "Contract", null),
new ClassificationLabel("timesheet", "Timesheet", null))),
"admin");
stubSinglePageDocument();
@@ -133,13 +152,13 @@ class ClassifyLabelControllerTest {
}
@Test
void classifyAndLabel_skipsClassificationWhenNoLabels() throws Exception {
withLabels(List.of());
void classifyAndLabel_skipsClassificationWhenNothingStored() throws Exception {
when(policyManagementAuthority.currentUserTeamId()).thenReturn(TEAM);
stubSinglePageDocument();
// No vocabulary, and the engine holds no default of its own, so the file is passed through
// unlabelled: neither the engine nor the metadata write is invoked.
// No team labels stored, and the engine holds no default of its own, so the file is passed
// through unlabelled: neither the engine nor the metadata write is invoked.
verify(aiEngineClient, never()).post(anyString(), anyString(), any());
verify(pdfMetadataService, never())
.setClassificationMetadata(any(PDDocument.class), anyString());
@@ -166,8 +166,8 @@ class PolicyExecutorTest {
new PipelineStep(
createPdf,
Map.of(
"document",
"{\"title\":\"PO\",\"sections\":[]}",
"htmlContent",
"<p>hi</p>",
"filename",
"purchase-order.pdf"))),
PolicyInputs.of(List.of()),
@@ -1,139 +0,0 @@
package stirling.software.proprietary.service;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.junit.jupiter.api.Test;
import stirling.software.proprietary.model.api.ai.create.AiDocument;
class AiDocumentHtmlRendererTest {
private final AiDocumentHtmlRenderer renderer = new AiDocumentHtmlRenderer();
private static AiDocument.Section section(String type) {
AiDocument.Section s = new AiDocument.Section();
s.setType(type);
return s;
}
private static AiDocument document(String title, List<AiDocument.Section> sections) {
AiDocument doc = new AiDocument();
doc.setTitle(title);
doc.setSections(sections);
return doc;
}
@Test
void rendersAllSectionTypes() {
AiDocument.Section text = section("text");
text.setBody("Some prose text.");
AiDocument.Section kv = section("key_value");
kv.setPairs(List.of(List.of("Key", "Value")));
AiDocument.Section items = section("line_items");
items.setColumns(List.of("A", "B"));
items.setRows(List.of(List.of("1", "2")));
AiDocument.Section bullets = section("bullet_list");
bullets.setItems(List.of("item one"));
AiDocument.Section sign = section("signature");
sign.setSignatories(List.of("Alice"));
String html = renderer.render(document("All", List.of(text, kv, items, bullets, sign)));
assertTrue(html.contains("<!DOCTYPE html>"));
assertTrue(html.contains("Some prose text."));
assertTrue(html.contains("Key") && html.contains("Value"));
assertTrue(html.contains("<th>"));
assertTrue(html.contains("item one"));
assertTrue(html.contains("Alice"));
}
@Test
void rendersMarkupCharactersAsText() {
AiDocument.Section text = section("text");
text.setBody("a <b>x</b> & y");
String html = renderer.render(document("Doc", List.of(text)));
assertFalse(html.contains("<b>"));
assertTrue(html.contains("&lt;b&gt;"));
}
@Test
void totalRowRenderedWhenPresent() {
AiDocument.Section items = section("line_items");
items.setColumns(List.of("Item", "Total"));
items.setRows(List.of(List.of("Widget", "$10")));
items.setTotalRow(List.of("Total", "$10"));
assertTrue(
renderer.render(document("Table", List.of(items)))
.contains("<tr class=\"total-row\">"));
}
@Test
void totalRowAbsentWhenNotProvided() {
AiDocument.Section items = section("line_items");
items.setColumns(List.of("Item"));
items.setRows(List.of(List.of("Widget")));
assertFalse(
renderer.render(document("Table", List.of(items)))
.contains("<tr class=\"total-row\">"));
}
@Test
void rendersSubtitleAndReference() {
AiDocument doc = document("My Doc", List.of());
doc.setSubtitle("Subtitle Here");
doc.setReferenceNumber("REF-42");
String html = renderer.render(doc);
assertTrue(html.contains("Subtitle Here"));
assertTrue(html.contains("REF-42"));
}
@Test
void appliesHexColourOverride() {
AiDocument doc = document("Styled", List.of());
AiDocument.Style style = new AiDocument.Style();
style.setPrimaryColor("#ff00ff");
style.setBackgroundColor("#111111");
doc.setStyle(style);
String html = renderer.render(doc);
assertTrue(html.contains("--color-primary: #ff00ff"));
assertTrue(html.contains("--color-bg: #111111"));
}
@Test
void ignoresColourWithDisallowedCharacters() {
AiDocument doc = document("Styled", List.of());
AiDocument.Style style = new AiDocument.Style();
style.setPrimaryColor("rgb(255, 0, 0)");
doc.setStyle(style);
String html = renderer.render(doc);
assertFalse(html.contains("rgb("));
assertTrue(html.contains("<!DOCTYPE html>"));
}
@Test
void ignoresNonHexColour() {
AiDocument doc = document("Styled", List.of());
AiDocument.Style style = new AiDocument.Style();
style.setPrimaryColor("magenta");
style.setBackgroundColor("#fff");
doc.setStyle(style);
String html = renderer.render(doc);
assertFalse(html.contains("--color-primary: magenta"));
assertFalse(html.contains("--color-bg: #fff;"));
}
}
@@ -1,10 +0,0 @@
-- Classification labels are now a fixed, built-in set bundled with the app and sent to the engine
-- per request (see ClassificationLabelProvider); the per-team classification_labels table (created
-- in V30) is no longer read or written. Drop it.
--
-- Forward migration: V30 is kept so any DB that already applied it still validates. This runs after
-- V30 in every case, so it drops the table whether V30 just created it (fresh DB) or it was created
-- and populated on an earlier deploy. IF EXISTS only guards the edge case where the table is already
-- absent, keeping the migration safe to apply regardless of prior state.
DROP TABLE IF EXISTS classification_labels;
-9
View File
@@ -36,8 +36,6 @@ ext {
okhttpBomVersion = "5.3.2"
gsonVersion = "2.14.0"
guavaVersion = "33.6.0-jre"
jinjavaVersion = "2.8.3"
jackson2Version = "2.21.2"
bucket4jVersion = "8.19.0"
archunitVersion = "1.4.2"
batikVersion = "1.19"
@@ -224,13 +222,6 @@ subprojects {
resolutionStrategy.force "org.apache.commons:commons-lang3:${commonsLang3}"
// CVE-2024-47554: commons-io DoS prevention
resolutionStrategy.force "commons-io:commons-io:${commonsIoVersion}"
// Jackson 2 is transitive-only here (jinjava, opensaml, jjwt request older versions);
// pin the family to a current release and keep modules aligned.
resolutionStrategy.force "com.fasterxml.jackson.core:jackson-core:${jackson2Version}"
resolutionStrategy.force "com.fasterxml.jackson.core:jackson-databind:${jackson2Version}"
resolutionStrategy.force "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jackson2Version}"
resolutionStrategy.force "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jackson2Version}"
resolutionStrategy.force "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jackson2Version}"
// Keep BouncyCastle modules aligned to avoid runtime linkage errors
resolutionStrategy.force "org.bouncycastle:bcprov-jdk18on:${bouncycastleVersion}"
resolutionStrategy.force "org.bouncycastle:bcpkix-jdk18on:${bouncycastleVersion}"
+1
View File
@@ -5,6 +5,7 @@ description = "AI Document Engine"
requires-python = ">=3.13"
dependencies = [
"fastapi>=0.116.0",
"jinja2>=3.1.0",
"pgvector>=0.3.6",
"psycopg[binary,pool]>=3.2",
"pydantic>=2.0.0",
@@ -116,8 +116,8 @@ class DocumentClassifierAgent:
)
async def classify(self, request: ClassifyDocumentRequest) -> ClassifyDocumentResponse:
# The caller (the backend) always supplies the allowed vocabulary — its
# fixed built-in label set — so the engine holds no vocabulary of its own.
# The caller (the backend) always supplies the allowed vocabulary — the
# team's stored labels — so the engine holds no vocabulary of its own.
allowed = request.labels
window = select_window(request.pages)
prompt = self._build_prompt(request.file_name, allowed, window)
+29 -12
View File
@@ -10,7 +10,7 @@ Flow:
4. SectionWriterAgents (smart_model) run in parallel via asyncio.gather.
Each returns a WrittenSections with fully populated DocumentSection objects.
5. The assembler collects sections in plan order → GeneratedDocument.
6. The assembled document is emitted as structured fields. The LLM never writes HTML.
6. Jinja renders the document to HTML. The LLM never writes HTML.
The planner is split into two calls (meta then sections) so each LLM output schema
stays small enough for grammar compilation on all model tiers including Haiku.
@@ -22,7 +22,9 @@ import asyncio
import logging
import re
from dataclasses import dataclass
from pathlib import Path
from jinja2 import Environment, FileSystemLoader
from pydantic_ai import Agent
from pydantic_ai.output import NativeOutput
@@ -49,6 +51,8 @@ from stirling.services import AppRuntime
logger = logging.getLogger(__name__)
_TEMPLATES_DIR = Path(__file__).parent / "templates"
# ── Token budget ──────────────────────────────────────────────────────────────────────────────────
# Conservative per-section token estimates mapped from planner-assigned depth.
@@ -162,13 +166,10 @@ Analyse the user's request and produce a DocumentMeta with:
document, if the user provides one. Leave empty if the user provides no such context.
- style_primary_color: accent and heading colour. Set ONLY when the user explicitly names a
colour or colour scheme (e.g. "make it red", "use navy blue"). Express it as a 6-digit hex
code in #RRGGBB format (map any named colour to its hex value yourself, e.g. "navy" →
"#000080"). No other format is accepted. Leave null if no colour is stated.
- style_background_color: page background colour, same #RRGGBB format. Set only if explicitly
requested.
- style_body_text_color: body text colour, same #RRGGBB format. Set only if explicitly
requested.
colour or colour scheme (e.g. "make it red", "use navy blue"). Use CSS named colours
(e.g. "magenta", "navy", "crimson") or hex values. Leave null if no colour is stated.
- style_background_color: page background colour. Set only if explicitly requested.
- style_body_text_color: body text colour. Set only if explicitly requested.
- cannot_do_reason: set this ONLY when the request is not asking to create a document at all
(e.g. a question, a greeting, an edit request to an existing document). Never set it
@@ -298,6 +299,15 @@ def _build_writer_prompt(plan: DocumentPlan, chunk: _Chunk) -> str:
# ── Helpers ───────────────────────────────────────────────────────────────────────────────────────
def _build_jinja_env() -> Environment:
return Environment(
loader=FileSystemLoader(str(_TEMPLATES_DIR)),
autoescape=True,
trim_blocks=True,
lstrip_blocks=True,
)
def _safe_filename(title: str) -> str:
slug = re.sub(r"[^\w\s-]", "", title.lower())
slug = re.sub(r"[\s_-]+", "-", slug).strip("-")
@@ -310,6 +320,7 @@ def _safe_filename(title: str) -> str:
class PdfCreateAgent:
def __init__(self, runtime: AppRuntime) -> None:
self.runtime = runtime
self._jinja_env = _build_jinja_env()
self._meta_planner: Agent[None, DocumentMeta] = Agent(
model=runtime.smart_model,
@@ -390,12 +401,14 @@ class PdfCreateAgent:
sections=all_sections,
)
# ── Phase 6: emit ──────────────────────────────────────────────────────
# ── Phase 6: render ────────────────────────────────────────────────────
logger.info("[pdf-create] phase 6/6: rendering HTML")
html = self._render(doc)
filename = _safe_filename(plan.title)
logger.info(
"[pdf-create] done — filename=%r sections=%d",
"[pdf-create] done — filename=%r html_bytes=%d",
filename,
len(all_sections),
len(html),
)
return EditPlanResponse(
@@ -404,7 +417,7 @@ class PdfCreateAgent:
ToolOperationStep(
tool=AgentToolId.CREATE_PDF_FROM_HTML_AGENT,
parameters=CreatePdfFromHtmlAgentParams(
document=doc.model_dump_json(),
html_content=html,
filename=filename,
),
)
@@ -424,3 +437,7 @@ class PdfCreateAgent:
len(result.output.sections),
)
return result.output
def _render(self, doc: GeneratedDocument) -> str:
template = self._jinja_env.get_template("document.html.jinja2")
return template.render(doc=doc)
@@ -1,4 +1,3 @@
{%- autoescape true -%}
<!DOCTYPE html>
<html lang="en">
<head>
@@ -176,18 +175,18 @@
color: var(--color-label);
}
</style>
{%- if style_primary or style_background or style_body %}
{%- if doc.style %}
<style>
:root {
{%- if style_primary %}
--color-primary: {{ style_primary }};
{%- if doc.style.primary_color %}
--color-primary: {{ doc.style.primary_color }};
{%- endif %}
{%- if style_background %}
--color-bg: {{ style_background }};
{%- if doc.style.background_color %}
--color-bg: {{ doc.style.background_color }};
{%- endif %}
{%- if style_body %}
--color-body: {{ style_body }};
--color-label: {{ style_body }};
{%- if doc.style.body_text_color %}
--color-body: {{ doc.style.body_text_color }};
--color-label: {{ doc.style.body_text_color }};
{%- endif %}
}
</style>
@@ -196,16 +195,16 @@
<body>
<div class="doc-header">
<div class="doc-title">{{ title }}</div>
{%- if subtitle %}
<div class="doc-subtitle">{{ subtitle }}</div>
<div class="doc-title">{{ doc.title }}</div>
{%- if doc.subtitle %}
<div class="doc-subtitle">{{ doc.subtitle }}</div>
{%- endif %}
{%- if reference_number %}
<div class="doc-reference">{{ reference_number }}</div>
{%- if doc.reference_number %}
<div class="doc-reference">{{ doc.reference_number }}</div>
{%- endif %}
</div>
{%- for section in sections %}
{%- for section in doc.sections %}
{%- if section.type == "text" %}
<section>
@@ -213,8 +212,8 @@
<h2>{{ section.heading }}</h2>
{%- endif %}
<div class="text-body">
{%- for para in section.paragraphs %}
<p>{{ para }}</p>
{%- for para in section.body.split('\n\n') %}
<p>{{ para | replace('\n', ' ') }}</p>
{%- endfor %}
</div>
</section>
@@ -226,10 +225,10 @@
{%- endif %}
<table class="kv-table">
<tbody>
{%- for pair in section.pairs %}
{%- for label, value in section.pairs %}
<tr>
<td class="kv-label">{{ pair.label }}</td>
<td class="kv-value">{{ pair.value }}</td>
<td class="kv-label">{{ label }}</td>
<td class="kv-value">{{ value }}</td>
</tr>
{%- endfor %}
</tbody>
@@ -300,4 +299,3 @@
</body>
</html>
{%- endautoescape %}
+8 -6
View File
@@ -1,14 +1,14 @@
"""Contracts for the PDF Create Agent.
The agent accepts a natural-language prompt and returns a single
CREATE_PDF_FROM_HTML_AGENT plan step carrying the assembled document.
CREATE_PDF_FROM_HTML_AGENT plan step carrying the rendered HTML.
Pipeline:
1. PlannerAgent (smart_model) → DocumentPlan: structured skeleton, no body text.
2. Python chunks the plan by token budget.
3. SectionWriterAgents (smart_model, parallel) → WrittenSections per chunk.
4. Assembler collects sections in plan order → GeneratedDocument.
5. The document is emitted as structured fields. The LLM never writes HTML.
5. Jinja renders GeneratedDocument → HTML. The LLM never writes HTML.
"""
from __future__ import annotations
@@ -81,12 +81,14 @@ type DocumentSection = Annotated[
]
# Colours must be a 6-digit hex code (#RRGGBB); anything else is dropped to None.
_SAFE_COLOR_RE = re.compile(r"^#[0-9a-fA-F]{6}$")
# Named colour or hex only — anything else is dropped so a colour can't inject CSS into the
# <style> block (which would let WeasyPrint fetch an attacker-controlled url() → SSRF).
_SAFE_COLOR_RE = re.compile(r"^#[0-9a-fA-F]{3,8}$|^[a-zA-Z]{1,30}$")
class DocumentStyle(ApiModel):
"""Document colours, inferred by the meta planner. Non-hex values are dropped to ``None``."""
"""Document colours, inferred by the meta planner and rendered into the engine's Jinja
template (never sent to Java). Unsafe colours are dropped to ``None``."""
primary_color: str | None = Field(default=None)
background_color: str | None = Field(default=None)
@@ -101,7 +103,7 @@ class DocumentStyle(ApiModel):
class GeneratedDocument(ApiModel):
"""The full document model emitted for rendering."""
"""The full document model passed to Jinja for HTML rendering."""
title: str
subtitle: str | None = None
@@ -29,7 +29,7 @@ class PdfCommentAgentParams(ApiModel):
class CreatePdfFromHtmlAgentParams(ApiModel):
document: str
html_content: str
filename: str = Field(pattern=r"^.+\.pdf$")
+148 -29
View File
@@ -2,7 +2,7 @@
Coverage:
1. Section model validation (each section type round-trips correctly)
2. orchestrate() emits the assembled document as structured JSON
2. Jinja rendering (_render produces valid HTML for each section type)
3. _safe_filename produces clean slugs
4. _make_chunks groups sections correctly by token budget
5. orchestrate() produces the correct EditPlanResponse via planner + writer mocks
@@ -12,8 +12,6 @@ Coverage:
from __future__ import annotations
import json
import pytest
from conftest import build_app_settings
from pydantic_ai.models.test import TestModel
@@ -66,6 +64,37 @@ def agent(runtime: AppRuntime) -> PdfCreateAgent:
# ── Helpers ───────────────────────────────────────────────────────────────────────────────────────
def _invoice_doc() -> GeneratedDocument:
return GeneratedDocument(
title="Invoice",
subtitle="Acme Corp",
reference_number="Invoice #INV-001",
sections=[
KeyValueSection(
heading="Details",
pairs=[("Date", "2026-05-06"), ("Due", "2026-06-06"), ("Currency", "USD")],
),
LineItemsSection(
heading="Line Items",
columns=["Description", "Qty", "Unit Price", "Total"],
rows=[
["Consulting services", "10", "$500.00", "$5,000.00"],
["Expenses", "1", "$200.00", "$200.00"],
],
total_row=["Total", "", "", "$5,200.00"],
),
TextSection(
heading="Payment Terms",
body="Payment is due within 30 days.\n\nPlease reference the invoice number.",
),
SignatureSection(
heading="Authorised By",
signatories=["Jane Smith, CEO", "Bob Jones, CFO"],
),
],
)
def _simple_meta() -> DocumentMeta:
return DocumentMeta(
title="Invoice",
@@ -170,6 +199,82 @@ def test_generated_document_optional_fields() -> None:
assert doc.reference_number is None
# ── Jinja rendering ───────────────────────────────────────────────────────────────────────────────
def test_render_produces_html(agent: PdfCreateAgent) -> None:
doc = _invoice_doc()
html = agent._render(doc)
assert "<!DOCTYPE html>" in html
assert "Invoice" in html
assert "INV-001" in html
def test_render_includes_all_section_types(agent: PdfCreateAgent) -> None:
doc = GeneratedDocument(
title="All Sections",
sections=[
TextSection(body="Some prose text."),
KeyValueSection(pairs=[("Key", "Value")]),
LineItemsSection(columns=["A", "B"], rows=[["1", "2"]]),
BulletListSection(items=["item one"]),
SignatureSection(signatories=["Alice"]),
],
)
html = agent._render(doc)
assert "Some prose text." in html
assert "Key" in html and "Value" in html
assert "<th>" in html
assert "item one" in html
assert "Alice" in html
def test_render_escapes_html_in_content(agent: PdfCreateAgent) -> None:
doc = GeneratedDocument(
title="XSS Test",
sections=[TextSection(body="<script>alert('xss')</script>")],
)
html = agent._render(doc)
assert "<script>" not in html
assert "&lt;script&gt;" in html
def test_render_total_row_present(agent: PdfCreateAgent) -> None:
doc = GeneratedDocument(
title="Table",
sections=[
LineItemsSection(
columns=["Item", "Total"],
rows=[["Widget", "$10"]],
total_row=["Total", "$10"],
)
],
)
html = agent._render(doc)
assert "total-row" in html
def test_render_no_total_row_skips_tfoot(agent: PdfCreateAgent) -> None:
doc = GeneratedDocument(
title="Table",
sections=[LineItemsSection(columns=["Item"], rows=[["Widget"]])],
)
html = agent._render(doc)
assert "<tfoot>" not in html
def test_render_subtitle_and_reference(agent: PdfCreateAgent) -> None:
doc = GeneratedDocument(
title="My Doc",
subtitle="Subtitle Here",
reference_number="REF-42",
sections=[TextSection(body="Content.")],
)
html = agent._render(doc)
assert "Subtitle Here" in html
assert "REF-42" in html
# ── _safe_filename ────────────────────────────────────────────────────────────────────────────────
@@ -291,9 +396,8 @@ async def test_orchestrate_returns_plan_step(agent: PdfCreateAgent) -> None:
assert step.tool == AgentToolId.CREATE_PDF_FROM_HTML_AGENT
assert isinstance(step.parameters, CreatePdfFromHtmlAgentParams)
assert step.parameters.filename.endswith(".pdf")
parsed = json.loads(step.parameters.document)
assert parsed["title"] == "Invoice"
assert parsed["sections"]
assert "<!DOCTYPE html>" in step.parameters.html_content
assert "Invoice" in step.parameters.html_content
@pytest.mark.anyio
@@ -364,9 +468,9 @@ async def test_orchestrate_assembles_multiple_chunks(agent: PdfCreateAgent) -> N
result = await agent.orchestrate(_orchestrator_request("Create a multi-chunk doc"))
assert isinstance(result, EditPlanResponse)
document = result.steps[0].parameters.document # type: ignore[union-attr]
assert "Introduction text." in document
assert "Details" in document
html = result.steps[0].parameters.html_content # type: ignore[union-attr]
assert "Introduction text." in html
assert "Details" in html
# ── Style inference ───────────────────────────────────────────────────────────────────────────────
@@ -378,7 +482,7 @@ async def test_orchestrate_applies_planner_inferred_style(agent: PdfCreateAgent)
meta = DocumentMeta(
title="Styled Doc",
tone_brief="Professional.",
style_primary_color="#ff00ff",
style_primary_color="magenta",
)
sections = _simple_sections()
written = _written_sections()
@@ -395,35 +499,50 @@ async def test_orchestrate_applies_planner_inferred_style(agent: PdfCreateAgent)
result = await agent.orchestrate(_orchestrator_request("Make an invoice, magenta styling"))
assert isinstance(result, EditPlanResponse)
document = result.steps[0].parameters.document # type: ignore[union-attr]
assert json.loads(document)["style"]["primaryColor"] == "#ff00ff"
html = result.steps[0].parameters.html_content # type: ignore[union-attr]
assert "magenta" in html
def test_document_style_keeps_only_six_digit_hex() -> None:
"""Only #RRGGBB hex is kept; named colours and other formats drop to None."""
safe = DocumentStyle(primary_color="#1e3a5f", background_color="#ffffff", body_text_color="#1A1A1A")
def test_render_applies_style(agent: PdfCreateAgent) -> None:
"""DocumentStyle fields are injected as CSS custom properties in the rendered HTML."""
doc = GeneratedDocument(
title="Styled",
sections=[TextSection(body="Content.")],
style=DocumentStyle(primary_color="magenta", background_color="#111111"),
)
html = agent._render(doc)
assert "--color-primary: magenta" in html
assert "--color-bg: #111111" in html
def test_document_style_drops_unsafe_colors() -> None:
"""Unsafe colours (not named/hex) are dropped, closing the <style> url() injection."""
safe = DocumentStyle(primary_color="navy", background_color="#1e3a5f", body_text_color="#fff")
assert (safe.primary_color, safe.background_color, safe.body_text_color) == (
"navy",
"#1e3a5f",
"#ffffff",
"#1A1A1A",
"#fff",
)
assert DocumentStyle(primary_color="navy").primary_color is None
assert DocumentStyle(primary_color="#fff").primary_color is None
assert DocumentStyle(primary_color="#1e3a5f00").primary_color is None
assert DocumentStyle(primary_color="rgb(255, 0, 0)").primary_color is None
assert DocumentStyle(background_color="teal darken-2").background_color is None
unsafe = DocumentStyle(
primary_color="red; background: url(http://evil.test/steal)",
background_color="expression(alert(1))",
body_text_color="navy; }",
)
assert unsafe.primary_color is None
assert unsafe.background_color is None
assert unsafe.body_text_color is None
# A trailing newline must not slip a value through (fullmatch, not $-before-newline).
assert DocumentStyle(primary_color="#1e3a5f\n").primary_color is None
assert DocumentStyle(primary_color="navy\n").primary_color is None
@pytest.mark.anyio
async def test_orchestrate_drops_non_hex_planner_colour(agent: PdfCreateAgent) -> None:
"""A non-hex colour inferred by the meta planner is dropped before the document is emitted."""
async def test_orchestrate_drops_unsafe_planner_color(agent: PdfCreateAgent) -> None:
"""An unsafe colour inferred by the meta planner never reaches the rendered HTML."""
meta = DocumentMeta(
title="Doc",
tone_brief="Professional.",
style_primary_color="rgb(0, 0, 255)",
style_primary_color="blue; background: url(http://evil.test/)",
)
sections = _simple_sections()
written = _written_sections()
@@ -440,6 +559,6 @@ async def test_orchestrate_drops_non_hex_planner_colour(agent: PdfCreateAgent) -
result = await agent.orchestrate(_orchestrator_request("make it blue"))
assert isinstance(result, EditPlanResponse)
document = result.steps[0].parameters.document # type: ignore[union-attr]
assert "rgb(" not in document
assert json.loads(document)["style"]["primaryColor"] is None
html = result.steps[0].parameters.html_content # type: ignore[union-attr]
assert "evil.test" not in html
assert "url(" not in html
+2
View File
@@ -604,6 +604,7 @@ version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "fastapi" },
{ name = "jinja2" },
{ name = "opentelemetry-sdk" },
{ name = "pgvector" },
{ name = "posthog" },
@@ -630,6 +631,7 @@ dev = [
[package.metadata]
requires-dist = [
{ name = "fastapi", specifier = ">=0.116.0" },
{ name = "jinja2", specifier = ">=3.1.0" },
{ name = "opentelemetry-sdk", specifier = ">=1.39.0" },
{ name = "pgvector", specifier = ">=0.3.6" },
{ name = "posthog", specifier = ">=3.0.0" },
+4
View File
@@ -38,6 +38,10 @@ const config: StorybookConfig = {
// modules (e.g. the auth supabase client that moved into proprietary).
"@proprietary": resolve(__dirname, "../editor/src/proprietary"),
"@core": resolve(__dirname, "../editor/src/core"),
// Public assets (e.g. the en-US translation TOML loaded ?raw by preview.tsx).
// No src alias covers public/, so this lets the config use an alias rather
// than a relative path.
"@public": resolve(__dirname, "../editor/public"),
};
// Editor stories import via @app/* (proprietary→core fallback), @core/* and
// @proprietary/*. Resolve them exactly the way the editor's own build does —
+41 -2
View File
@@ -17,6 +17,8 @@ import { LinkProvider, type LinkState } from "@portal/contexts/LinkContext";
import { ThemeProvider, useTheme } from "@portal/contexts/ThemeContext";
import { UIProvider } from "@portal/contexts/UIContext";
import { SuiProvider } from "@portal/theme/SuiProvider";
import { deriveAccessiblePrimary } from "@core/utils/customPrimary";
import { DEFAULT_ACCENT_COLOR } from "@core/constants/theme";
import { handlers } from "@portal/mocks/handlers";
import { configureSupabase } from "@proprietary/auth/supabase/supabaseClient";
import i18next from "i18next";
@@ -24,11 +26,11 @@ import { initReactI18next } from "react-i18next";
import { parse as parseToml } from "smol-toml";
// Load the real English copy so stories render human text, not raw keys. Bundled
// synchronously via ?raw so it's present on the very first render (no async flash).
// eslint-disable-next-line no-restricted-imports -- Storybook-only: read the public i18n asset; no @-alias covers editor/public/.
import enTranslationToml from "../editor/public/locales/en-US/translation.toml?raw";
import enTranslationToml from "@public/locales/en-US/translation.toml?raw";
import "@mantine/core/styles.css";
import "@core/tokens/tokens.css";
import "@core/theme/index.css";
import "@core/tokens/base.css";
// Storybook-only: init react-i18next with the real English resources parsed from
@@ -124,6 +126,33 @@ function ThemeBridge({
return <>{children}</>;
}
/**
* Tints the canvas from the toolbar accent picker (see .storybook/manager.tsx),
* exactly like the editor: always `data-app-theme="custom"`, with
* --user-primary/-on/-accent-fg derived from the active mode's accent global.
*/
function AccentInjector({
scheme,
accent,
}: {
scheme: "light" | "dark";
accent: string;
}) {
useEffect(() => {
const root = document.documentElement;
root.setAttribute("data-app-theme", "custom");
root.setAttribute("data-mantine-color-scheme", scheme);
const { primary, onPrimary, accentForeground } = deriveAccessiblePrimary(
accent,
scheme,
);
root.style.setProperty("--user-primary", primary);
root.style.setProperty("--user-primary-on", onPrimary);
root.style.setProperty("--user-accent-fg", accentForeground);
}, [scheme, accent]);
return null;
}
const withProviders: Decorator = (Story, context) => {
const tier = (context.globals.tier as Tier) ?? "pro";
const linkState =
@@ -135,9 +164,15 @@ const withProviders: Decorator = (Story, context) => {
// anything that isn't "dark" as light — matching the addon's own
// `selected || defaultTheme` fallback where defaultTheme is light.
const colorScheme = context.globals.theme === "dark" ? "dark" : "light";
// Each mode has its own accent (set by the toolbar accent picker).
const accent =
(colorScheme === "dark"
? (context.globals.accentDark as string)
: (context.globals.accentLight as string)) ?? DEFAULT_ACCENT_COLOR;
return (
<MemoryRouter initialEntries={["/"]}>
<ThemeProvider>
<AccentInjector scheme={colorScheme} accent={accent} />
<ThemeBridge theme={colorScheme}>
<SuiProvider colorScheme={colorScheme}>
{/* LinkProvider must wrap TierProvider: TierContext derives its tier
@@ -182,6 +217,10 @@ const preview: Preview = {
},
},
globalTypes: {
// Per-mode accent colours, driven by the custom toolbar picker in
// .storybook/manager.tsx (no built-in toolbar UI of their own).
accentLight: { name: "Accent (light)", defaultValue: DEFAULT_ACCENT_COLOR },
accentDark: { name: "Accent (dark)", defaultValue: DEFAULT_ACCENT_COLOR },
tier: {
name: "Tier",
description: "Subscription tier — drives useTier() everywhere",
+2 -1
View File
@@ -12,7 +12,8 @@
],
"@core/*": ["../editor/src/core/*"],
"@proprietary/*": ["../editor/src/proprietary/*"],
"@portal/*": ["../editor/src/portal/*"]
"@portal/*": ["../editor/src/portal/*"],
"@public/*": ["../editor/public/*"]
},
"resolveJsonModule": true,
"esModuleInterop": true,
+45
View File
@@ -14,6 +14,51 @@
<link rel="manifest" href="manifest.json" />
<title>Stirling PDF</title>
<!-- Apply theme + accent before first paint (no FOUC); mirrors ThemeProvider, which then refines it. -->
<script>
(function () {
try {
var p = JSON.parse(
localStorage.getItem("stirlingpdf_preferences") || "{}",
);
var mode = p.theme || "system";
var scheme =
mode === "light"
? "light"
: mode === "dark"
? "dark"
: window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
var stored = scheme === "dark" ? p.darkPrimary : p.lightPrimary;
// "default" (or unset) = neutral surfaces + blue buttons; a hex tints.
var isDefault = !stored || stored === "default";
var accent = isDefault ? "#3b82f6" : stored;
var r = document.documentElement;
r.setAttribute("data-theme", scheme);
r.setAttribute("data-app-theme", "custom");
r.setAttribute("data-accent", isDefault ? "default" : "custom");
r.setAttribute("data-mantine-color-scheme", scheme);
r.style.setProperty("--user-primary", accent);
r.style.setProperty("--user-accent-fg", accent);
var h = accent.replace("#", "");
if (h.length === 3) h = h.replace(/./g, "$&$&");
var lum =
(0.2126 * parseInt(h.slice(0, 2), 16) +
0.7152 * parseInt(h.slice(2, 4), 16) +
0.0722 * parseInt(h.slice(4, 6), 16)) /
255;
r.style.setProperty(
"--user-primary-on",
lum > 0.7 ? "#000000" : "#ffffff",
);
} catch (e) {
/* first visit / unavailable storage: ThemeProvider handles it */
}
})();
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
@@ -3708,6 +3708,8 @@ openFromComputer = "Open from computer"
openSettings = "Open settings"
other = "Other"
recent = "Recent"
search = "Search"
searchPlaceholder = "Search files..."
viewAll = "View all {{count}} files"
[fileSidebar.fileItem]
@@ -3747,6 +3749,7 @@ backToMyFiles = "Back to My Files"
breadcrumbs = "Folder path"
cancel = "Cancel"
classification = "Classification"
clearSearch = "Clear search"
clearSelection = "Clear selection"
closeDetails = "Close details"
create = "Create"
@@ -3810,6 +3813,8 @@ resizeFolderTree = "Resize folder tree (arrow keys, Shift for bigger steps; doub
save = "Save"
saveToServer = "Save to server"
saveToServerDisabledHint = "Saving to the server isn't enabled on this server. Ask your admin to enable it."
search = "Search"
searchPlaceholder = "Search this folder & subfolders"
selectAll = "Select all"
selectAllHint = "Click to select all. Tip: hold Ctrl (or Cmd) to add files one at a time, Shift to select a range."
selectedCount = "{{count}} selected"
@@ -3869,10 +3874,6 @@ title = "No cloud files yet"
hint = "Files saved without uploading stay here. Drop a file to add one."
title = "No local-only files"
[filesPage.empty.noResults]
hint = "No files in this folder match your filter. Try a different term or clear the filter."
title = "No matching files"
[filesPage.empty.recent]
hint = "Files you open or edit will appear here."
title = "Nothing modified yet"
@@ -3944,11 +3945,6 @@ localHint = "Only stored in this browser"
shared = "Shared"
sharedHint = "Shared with you via link"
[filesPage.search]
clear = "Clear filter"
label = "Filter files by name"
placeholder = "Filter files…"
[filesPage.sort]
modifiedAsc = "Oldest first"
modifiedDesc = "Recent first"
@@ -7895,6 +7891,15 @@ viewAll = "View all"
description = "Pipeline runs, deploys and agent events will appear here."
title = "Nothing here yet"
[portal.search]
ariaLabel = "Search"
placeholder = "Search Stirling — endpoints, pipelines, docs…"
[portal.search.empty]
noActionsDescription = "Quick actions will appear here once they're available."
noActionsTitle = "No quick actions"
noMatches = "No matches for \"{{query}}\""
noMatchesDescription = "Try a different keyword or browse the catalogue."
[portal.settings.groups]
admin = "Admin"
@@ -9717,17 +9722,6 @@ title = "Upload to Server"
updateButton = "Update on Server"
uploadButton = "Upload to Server"
[superSearch]
ariaLabel = "Super search"
hint = "Type to search"
placeholder = "Search Stirling"
[superSearch.group]
files = "Files"
processor = "Processor"
settings = "Settings"
tools = "Tools"
[survey]
title = "Stirling-PDF Survey"
@@ -10717,7 +10711,6 @@ exitRedaction = "Exit Redaction Mode"
exportAll = "Export PDF"
exportSelected = "Export Selected Pages"
formFill = "Fill Form"
hideToolbar = "Hide toolbar"
multiTool = "Multi-Tool"
panMode = "Pan Mode"
print = "Print PDF"
@@ -10737,7 +10730,6 @@ selectAll = "Select All"
selectByNumber = "Select by Page Numbers"
selectLanguage = "Select language"
share = "Share"
showToolbar = "Show toolbar"
toggleAnnotations = "Toggle Annotations Visibility"
toggleAttachments = "Toggle Attachments"
toggleBookmarks = "Toggle Bookmarks"
@@ -3719,6 +3719,8 @@ openFromComputer = "Open from computer"
openSettings = "Open settings"
other = "Other"
recent = "Recent"
search = "Search"
searchPlaceholder = "Search files..."
viewAll = "View all {{count}} files"
[fileSidebar.fileItem]
@@ -3732,9 +3734,20 @@ uploadToServer = "Upload to server"
versionHistory = "Version history"
[fileSidebar.groupsModal]
add = "Add"
addLabel = "Add a label…"
categoryIconAria = "Choose an icon for {{name}}"
createCategory = "Create category"
delete = "Delete category"
done = "Done"
reset = "Show all"
subtitle = "Show or hide categories in the files sidebar."
hide = "Hide category"
newCategory = "New category name…"
removeLabel = "Remove {{name}}"
rename = "Rename"
reset = "Reset to defaults"
search = "Search labels…"
show = "Show category"
subtitle = "Group your files into parent categories. Add existing or new labels to a category, rename it, or create your own. Files in none of your categories appear under “Other”."
title = "Sidebar categories"
[filesPage]
@@ -3747,6 +3760,7 @@ backToMyFiles = "Back to My Files"
breadcrumbs = "Folder path"
cancel = "Cancel"
classification = "Classification"
clearSearch = "Clear search"
clearSelection = "Clear selection"
closeDetails = "Close details"
create = "Create"
@@ -3810,6 +3824,8 @@ resizeFolderTree = "Resize folder tree (arrow keys, Shift for bigger steps; doub
save = "Save"
saveToServer = "Save to server"
saveToServerDisabledHint = "Saving to the server isn't enabled on this server. Ask your admin to enable it."
search = "Search"
searchPlaceholder = "Search this folder & subfolders"
selectAll = "Select all"
selectAllHint = "Click to select all. Tip: hold Ctrl (or Cmd) to add files one at a time, Shift to select a range."
selectedCount = "{{count}} selected"
@@ -3869,10 +3885,6 @@ title = "No cloud files yet"
hint = "Files saved without uploading stay here. Drop a file to add one."
title = "No local-only files"
[filesPage.empty.noResults]
hint = "No files in this folder match your filter. Try a different term or clear the filter."
title = "No matching files"
[filesPage.empty.recent]
hint = "Files you open or edit will appear here."
title = "Nothing modified yet"
@@ -3944,11 +3956,6 @@ localHint = "Only stored in this browser"
shared = "Shared"
sharedHint = "Shared with you via link"
[filesPage.search]
clear = "Clear filter"
label = "Filter files by name"
placeholder = "Filter files…"
[filesPage.sort]
modifiedAsc = "Oldest first"
modifiedDesc = "Recent first"
@@ -6007,11 +6014,31 @@ summaryMore = "{{first}}, {{second}} and {{more}} more"
summaryTwo = "{{first}} and {{second}}"
[policies.labels]
categoryCount = "categories"
hideCategory = "Hide category"
labelCount = "labels"
sharedNote = "These labels are built in and shared across your whole team."
showCategory = "Show category"
add = "Add"
addPlaceholder = "Add a label…"
customNote = "Customized for your team."
defaultNote = "Using the built-in default, shared with your team."
duplicate = "\"{{name}}\" already exists."
edit = "Edit labels"
empty = "No labels yet."
export = "Export JSON"
iconAria = "Choose an icon for {{name}}"
import = "Import JSON"
importError = "Couldn't import that file."
managedNote = "Team labels are managed by your team leader."
modalSubtitle = "Shared with your whole team. The classifier picks the labels that fit each document."
modalTitle = "Classification labels"
pickIcon = "Use {{label}} icon"
removeAria = "Remove {{name}}"
resetToDefault = "Reset to default"
saveForTeam = "Save for team"
saving = "Saving…"
sectionLabel = "Classification labels"
startFromScratch = "Start from scratch"
teamCount = "team labels"
tooLong = "Labels can be at most {{max}} characters."
ungrouped = "Ungrouped"
view = "View labels"
[policies.pii]
account = "Account numbers (labelled)"
@@ -7424,11 +7451,6 @@ title = "Policies"
[portal.policies.card]
comingSoon = "Upgrade to Enterprise"
notSetUp = "Not set up"
requiresAiEngine = "Requires AI engine"
[portal.policies.categories.classification]
desc = "Identify each document's type on upload and tag its metadata for filing and search."
label = "Classification"
[portal.policies.categories.compliance]
desc = "Enforce HIPAA, GDPR, SOC 2, or FedRAMP requirements on every document."
@@ -7453,13 +7475,6 @@ label = "Security"
[portal.policies.config]
scopeAll = "All documents"
[portal.policies.config.classification]
summary = "Classifies every uploaded document against your team's labels and tags its metadata."
[portal.policies.config.classification.rules]
0 = "Classify"
1 = "Tag metadata"
[portal.policies.config.compliance]
summary = "Validates documents against regulatory frameworks before they leave the system."
@@ -7554,7 +7569,6 @@ title = "No activity yet"
[portal.policies.endpoints]
addWatermark = "Watermark"
autoRedact = "Redact PII"
classifyAndLabel = "Classify"
compressPdf = "Compress"
flatten = "Flatten"
ocrPdf = "OCR"
@@ -7597,10 +7611,6 @@ continue = "Continue"
enablePolicy = "Enable policy"
saveChanges = "Save changes"
[portal.policies.wizard.capability.classify]
desc = "Identifies the document's type from your team's labels and tags it, so it files and searches by category."
label = "Classify the document"
[portal.policies.wizard.capability.compress]
desc = "Compresses the document to a smaller file size."
label = "Reduce file size"
@@ -7625,10 +7635,6 @@ label = "Strip active content"
desc = "Stamps a visible mark (e.g. “Confidential”) across every page."
label = "Apply a watermark"
[portal.policies.wizard.classification]
description = "Every uploaded document is classified against the built-in labels and tagged with the types that fit. The label set is shared across your whole team."
labelsHeading = "Classification labels"
[portal.policies.wizard.errors]
noTools = "Enable at least one tool in the workflow first."
saveFailed = "Couldn't save the policy. Please try again."
@@ -7985,6 +7991,16 @@ viewAll = "View all"
description = "Pipeline runs, deploys and agent events will appear here."
title = "Nothing here yet"
[portal.search]
ariaLabel = "Search"
placeholder = "Search Stirling — endpoints, pipelines, docs…"
[portal.search.empty]
noActionsDescription = "Quick actions will appear here once they're available."
noActionsTitle = "No quick actions"
noMatches = "No matches for \"{{query}}\""
noMatchesDescription = "Try a different keyword or browse the catalogue."
[portal.settings.groups]
admin = "Admin"
@@ -8991,9 +9007,18 @@ languageDescription = "Choose the display language"
logout = "Log out"
setAsDefault = "Set as Default"
theme = "Theme"
themeAccent = "Accent colour"
themeAccentCustom = "Custom colour"
themeAccentCustomHint = "Custom (defaults recommended)"
themeAccentDark = "Dark mode accent colour"
themeAccentDefault = "Default"
themeAccentDefaultHint = "Default theme (recommended)"
themeAccentDescription = "Buttons, links and highlights follow it, and it subtly tints the app. Light and dark each have their own. System uses whichever is active."
themeAccentLight = "Light mode accent colour"
themeDark = "Dark"
themeDescription = "Choose light, dark, or follow your system"
themeDescription = "Choose light, dark, or follow your system so it switches automatically."
themeLight = "Light"
themeReset = "Restore theme to default"
themeSystem = "System"
title = "General"
user = "User"
@@ -9838,17 +9863,6 @@ title = "Upload to Server"
updateButton = "Update on Server"
uploadButton = "Upload to Server"
[superSearch]
ariaLabel = "Super search"
hint = "Type to search"
placeholder = "Search Stirling"
[superSearch.group]
files = "Files"
processor = "Processor"
settings = "Settings"
tools = "Tools"
[survey]
title = "Stirling-PDF Survey"
@@ -10871,7 +10885,6 @@ exitRedaction = "Exit Redaction Mode"
exportAll = "Export PDF"
exportSelected = "Export Selected Pages"
formFill = "Fill Form"
hideToolbar = "Hide toolbar"
multiTool = "Multi-Tool"
panMode = "Pan Mode"
print = "Print PDF"
@@ -10891,7 +10904,6 @@ selectAll = "Select All"
selectByNumber = "Select by Page Numbers"
selectLanguage = "Select language"
share = "Share"
showToolbar = "Show toolbar"
toggleAnnotations = "Toggle Annotations Visibility"
toggleAttachments = "Toggle Attachments"
toggleBookmarks = "Toggle Bookmarks"
+518
View File
@@ -0,0 +1,518 @@
#!/usr/bin/env node
// Theme colour lint. Modes:
//
// node theme-lint.mjs enforce: literal colours live ONLY in
// primitives.css; colors/dimensions must
// reference tokens; no duplicate primitives.
// Scope: core/theme/. (blocking)
// node theme-lint.mjs css-colors enforce: NO hardcoded colour in any source
// .css (primitives.css + generated output.css
// exempt). Scope: all editor/src. (blocking)
// node theme-lint.mjs code-colors enforce: no hardcoded colour in TS/TSX DOM
// code. Default-deny with layered exemptions
// (structural; var()/readColor/canvas/pdf-lib
// contexts; `// theme-allow-color` opt-out;
// exempt PATHS for rendering/vendor/config).
// Scope: all editor/src. (blocking)
// node theme-lint.mjs contrast enforce: text-on-surface / on-primary pairs
// clear WCAG AA per theme (default accent).
// (blocking)
//
// Structural black / white / transparent (shadows, scrims) are always allowed.
import { readFileSync, readdirSync } from "node:fs";
import { execSync } from "node:child_process";
import { relative, resolve, join } from "node:path";
const THEME = resolve(process.cwd(), "editor/src/core/theme");
const PRIMITIVES = "editor/src/core/theme/primitives.css";
// Fixed list of theme CSS files to check, so every read takes a constant path
// (no directory-listing feeding into a file read). readdir is used only to fail
// if a new .css is added without being registered — coverage can't silently
// lapse — but its output is never passed to readFileSync.
const THEME_FILES = [
"primitives.css",
"colors.css",
"dimensions.css",
"index.css",
];
// ── colour helpers ─────────────────────────────────────────────────────────
const HEX_RE = /#[0-9a-fA-F]{3,8}\b/g;
const FUNC_RE = /\b(?:rgba?|hsla?)\(\s*[^)]*\)/g;
const NAMED_RE =
/\b(?:white|black|red|green|blue|orange|yellow|purple|gray|grey|silver|transparent)\b/g;
function expandHex(hex) {
let h = hex.slice(1).toLowerCase();
if (h.length === 3) h = [...h].map((c) => c + c).join("");
if (h.length === 4) h = [...h].map((c) => c + c).join("");
return "#" + h;
}
function normalizeColor(raw) {
const s = raw.trim().toLowerCase();
if (s.startsWith("#")) return expandHex(s);
const nums = s.match(/[\d.]+%?/g);
if (!nums) return s;
return `${s.startsWith("hsl") ? "hsl" : "rgb"}(${nums.join(",")})`;
}
function isStructuralColor(norm) {
return (
norm === "transparent" ||
/^#000000(00)?$/.test(norm) ||
/^#ffffff(ff)?$/.test(norm) ||
/^rgb\(0,0,0[,)]/.test(norm) ||
/^rgb\(255,255,255[,)]/.test(norm)
);
}
function isStructuralName(name) {
return /^(?:white|black|transparent)$/i.test(name.trim());
}
function stripComments(text) {
return text.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " "));
}
// ── enforce: literals only in primitives.css, no duplicate primitives ────────
function check() {
const violations = [];
const primitiveValues = new Map();
const lineOf = (text, index) => text.slice(0, index).split("\n").length;
// Fail if a theme .css exists that isn't registered above (readdir is only
// compared here — never used to build a path passed to readFileSync).
const known = new Set(THEME_FILES);
for (const name of readdirSync(THEME)) {
if (name.endsWith(".css") && !known.has(name)) {
violations.push({
file: relative(process.cwd(), join(THEME, name)),
line: 1,
msg: `unregistered theme CSS — add "${name}" to THEME_FILES in theme-lint.mjs`,
});
}
}
for (const name of THEME_FILES) {
const rel = relative(process.cwd(), join(THEME, name));
const isPrimitives = rel === PRIMITIVES;
const text = stripComments(readFileSync(join(THEME, name), "utf8"));
for (const re of [HEX_RE, FUNC_RE]) {
re.lastIndex = 0;
let m;
while ((m = re.exec(text)) !== null) {
const norm = normalizeColor(m[0]);
if (isStructuralColor(norm)) continue;
if (isPrimitives) {
if (primitiveValues.has(norm)) {
violations.push({
file: rel,
line: lineOf(text, m.index),
msg: `duplicate primitive value ${norm} (also ${primitiveValues.get(norm)})`,
});
} else {
primitiveValues.set(norm, m[0]);
}
} else {
violations.push({
file: rel,
line: lineOf(text, m.index),
msg: `raw colour ${m[0]} — define it in primitives.css and use var()`,
});
}
}
}
// Named colours, only in value position.
if (!isPrimitives) {
text.split("\n").forEach((line, i) => {
const colon = line.indexOf(":");
if (colon < 0 || /[{}]/.test(line)) return;
// Property must be a lone identifier — a custom prop (--x) OR a standard
// property (color, border) — so `color: red` is checked, not just tokens,
// while selectors (`.foo:hover`) with a colon are skipped.
if (!/^\s*(?:--)?[a-z][a-z0-9-]*\s*$/i.test(line.slice(0, colon)))
return;
const value = line
.slice(colon + 1)
.replace(/--[a-z0-9-]+/gi, " ")
.replace(/url\([^)]*\)/g, " ")
.replace(/["'][^"']*["']/g, " ");
for (const nm of value.match(NAMED_RE) || []) {
if (isStructuralName(nm)) continue;
violations.push({
file: rel,
line: i + 1,
msg: `named colour "${nm}" — define it in primitives.css and use var()`,
});
}
});
}
}
return violations;
}
// ── contrast report (warn-only): resolve --c-* per theme, check legibility ───
function reportContrast() {
const primitivesCss = readFileSync(join(THEME, "primitives.css"), "utf8");
const colorsCss = readFileSync(join(THEME, "colors.css"), "utf8");
const primitives = {};
for (const m of primitivesCss.matchAll(
/(--p-[a-z0-9-]+)\s*:\s*(#[0-9a-fA-F]{3,8})\s*;/g,
))
primitives[m[1]] = m[2];
const blocks = [];
for (const m of colorsCss.matchAll(/([^{}]+)\{([^}]*)\}/g)) {
const decls = {};
for (const d of m[2].matchAll(/(--c-[a-z0-9-]+)\s*:\s*([^;]+);/g))
decls[d[1]] = d[2].trim();
if (Object.keys(decls).length)
blocks.push({ selector: m[1].trim(), decls });
}
// The editor always renders data-app-theme="custom"; the accent (--user-*) is
// injected at runtime, so seed the DEFAULT blue to resolve the custom tint
// statically. Themes = the ones that actually render: editor custom light/dark
// (data-app-theme="custom") and the portal's neutral dark (data-theme="dark").
const SEED = {
"--user-primary": "#3b82f6",
"--user-primary-on": "#ffffff",
"--user-accent-fg": "#3b82f6",
};
const pick = (re) => blocks.filter((b) => re.test(b.selector));
const lightBase = pick(/:root/);
const customBase = blocks.filter(
(b) =>
/app-theme="custom"/.test(b.selector) &&
!/color-scheme="dark"/.test(b.selector),
);
const customDark = pick(
/app-theme="custom"\]\[data-mantine-color-scheme="dark"/,
);
const midnight = pick(/data-theme="dark"/);
const themes = {
"editor light": [...lightBase, ...customBase],
"editor dark": [...lightBase, ...customBase, ...customDark],
"portal dark": [...lightBase, ...midnight],
};
const flatten = (list) =>
Object.assign({ ...SEED }, ...list.map((b) => b.decls));
const hexToRgb = (h) => {
h = h.replace("#", "");
if (h.length === 3)
h = h
.split("")
.map((c) => c + c)
.join("");
return {
r: parseInt(h.slice(0, 2), 16),
g: parseInt(h.slice(2, 4), 16),
b: parseInt(h.slice(4, 6), 16),
a: 1,
};
};
const over = (f, b) => ({
r: f.r * f.a + b.r * (1 - f.a),
g: f.g * f.a + b.g * (1 - f.a),
b: f.b * f.a + b.b * (1 - f.a),
a: 1,
});
const mix = (a, b, p) => ({
r: (a.r * p + b.r * (100 - p)) / 100,
g: (a.g * p + b.g * (100 - p)) / 100,
b: (a.b * p + b.b * (100 - p)) / 100,
a: 1,
});
// Resolve any token value: hex, rgb(a), var(--x[, fallback]) (--p-* → palette,
// else the theme map/seed), or color-mix(in srgb, A n%, B|transparent).
function resolveValue(v, t, seen) {
if (v == null) return null;
v = v.trim();
let m;
if (v.startsWith("#")) return hexToRgb(v);
if ((m = v.match(/^rgba?\(([^)]+)\)$/))) {
const n = m[1]
.split(/[,/\s]+/)
.map(Number)
.filter((x) => !Number.isNaN(x));
return { r: n[0], g: n[1], b: n[2], a: n[3] ?? 1 };
}
if ((m = v.match(/^var\(\s*(--[a-z0-9-]+)\s*(?:,\s*([\s\S]+))?\)$/))) {
return resolveVar(m[1], m[2], t, seen);
}
if ((m = v.match(/^color-mix\(in srgb,\s*(.+?)\s+(\d+)%\s*,\s*(.+)\)$/))) {
const a = resolveValue(m[1], t, seen);
if (!a) return null;
if (m[3].trim() === "transparent") return { ...a, a: +m[2] / 100 };
const b = resolveValue(m[3].trim(), t, seen);
return b ? mix(a, b, +m[2]) : null;
}
return null;
}
function resolveVar(name, fallback, t, seen) {
if (name.startsWith("--p-")) {
return primitives[name]
? hexToRgb(primitives[name])
: fallback
? resolveValue(fallback, t, seen)
: null;
}
if (!seen.has(name) && t[name] !== undefined) {
const next = new Set(seen).add(name);
const r = resolveValue(t[name], t, next);
if (r) return r;
}
return fallback ? resolveValue(fallback, t, seen) : null;
}
const resolve = (token, t) =>
resolveValue(t[token] ?? null, t, new Set([token]));
const lum = ({ r, g, b }) => {
const f = (v) => {
v /= 255;
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
};
return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
};
const contrast = (t1, t2, t) => {
const surface = resolve("--c-surface", t);
let a = resolve(t1, t);
let b = resolve(t2, t);
if (!a || !b || !surface) return null;
if (a.a < 1) a = over(a, surface);
if (b.a < 1) b = over(b, surface);
const [hi, lo] = [lum(a), lum(b)].sort((x, y) => y - x);
return (hi + 0.05) / (lo + 0.05);
};
const PAIRS = [
["--c-text", "--c-surface", 4.5],
["--c-text-muted", "--c-surface", 4.5],
["--c-text-subtle", "--c-surface", 4.5],
["--c-text", "--c-bg", 4.5],
["--c-text-on-primary", "--c-primary", 3.0],
];
let warnings = 0;
console.log("contrast report (warning-only, default accent):\n");
for (const name of Object.keys(themes)) {
const t = flatten(themes[name]);
console.log(` ${name}`);
for (const [t1, t2, floor] of PAIRS) {
const r = contrast(t1, t2, t);
if (r == null) {
console.log(` ? ${t1} on ${t2} (unresolved)`);
continue;
}
if (r < floor) warnings++;
console.log(
` ${r < floor ? "⚠ " : " "}${r.toFixed(2).padStart(5)} (floor ${floor}) ${t1} on ${t2}`,
);
}
console.log("");
}
console.log(
warnings
? `✖ ${warnings} pair(s) below floor.`
: "✓ all pairs clear their floor.",
);
return warnings;
}
// ── css-colors (blocking): no hardcoded colour in ANY source .css ────────────
// App-wide guard that source CSS routes every colour through the palette. The
// file list comes from `git ls-files` (a VCS query over tracked, in-repo paths)
// — never a directory walk feeding a read — so there's no readdir→readFile path.
// primitives.css (the literal home) and generated output.css are exempt.
function checkAppCss() {
const EXEMPT = /(?:^|\/)(?:primitives\.css|output\.css)$/;
const listed = execSync("git ls-files -- editor/src", {
encoding: "utf8",
})
.split("\n")
.map((l) => l.trim())
.filter((l) => l && l.endsWith(".css") && !EXEMPT.test(l));
const violations = [];
const lineOf = (text, index) => text.slice(0, index).split("\n").length;
for (const rel of listed) {
const text = stripComments(readFileSync(rel, "utf8"));
for (const re of [HEX_RE, FUNC_RE]) {
re.lastIndex = 0;
let m;
while ((m = re.exec(text)) !== null) {
if (/var\(/i.test(m[0])) continue; // rgb()/color-mix wrapping a token
const norm = normalizeColor(m[0]);
if (isStructuralColor(norm)) continue;
violations.push({
file: rel,
line: lineOf(text, m.index),
msg: `raw colour ${m[0]} — define it in primitives.css and use var(--p-…)`,
});
}
}
text.split("\n").forEach((line, i) => {
const colon = line.indexOf(":");
if (colon < 0 || /[{}]/.test(line)) return;
if (!/^\s*(?:--)?[a-z][a-z0-9-]*\s*$/i.test(line.slice(0, colon))) return;
const value = line
.slice(colon + 1)
.replace(/--[a-z0-9-]+/gi, " ")
.replace(/url\([^)]*\)/g, " ")
.replace(/["'][^"']*["']/g, " ");
for (const nm of value.match(NAMED_RE) || []) {
if (isStructuralName(nm)) continue;
violations.push({
file: rel,
line: i + 1,
msg: `named colour "${nm}" — define it in primitives.css and use var(--p-…)`,
});
}
});
}
return violations;
}
// ── code-colors (blocking): no NEW hardcoded colour in TS/TSX DOM code ───────
// TS/TSX can't be zeroed like CSS — canvas/PDF/pdfium rendering, colour maths,
// colour pickers, vendor brand and self-contained docs legitimately need
// numeric colour. So this is default-deny with layered exemptions:
// 1. structural black/white/transparent
// 2. detected safe CONTEXTS on the line (var()/readColor fallback, canvas
// assignment, pdf-lib 0..1 rgb) and an explicit `// theme-allow-color` opt-out
// 3. exempt PATHS — whole areas where colour literals are inherent
// Anything else (a raw colour in a normal DOM component) fails. File list from
// `git ls-files` (no directory walk). Comments and HTML entities are stripped.
const CODE_EXEMPT_PATH = [
/Thumbnail|Overlay|DrawingCanvas|PageEditor|MobileScannerPage/, // canvas/PDF render
/[Pp]df|PDF|pixelCompare|\/compare\.ts$|customPrimary|accentColors/,
/validateSignature\/outputtedPDFSections|CenteredMessageSection|StatusBadgeSection/,
/\/viewer\/|Annotation|useViewerReadAloud|CommentsSidebar|\/constants\/search\.ts$|SignaturePreview/,
/ColorPicker|ColorControl|WatchedFolderManagementModal|watchedFolderPresets|fileColors|unifiedBackground|folder\.ts$|policyFolders/, // pickers/palettes as data
/OAuthButtons|oauthCallbackHtml/, // vendor brand / self-contained doc
/mantineTheme|\/theme\.ts$|toolsTaxonomy|LayoutPreview|PageNumberPreview|CloudStorageIcons/, // theme/config objects
/\/onboarding\//, // decorative onboarding illustration gradients
/addStamp|addWatermark|\/tooltips\//, // colour params fed to PDF + tooltip prose
/UpgradeBanner|AdminPlanSection/, // bespoke marketing/upsell banner palette
/\.test\.[jt]sx?$|\.stories\.[jt]sx?$|\/types\//, // tests, stories, type decls
];
const CODE_HEX =
/#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})(?![0-9a-fA-F])/g;
const CODE_RGB = /rgba?\(([^)]*)\)/gi;
const codeStructuralHex = (h) =>
/^#(?:000|fff|000f|ffff|000000|ffffff|00000000|ffffffff)$/i.test(h);
const CODE_SKIP_LINE =
/theme-allow-color|var\(\s*--[a-z0-9-]+\s*,|readColor\(|getPropertyValue|\.colors\.[a-z]+\?\.\[|fillStyle|strokeStyle|shadowColor|addColorStop|createLinearGradient|ctx\.|getContext/i;
function codeStripNonCode(text) {
return text
.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " "))
.replace(
/(^|[^:])\/\/[^\n]*/g,
(m, p) => p + m.slice(p.length).replace(/[^\n]/g, " "),
)
.replace(/&#\d+;/g, " ");
}
function codeRgbIsColour(inner) {
if (/var\(/.test(inner)) return false;
const p = inner
.split(/[, /]+/)
.map((x) => x.trim())
.filter(Boolean);
if (!/^\d/.test(p[0] || "")) return false;
const nums = p.slice(0, 3).map(Number);
if (nums.some((n) => Number.isNaN(n))) return false;
if (nums.every((n) => n <= 1)) return false; // pdf-lib rgb(0..1)
const k = `${nums[0]},${nums[1]},${nums[2]}`;
return k !== "0,0,0" && k !== "255,255,255";
}
function checkCodeColors() {
const files = execSync("git ls-files -- editor/src", { encoding: "utf8" })
.split("\n")
.map((l) => l.trim())
.filter(
(l) =>
/\.(ts|tsx)$/.test(l) && !CODE_EXEMPT_PATH.some((re) => re.test(l)),
);
const violations = [];
for (const rel of files) {
const raw = readFileSync(rel, "utf8");
const rawLines = raw.split("\n");
const text = codeStripNonCode(raw);
text.split("\n").forEach((line, i) => {
// marker lives in a comment (stripped from `line`), so test the raw line
if (/theme-allow-color/.test(rawLines[i] || "")) return;
if (CODE_SKIP_LINE.test(line)) return;
const hits = [];
for (const h of line.match(CODE_HEX) || [])
if (!codeStructuralHex(h)) hits.push(h);
for (const m of line.match(CODE_RGB) || [])
if (codeRgbIsColour(m.replace(/rgba?\(|\)/gi, ""))) hits.push(m);
for (const h of hits)
violations.push({
file: rel,
line: i + 1,
msg: `hardcoded colour ${h} — use a var(--c-*/--p-*) token, or add \`// theme-allow-color <reason>\` if this must be a literal`,
});
});
}
return violations;
}
// ── CLI ──────────────────────────────────────────────────────────────────────
if (process.argv.includes("contrast")) {
const below = reportContrast();
if (below) {
console.error(
`\nRaise the failing token's lightness (or its surface's) until every pair clears WCAG AA (4.5 normal / 3.0 on-primary).\n`,
);
process.exit(1);
}
process.exit(0);
}
if (process.argv.includes("code-colors")) {
const violations = checkCodeColors();
if (violations.length) {
console.error(
`\n✖ theme-lint code-colors: ${violations.length} hardcoded colour(s) in TS/TSX:\n`,
);
for (const v of violations)
console.error(` ${v.file}:${v.line} ${v.msg}`);
console.error("");
process.exit(1);
}
console.log(
"✓ theme-lint code-colors: no hardcoded colour in TS/TSX DOM code (rendering/vendor/config areas exempt)",
);
process.exit(0);
}
if (process.argv.includes("css-colors")) {
const violations = checkAppCss();
if (violations.length) {
console.error(
`\n✖ theme-lint css-colors: ${violations.length} hardcoded colour(s) in source CSS:\n`,
);
for (const v of violations)
console.error(` ${v.file}:${v.line} ${v.msg}`);
console.error(
`\nDefine every colour once in core/theme/primitives.css and reference it with var(--p-…).\n`,
);
process.exit(1);
}
console.log(
"✓ theme-lint css-colors: source CSS is free of hardcoded colour",
);
process.exit(0);
}
const violations = check();
if (violations.length) {
console.error(
`\n✖ theme-lint: ${violations.length} raw/duplicate colour(s) in core/theme/:\n`,
);
for (const v of violations) console.error(` ${v.file}:${v.line} ${v.msg}`);
console.error(
`\nDefine every colour once in core/theme/primitives.css and reference it with var(--p-…).\n`,
);
process.exit(1);
}
console.log(
"✓ theme-lint: core/theme colours all route through the primitive palette",
);
@@ -8,7 +8,7 @@
}
.freeHighlight {
background: linear-gradient(135deg, #6366f1, #ec4899);
background: linear-gradient(135deg, var(--p-indigo-500), var(--p-pink-500));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
@@ -36,7 +36,7 @@
flex-direction: column;
max-height: 200px;
overflow-y: auto;
border: 1px solid var(--border-default, #d1d5db);
border: 1px solid var(--c-border);
border-radius: 12px;
margin-bottom: 12px;
}
@@ -49,7 +49,7 @@
}
.memberRow + .memberRow {
border-top: 1px solid var(--border-subtle, #e5e7eb);
border-top: 1px solid var(--c-border-subtle);
}
.memberIdentity {
@@ -62,7 +62,7 @@
.memberName {
font-size: 14px;
font-weight: 600;
color: var(--onboarding-title, #111827);
color: var(--c-text);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -70,7 +70,7 @@
.memberEmail {
font-size: 12px;
color: var(--onboarding-body, #6b7280);
color: var(--c-text-muted);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -87,7 +87,7 @@ export function FreeLimitReachedModal({ onClose }: FreeLimitReachedModalProps) {
content: {
overflow: "hidden",
border: "none",
background: "var(--bg-surface)",
background: "var(--c-surface)",
maxHeight: "90vh",
display: "flex",
flexDirection: "column",
@@ -87,7 +87,7 @@ export function SpendCapReachedModal({ onClose }: SpendCapReachedModalProps) {
content: {
overflow: "hidden",
border: "none",
background: "var(--bg-surface)",
background: "var(--c-surface)",
maxHeight: "90vh",
display: "flex",
flexDirection: "column",
@@ -2,25 +2,22 @@
Uses the app's semantic theme tokens (theme.css) so it tracks light/dark. */
.payg {
--payg-accent: #0a8bff;
--payg-accent-soft: rgba(10, 139, 255, 0.1);
--payg-accent: var(--p-azure-500);
--payg-accent-soft: color-mix(in srgb, var(--p-azure-500) 10%, transparent);
--payg-radius: 14px;
--payg-gap: 20px;
/* Cards sit ON the modal content bg; in light that's white-on-white so we
lean on border + shadow. Tokens are overridden per scheme below. */
--payg-card-bg: var(--bg-surface);
--payg-card-border: var(--border-default);
--payg-inset-bg: var(--bg-raised);
--payg-divider: var(--border-subtle);
--payg-card-bg: var(--c-surface);
--payg-card-border: var(--c-border);
--payg-inset-bg: var(--c-surface-raised);
--payg-divider: var(--c-border-subtle);
}
/* Dark mode: modal content bg is #131729 (--bg-surface), so lift cards above it */
/* Dark mode: surfaces/borders track the neutral --c-* tokens (set on the base
rule); only the brand-azure accent tint is tuned brighter for dark. */
[data-mantine-color-scheme="dark"] .payg {
--payg-card-bg: #1c2340;
--payg-card-border: #2d3560;
--payg-inset-bg: #0d1020;
--payg-accent-soft: rgba(79, 142, 245, 0.16);
--payg-divider: #2d3560;
--payg-accent-soft: color-mix(in srgb, var(--p-azure-550) 16%, transparent);
}
/* ── Header ─────────────────────────────────────────────────────────── */
@@ -29,12 +26,12 @@
font-size: 1.35rem;
font-weight: 700;
letter-spacing: -0.01em;
color: var(--text-primary);
color: var(--c-text);
}
.payg-header__subtitle {
margin-top: 4px;
font-size: 0.875rem;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.payg-role-pill {
display: inline-flex;
@@ -49,12 +46,12 @@
.payg-role-pill[data-leader="true"] {
background: var(--payg-accent-soft);
color: var(--payg-accent);
border: 1px solid rgba(10, 139, 255, 0.25);
border: 1px solid color-mix(in srgb, var(--p-azure-500) 25%, transparent);
}
.payg-role-pill[data-leader="false"] {
background: var(--bg-muted);
color: var(--text-muted);
border: 1px solid var(--border-default);
background: var(--c-surface-sunken);
color: var(--c-text-subtle);
border: 1px solid var(--c-border);
}
/* ── Plan header: free-vs-metered split (shared by free + subscribed) ──── */
@@ -73,7 +70,7 @@
}
.payg-planhead__eyebrow {
font-size: 0.78rem;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.payg-planhead__split {
display: grid;
@@ -98,7 +95,7 @@
margin-bottom: 8px;
}
.payg-planhead__lbl--free {
color: #10b981;
color: var(--p-emerald-500);
}
.payg-planhead__lbl--meter {
color: var(--payg-accent);
@@ -110,14 +107,14 @@
margin: 0;
font-size: 1.05rem;
font-weight: 700;
color: var(--text-primary);
color: var(--c-text);
letter-spacing: -0.01em;
line-height: 1.25;
}
.payg-planhead__body {
margin: 5px 0 0;
font-size: 0.85rem;
color: var(--text-muted);
color: var(--c-text-subtle);
line-height: 1.5;
}
@media (max-width: 640px) {
@@ -147,11 +144,11 @@
.payg-card__title {
font-size: 0.95rem;
font-weight: 650;
color: var(--text-primary);
color: var(--c-text);
}
.payg-card__subtitle {
font-size: 0.8125rem;
color: var(--text-muted);
color: var(--c-text-subtle);
margin-top: 2px;
}
@@ -175,22 +172,22 @@
.payg-hero[data-state="FULL"]::before {
background: linear-gradient(
135deg,
rgba(10, 139, 255, 0.12) 0%,
rgba(10, 139, 255, 0) 55%
color-mix(in srgb, var(--p-azure-500) 12%, transparent) 0%,
color-mix(in srgb, var(--p-azure-500) 0%, transparent) 55%
);
}
.payg-hero[data-state="WARNED"]::before {
background: linear-gradient(
135deg,
rgba(234, 179, 8, 0.16) 0%,
rgba(234, 179, 8, 0) 55%
color-mix(in srgb, var(--p-amber-400) 16%, transparent) 0%,
color-mix(in srgb, var(--p-amber-400) 0%, transparent) 55%
);
}
.payg-hero[data-state="DEGRADED"]::before {
background: linear-gradient(
135deg,
rgba(239, 68, 68, 0.16) 0%,
rgba(239, 68, 68, 0) 55%
color-mix(in srgb, var(--p-red-500) 16%, transparent) 0%,
color-mix(in srgb, var(--p-red-500) 0%, transparent) 55%
);
}
.payg-hero__inner {
@@ -202,7 +199,7 @@
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.payg-hero__figure {
display: flex;
@@ -215,12 +212,12 @@
font-weight: 750;
line-height: 1;
letter-spacing: -0.03em;
color: var(--text-primary);
color: var(--c-text);
font-variant-numeric: tabular-nums;
}
.payg-hero__cap {
font-size: 1rem;
color: var(--text-muted);
color: var(--c-text-subtle);
font-variant-numeric: tabular-nums;
}
.payg-hero__meta {
@@ -229,10 +226,10 @@
flex-wrap: wrap;
gap: 6px 18px;
font-size: 0.8125rem;
color: var(--text-secondary);
color: var(--c-text-muted);
}
.payg-hero__meta-dot {
color: var(--border-strong);
color: var(--c-border-strong);
}
.payg-hero__credit {
display: inline-flex;
@@ -242,11 +239,11 @@
font-size: 0.75rem;
font-weight: 600;
color: var(--color-green-700);
background: rgba(34, 197, 94, 0.14);
background: color-mix(in srgb, var(--p-green-500) 14%, transparent);
}
[data-mantine-color-scheme="dark"] .payg-hero__credit {
color: #4ade80;
background: rgba(34, 197, 94, 0.18);
color: var(--p-green-400);
background: color-mix(in srgb, var(--p-green-500) 18%, transparent);
}
/* Make Mantine default-variant buttons read clearly on the lifted cards in
@@ -257,16 +254,24 @@
/* Dark mode: the stock default button is a flat slab that disappears into the
card. Lift it with a soft top-down gradient + brighter border, and warm the
hover so the buttons feel tactile against --payg-card-bg (#1c2340). Driven
through Mantine's --button-* vars. The same rule covers disabled buttons
hover so the buttons feel tactile against the card surface. Driven through
Mantine's --button-* vars. The same rule covers disabled buttons
(Cancel/Update cap before the form is dirty) so they read identically to the
always-enabled ones — Mantine only fades them via opacity. */
[data-mantine-color-scheme="dark"]
.payg
.mantine-Button-root[data-variant="default"] {
--button-bg: linear-gradient(180deg, #232a50 0%, #1c2340 100%);
--button-hover: linear-gradient(180deg, #2d3560 0%, #232a50 100%);
--button-bd: 1px solid #2d3560;
--button-bg: linear-gradient(
180deg,
var(--c-surface-raised) 0%,
var(--c-surface) 100%
);
--button-hover: linear-gradient(
180deg,
var(--c-border) 0%,
var(--c-surface-raised) 100%
);
--button-bd: 1px solid var(--c-border);
--button-color: var(--mantine-color-white);
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.04) inset,
@@ -307,7 +312,7 @@
}
.payg-status[data-state="FULL"] .payg-status__dot {
background: var(--color-green-500);
box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--p-green-500) 18%, transparent);
}
.payg-status[data-state="WARNED"] {
background: var(--color-yellow-100);
@@ -315,7 +320,7 @@
}
.payg-status[data-state="WARNED"] .payg-status__dot {
background: var(--color-yellow-500);
box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.2);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--p-amber-400) 20%, transparent);
}
.payg-status[data-state="DEGRADED"] {
background: var(--color-red-100);
@@ -323,7 +328,7 @@
}
.payg-status[data-state="DEGRADED"] .payg-status__dot {
background: var(--color-red-500);
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--p-red-500) 20%, transparent);
}
/* Segmented usage bar */
@@ -331,7 +336,7 @@
margin-top: 18px;
height: 10px;
border-radius: 999px;
background: var(--bg-muted);
background: var(--c-surface-sunken);
overflow: hidden;
position: relative;
}
@@ -341,13 +346,13 @@
transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.payg-bar__fill[data-state="FULL"] {
background: linear-gradient(90deg, #0a8bff, #38bdf8);
background: linear-gradient(90deg, var(--p-azure-500), var(--p-azure-400));
}
.payg-bar__fill[data-state="WARNED"] {
background: linear-gradient(90deg, #f59e0b, #fbbf24);
background: linear-gradient(90deg, var(--p-amber-500), var(--p-amber-400));
}
.payg-bar__fill[data-state="DEGRADED"] {
background: linear-gradient(90deg, #dc2626, #f87171);
background: linear-gradient(90deg, var(--p-red-600), var(--p-red-400));
}
/* ── "What counts as a document?" expandable help ───────────────────── */
@@ -365,10 +370,10 @@
font: inherit;
font-size: 0.8125rem;
font-weight: 600;
color: var(--text-secondary);
color: var(--c-text-muted);
}
.payg-help__toggle:hover {
color: var(--text-primary);
color: var(--c-text);
}
.payg-help__chevron {
transition: transform 0.15s ease;
@@ -381,10 +386,10 @@
padding: 12px 14px;
border-radius: 10px;
border: 1px solid var(--payg-card-border);
background: var(--bg-muted);
background: var(--c-surface-sunken);
font-size: 0.8125rem;
line-height: 1.45;
color: var(--text-secondary);
color: var(--c-text-muted);
}
.payg-help__panel ul {
margin: 0;
@@ -401,7 +406,7 @@
padding: 13px 16px;
border-radius: 10px;
background: var(--payg-accent-soft);
border: 1px solid rgba(10, 139, 255, 0.2);
border: 1px solid color-mix(in srgb, var(--p-azure-500) 20%, transparent);
}
.payg-preview__icon {
color: var(--payg-accent);
@@ -409,12 +414,12 @@
}
.payg-preview__main {
font-size: 0.875rem;
color: var(--text-primary);
color: var(--c-text);
font-weight: 550;
}
.payg-preview__note {
font-size: 0.75rem;
color: var(--text-muted);
color: var(--c-text-subtle);
margin-top: 1px;
}
@@ -453,17 +458,17 @@
flex-shrink: 0;
}
.payg-gate[data-enabled="true"] .payg-gate__chip {
background: rgba(34, 197, 94, 0.16);
color: #22c55e;
background: color-mix(in srgb, var(--p-green-500) 16%, transparent);
color: var(--p-green-500);
}
.payg-gate[data-enabled="false"] .payg-gate__chip {
background: rgba(239, 68, 68, 0.16);
color: #f87171;
background: color-mix(in srgb, var(--p-red-500) 16%, transparent);
color: var(--p-red-400);
}
.payg-gate__label {
font-size: 0.8125rem;
line-height: 1.35;
color: var(--text-primary);
color: var(--c-text);
flex: 1;
}
.payg-gate__tag {
@@ -477,16 +482,16 @@
white-space: nowrap;
}
.payg-gate__tag[data-variant="on"] {
color: var(--text-muted);
background: var(--bg-muted);
color: var(--c-text-subtle);
background: var(--c-surface-sunken);
}
.payg-gate__tag[data-variant="pause"] {
color: #dc2626;
background: rgba(239, 68, 68, 0.12);
color: var(--c-danger);
background: color-mix(in srgb, var(--p-red-500) 12%, transparent);
}
[data-mantine-color-scheme="dark"] .payg-gate__tag[data-variant="pause"] {
color: #f87171;
background: rgba(239, 68, 68, 0.18);
color: var(--c-danger);
background: color-mix(in srgb, var(--p-red-500) 18%, transparent);
}
/* ── Member rows ────────────────────────────────────────────────────── */
@@ -515,11 +520,11 @@
.payg-member__name {
font-size: 0.875rem;
font-weight: 550;
color: var(--text-primary);
color: var(--c-text);
}
.payg-member__email {
font-size: 0.75rem;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.payg-member__usage {
text-align: right;
@@ -527,7 +532,7 @@
}
.payg-member__usage-num {
font-size: 0.8125rem;
color: var(--text-primary);
color: var(--c-text);
font-variant-numeric: tabular-nums;
}
.payg-member__minibar {
@@ -570,27 +575,27 @@
}
.payg-activity__label {
font-size: 0.8438rem;
color: var(--text-primary);
color: var(--c-text);
flex: 1;
}
.payg-activity__ts {
font-size: 0.75rem;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.payg-activity__kind {
font-size: 0.625rem;
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
color: var(--text-muted);
background: var(--bg-muted);
color: var(--c-text-subtle);
background: var(--c-surface-sunken);
padding: 2px 8px;
border-radius: 999px;
}
.payg-activity__units {
font-size: 0.8125rem;
font-weight: 650;
color: var(--text-primary);
color: var(--c-text);
font-variant-numeric: tabular-nums;
min-width: 58px;
text-align: right;
@@ -604,20 +609,20 @@
gap: 16px;
padding: 20px 24px;
border-radius: var(--payg-radius);
border: 1px solid rgba(99, 91, 255, 0.28);
border: 1px solid color-mix(in srgb, var(--p-periwinkle-500) 28%, transparent);
background: linear-gradient(
135deg,
rgba(99, 91, 255, 0.1) 0%,
rgba(99, 91, 255, 0.02) 100%
color-mix(in srgb, var(--p-periwinkle-500) 10%, transparent) 0%,
color-mix(in srgb, var(--p-periwinkle-500) 2%, transparent) 100%
);
}
.payg-stripe__title {
font-size: 0.9375rem;
font-weight: 650;
color: var(--text-primary);
color: var(--c-text);
}
.payg-stripe__subtitle {
font-size: 0.8125rem;
color: var(--text-muted);
color: var(--c-text-subtle);
margin-top: 2px;
}
@@ -60,12 +60,12 @@ interface PaygProps {
// Stable-ish avatar colour from a string.
const AVATAR_COLORS = [
"#0a8bff",
"#8b5cf6",
"#ec4899",
"#10b981",
"#f59e0b",
"#06b6d4",
"var(--p-azure-500)",
"var(--p-violet-500)",
"var(--p-pink-500)",
"var(--p-emerald-500)",
"var(--p-amber-500)",
"var(--p-cyan-500)",
];
function avatarColor(seed: string): string {
let h = 0;
@@ -70,11 +70,11 @@
gap: 8px;
font-size: 0.8rem;
line-height: 1.45;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.paygf-proc__membernote-icon {
flex-shrink: 0;
color: var(--text-muted);
color: var(--c-text-subtle);
font-size: 1.1rem !important;
margin-top: 1px;
}
@@ -113,12 +113,12 @@
font-weight: 750;
line-height: 1;
letter-spacing: -0.02em;
color: var(--text-primary);
color: var(--c-text);
font-variant-numeric: tabular-nums;
}
.paygf-meter__cap {
font-size: 0.85rem;
color: var(--text-muted);
color: var(--c-text-subtle);
font-variant-numeric: tabular-nums;
}
.paygf-meter .payg-bar {
@@ -131,7 +131,7 @@
align-items: center;
gap: 6px 10px;
font-size: 0.78rem;
color: var(--text-secondary);
color: var(--c-text-muted);
}
/* ── Leader CTA card ──────────────────────────────────────────────────── */
@@ -145,8 +145,10 @@
border: 1.5px solid transparent;
background:
linear-gradient(var(--payg-card-bg), var(--payg-card-bg)) padding-box,
linear-gradient(135deg, var(--payg-accent) 0%, #6c5ce7 100%) border-box;
box-shadow: 0 10px 28px -18px rgba(10, 139, 255, 0.4);
linear-gradient(135deg, var(--payg-accent) 0%, var(--p-purple-500) 100%)
border-box;
box-shadow: 0 10px 28px -18px
color-mix(in srgb, var(--p-azure-500) 40%, transparent);
display: flex;
flex-direction: column;
gap: 16px;
@@ -161,7 +163,11 @@
flex-shrink: 0;
padding: 10px;
border-radius: 12px;
background: linear-gradient(135deg, var(--payg-accent) 0%, #6c5ce7 100%);
background: linear-gradient(
135deg,
var(--payg-accent) 0%,
var(--p-purple-500) 100%
);
color: white !important;
font-size: 1.7rem !important;
}
@@ -172,14 +178,14 @@
margin: 0;
font-size: 1.2rem;
font-weight: 700;
color: var(--text-primary);
color: var(--c-text);
letter-spacing: -0.01em;
line-height: 1.25;
}
.paygf-cta__subtitle {
margin: 4px 0 0;
font-size: 0.9rem;
color: var(--text-muted);
color: var(--c-text-subtle);
line-height: 1.5;
}
@@ -196,7 +202,7 @@
align-items: flex-start;
gap: 8px;
font-size: 0.85rem;
color: var(--text-primary);
color: var(--c-text);
line-height: 1.45;
}
.paygf-cta__check {
@@ -220,7 +226,7 @@
.paygf-cta__reassurance {
margin: 0;
font-size: 0.78rem;
color: var(--text-muted);
color: var(--c-text-subtle);
text-align: right;
}
@@ -237,7 +243,7 @@
}
.paygf-member-note__icon {
flex-shrink: 0;
color: var(--text-muted);
color: var(--c-text-subtle);
padding: 8px;
background: var(--payg-card-bg);
border-radius: 10px;
@@ -247,14 +253,14 @@
margin: 0;
font-size: 1rem;
font-weight: 700;
color: var(--text-primary);
color: var(--c-text);
letter-spacing: -0.005em;
line-height: 1.3;
}
.paygf-member-note__body {
margin: 6px 0 0;
font-size: 0.875rem;
color: var(--text-muted);
color: var(--c-text-subtle);
line-height: 1.5;
}
@@ -285,14 +291,14 @@
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--text-muted);
color: var(--c-text-subtle);
margin-bottom: 10px;
}
.paygf-explainer__icon {
font-size: 1rem !important;
}
.paygf-explainer__icon--free {
color: #10b981;
color: var(--p-emerald-500);
}
.paygf-explainer__icon--paid {
color: var(--payg-accent);
@@ -300,6 +306,6 @@
.paygf-explainer__text {
margin: 0;
font-size: 0.85rem;
color: var(--text-primary);
color: var(--c-text);
line-height: 1.55;
}
@@ -9,12 +9,12 @@
Payg.css / UpgradeModal.css treatments the control sits beside. */
.scc {
--scc-accent: #0a8bff;
--scc-accent-text: #0a8bff;
--scc-accent-soft: rgba(10, 139, 255, 0.12);
--scc-accent-border: rgba(10, 139, 255, 0.25);
--scc-chip-bg: var(--bg-muted);
--scc-chip-border: var(--border-default);
--scc-accent: var(--p-azure-500);
--scc-accent-text: var(--p-azure-500);
--scc-accent-soft: color-mix(in srgb, var(--p-azure-500) 12%, transparent);
--scc-accent-border: color-mix(in srgb, var(--p-azure-500) 25%, transparent);
--scc-chip-bg: var(--c-surface-sunken);
--scc-chip-border: var(--c-border);
/* Consistent vertical rhythm between the control row, the estimate, and any
note — without it the blocks sit flush. */
display: flex;
@@ -22,10 +22,10 @@
gap: 14px;
}
[data-mantine-color-scheme="dark"] .scc {
--scc-accent-text: #7ab4ff;
--scc-accent-soft: rgba(79, 142, 245, 0.16);
--scc-chip-bg: #1c2340;
--scc-chip-border: #2d3560;
/* Chip surface/border track the neutral --c-* tokens (base rule); only the
brand-azure accent is tuned brighter for dark. */
--scc-accent-text: var(--p-azure-300);
--scc-accent-soft: color-mix(in srgb, var(--p-azure-500) 16%, transparent);
}
/* ── Inline row: presets · custom · no-cap · (save) ──────────────────── */
@@ -47,7 +47,7 @@
border-radius: 999px;
border: 1px solid var(--scc-chip-border);
background: var(--scc-chip-bg);
color: var(--text-secondary);
color: var(--c-text-muted);
font: inherit;
font-size: 0.85rem;
font-weight: 600;
@@ -59,8 +59,8 @@
background 0.12s ease;
}
.scc-chip:hover:not(:disabled) {
color: var(--text-primary);
border-color: var(--border-strong);
color: var(--c-text);
border-color: var(--c-border-strong);
}
.scc-chip[data-selected="true"] {
background: var(--scc-accent-soft);
@@ -90,7 +90,7 @@
background 0.12s ease;
}
.scc-custom:hover {
border-color: var(--border-strong);
border-color: var(--c-border-strong);
}
.scc-custom[data-active="true"] {
border-style: solid;
@@ -98,7 +98,7 @@
background: var(--scc-accent-soft);
}
.scc-custom__symbol {
color: var(--text-muted);
color: var(--c-text-subtle);
font-size: 0.85rem;
font-weight: 600;
}
@@ -111,14 +111,14 @@
border: none;
outline: none;
background: transparent;
color: var(--text-primary);
color: var(--c-text);
font: inherit;
font-size: 0.85rem;
font-weight: 600;
font-variant-numeric: tabular-nums;
}
.scc-custom__input::placeholder {
color: var(--text-muted);
color: var(--c-text-subtle);
font-weight: 600;
}
.scc-custom:disabled,
@@ -148,17 +148,17 @@
.scc-estimate__main {
font-size: 0.875rem;
font-weight: 550;
color: var(--text-primary);
color: var(--c-text);
}
.scc-estimate__sub {
font-size: 0.75rem;
color: var(--text-muted);
color: var(--c-text-subtle);
margin-top: 1px;
}
/* Quiet helper line (e.g. "Shown in USD — change later in your currency"). */
.scc-note {
font-size: 0.8125rem;
color: var(--text-muted);
color: var(--c-text-subtle);
line-height: 1.45;
}
@@ -430,8 +430,8 @@ const TeamSection: React.FC = () => {
style={
member.role !== "LEADER"
? {
backgroundColor: "var(--tool-header-badge-bg)",
color: "var(--tool-header-badge-text)",
backgroundColor: "var(--c-surface-raised)",
color: "var(--c-accent-fg)",
}
: undefined
}
@@ -5,22 +5,21 @@
user feels like they're filling out one form, not navigating pages. */
.upm {
--upm-accent: #0a8bff;
--upm-accent-2: #6c5ce7;
--upm-accent-soft: rgba(10, 139, 255, 0.08);
--upm-success: #10b981;
--upm-accent: var(--p-azure-500);
--upm-accent-2: var(--p-purple-500);
--upm-accent-soft: color-mix(in srgb, var(--p-azure-500) 8%, transparent);
--upm-success: var(--p-emerald-500);
--upm-radius: 18px;
--upm-card-bg: var(--bg-surface);
--upm-border: var(--border-default);
--upm-divider: var(--border-subtle);
--upm-text: var(--text-primary);
--upm-muted: var(--text-muted);
--upm-card-bg: var(--c-surface);
--upm-border: var(--c-border);
--upm-divider: var(--c-border-subtle);
--upm-text: var(--c-text);
--upm-muted: var(--c-text-subtle);
}
[data-mantine-color-scheme="dark"] .upm {
--upm-card-bg: #1c2340;
--upm-border: #2d3560;
--upm-divider: #2d3560;
--upm-accent-soft: rgba(79, 142, 245, 0.14);
/* Card/border/divider track the neutral --c-* tokens (base rule); only the
brand-azure accent tint is tuned for dark. */
--upm-accent-soft: color-mix(in srgb, var(--p-azure-550) 14%, transparent);
}
/* Backdrop locks the page and centres the modal. z-index matches
@@ -254,7 +253,7 @@
border-radius: 6px;
}
.upm-step__edit:hover {
background: rgba(10, 139, 255, 0.12);
background: color-mix(in srgb, var(--p-azure-500) 12%, transparent);
}
/* Placeholder card for the loading / error / mock states — a dashed, centered
@@ -327,8 +326,10 @@
}
.upm-confirm__icon {
font-size: 64px !important;
color: #10b981;
filter: drop-shadow(0 6px 18px rgba(16, 185, 129, 0.35));
color: var(--upm-success);
filter: drop-shadow(
0 6px 18px color-mix(in srgb, var(--p-emerald-500) 35%, transparent)
);
}
.upm-confirm__title {
margin: 6px 0 0;
@@ -61,7 +61,9 @@ function Swatch({ label, src, onDark, h }: Asset & { h: number }) {
>
<img src={src} alt={label} style={{ height: h, maxWidth: 200 }} />
</div>
<figcaption style={{ fontSize: 12, color: "var(--text-muted, #71717a)" }}>
<figcaption
style={{ fontSize: 12, color: "var(--c-text-subtle, #71717a)" }}
>
{label}
</figcaption>
</figure>
@@ -221,7 +221,7 @@ const FileManager: React.FC<FileManagerProps> = ({ selectedTool }) => {
width: "100%",
border: "none",
borderRadius: "var(--radius-md)",
backgroundColor: "var(--bg-file-manager)",
backgroundColor: "var(--c-bg)",
}}
styles={{
inner: { pointerEvents: "all" },
@@ -227,7 +227,7 @@ export const TextInputWithFont: React.FC<TextInputWithFontProps> = ({
width: 24,
height: 24,
backgroundColor: textColor,
border: "1px solid #ccc",
border: "1px solid var(--c-border)",
borderRadius: 4,
cursor: disabled ? "default" : "pointer",
}}
@@ -110,7 +110,7 @@ const AddFileCard = ({
variant="tertiary"
style={{
backgroundColor: "var(--landing-button-bg)",
color: "var(--landing-button-color)",
color: "var(--c-accent-fg)",
border: "1px solid var(--landing-button-border)",
borderRadius: "2rem",
height: "38px",
@@ -129,7 +129,7 @@ const AddFileCard = ({
icon="add"
width="1.5rem"
height="1.5rem"
className="text-[var(--accent-interactive)]"
className="text-[var(--c-primary)]"
/>
<span>{t("landing.addFiles", "Add Files")}</span>
</Button>
@@ -140,7 +140,7 @@ const AddFileCard = ({
title={terminology.uploadFromComputer}
style={{
backgroundColor: "var(--landing-button-bg)",
color: "var(--landing-button-color)",
color: "var(--c-accent-fg)",
border: "1px solid var(--landing-button-border)",
borderRadius: "1rem",
height: "38px",
@@ -161,7 +161,7 @@ const AddFileCard = ({
icon={icons.uploadIconName}
width="1.25rem"
height="1.25rem"
style={{ color: "var(--accent-interactive)", flexShrink: 0 }}
style={{ color: "var(--c-primary)", flexShrink: 0 }}
/>
{isUploadHover && (
<span
@@ -181,7 +181,7 @@ const AddFileCard = ({
{/* Instruction Text */}
<span
className="text-[var(--accent-interactive)]"
className="text-[var(--c-primary)]"
style={{
fontSize: ".8rem",
textAlign: "center",
@@ -3,7 +3,7 @@
========================= */
.card {
background: var(--file-card-bg);
background: var(--c-surface-raised);
border-radius: 0.0625rem;
cursor: pointer;
transition:
@@ -28,7 +28,7 @@
/* While dragging */
.card.dragging,
.card:global(.dragging) {
outline: 1px solid var(--border-strong);
outline: 1px solid var(--c-border-strong);
box-shadow: var(--shadow-md);
transform: none !important;
}
@@ -42,15 +42,15 @@
justify-content: space-between;
padding: 0 6px;
user-select: none;
background: var(--bg-toolbar);
color: var(--text-primary);
border-bottom: 1px solid var(--border-default);
background: var(--c-bg-raised);
color: var(--c-text);
border-bottom: 1px solid var(--c-border);
}
.headerResting {
background: #3b4b6e; /* dark blue for unselected in light mode */
background: var(--p-navy-500); /* dark blue for unselected in light mode */
color: #ffffff;
border-bottom: 1px solid var(--border-default);
border-bottom: 1px solid var(--c-border);
}
.headerSelected {
@@ -62,20 +62,20 @@
/* Error highlight (transient) */
.headerError {
background: var(--color-red-200);
color: var(--text-primary);
color: var(--c-text);
border-bottom: 2px solid var(--color-red-500);
}
/* Unsupported (but not errored) header appearance */
.headerUnsupported {
background: var(--unsupported-bar-bg); /* neutral gray */
background: var(--c-bg-raised); /* neutral gray */
color: #ffffff;
border-bottom: 1px solid var(--unsupported-bar-border);
border-bottom: 1px solid var(--c-border);
}
/* Selected border color in light mode */
:global([data-mantine-color-scheme="light"]) .card[data-selected="true"] {
outline-color: var(--card-selected-border);
outline-color: var(--c-primary);
}
/* Reserve space for checkbox instead of logo */
@@ -117,12 +117,12 @@
/* -------- Title / Meta -------- */
.title {
line-height: 1.2;
color: var(--text-primary);
color: var(--c-text);
}
.meta {
margin-top: 2px;
color: var(--text-secondary);
color: var(--c-text-muted);
}
/* -------- Preview area -------- */
@@ -131,7 +131,7 @@
width: 100%;
height: 100%;
overflow: hidden;
background: var(--file-card-bg);
background: var(--c-surface-raised);
}
.previewPaper {
@@ -142,7 +142,7 @@
display: grid;
position: relative;
overflow: hidden;
background: var(--file-card-bg);
background: var(--c-surface-raised);
}
/* Thumbnail fallback */
@@ -152,7 +152,7 @@
inset: 0;
display: grid;
place-items: center;
color: var(--text-secondary);
color: var(--c-text-muted);
font-weight: 600;
font-size: 12px;
}
@@ -162,7 +162,7 @@
position: absolute;
bottom: 6px;
right: 6px;
color: var(--text-secondary);
color: var(--c-text-muted);
z-index: 1;
cursor: grab;
display: inline-flex;
@@ -173,12 +173,12 @@
position: absolute;
left: 0;
top: 44px; /* just below header */
background: var(--bg-toolbar);
border-bottom: 1px solid var(--border-default);
background: var(--c-bg-raised);
border-bottom: 1px solid var(--c-border);
z-index: 20;
overflow: hidden;
animation: slideDown 140ms ease-out;
color: var(--text-primary);
color: var(--c-text);
}
@keyframes slideDown {
@@ -200,13 +200,13 @@
padding: 12px 16px;
background: transparent;
border: none;
color: var(--text-primary);
color: var(--c-text);
cursor: pointer;
text-align: left;
}
.actionRow:hover {
background: var(--hover-bg);
background: var(--c-hover);
}
.actionDanger {
@@ -215,7 +215,7 @@
.actionsDivider {
height: 1px;
background: var(--border-default);
background: var(--c-border);
margin: 4px 0;
}
@@ -229,13 +229,13 @@
}
.pinned {
color: #ffc107 !important;
color: var(--p-amber-400) !important;
}
/* Unsupported file indicator */
.unsupportedPill {
margin-left: 1.75rem;
background: #6b7280;
background: var(--p-gray-500);
color: white;
padding: 4px 8px;
border-radius: 12px;
@@ -291,36 +291,23 @@
DARK MODE OVERRIDES
========================= */
:global([data-mantine-color-scheme="dark"]) .card {
outline-color: #1c2340; /* deselected stroke */
outline-color: var(--c-border); /* deselected stroke (neutral) */
}
:global([data-mantine-color-scheme="dark"]) .card[data-selected="true"] {
outline-color: #2d3560; /* selected stroke (subtle navy) */
outline-color: var(--c-primary); /* selected stroke (accent) */
}
:global([data-mantine-color-scheme="dark"]) .headerResting {
background: #0d1020; /* requested default unselected color */
color: var(--tool-header-text); /* #D0D6DC */
border-bottom-color: var(--tool-header-border); /* #3A4047 */
background: var(--p-navy-950); /* requested default unselected color */
color: var(--c-accent-fg); /* var(--p-gray-300) */
border-bottom-color: var(--c-border); /* #3A4047 */
}
:global([data-mantine-color-scheme="dark"]) .headerSelected {
background: var(--tool-header-border); /* #3A4047 */
color: var(--tool-header-text); /* #D0D6DC */
border-bottom-color: var(--tool-header-border);
}
:global([data-mantine-color-scheme="dark"]) .title {
color: #d0d6dc; /* title text */
}
:global([data-mantine-color-scheme="dark"]) .meta {
color: #6b7280; /* subtitle text */
}
/* Light mode selected header stroke override */
:global([data-mantine-color-scheme="light"]) .card[data-selected="true"] {
outline-color: #3b4b6e;
background: var(--c-border); /* #3A4047 */
color: var(--c-accent-fg); /* var(--p-gray-300) */
border-bottom-color: var(--c-border);
}
/* =========================
@@ -332,8 +319,8 @@
max-width: 260px;
height: calc(310px - 0.5rem);
margin: 0.5rem auto 0;
background: var(--file-card-bg);
border: 1.5px solid var(--border-default);
background: var(--c-bg);
border: 1.5px solid var(--c-border);
border-radius: 12px;
box-shadow: var(--shadow-md);
cursor: pointer;
@@ -347,11 +334,11 @@
.addFileCard:hover {
box-shadow: var(--shadow-lg);
transform: translateY(-1px);
border-color: var(--accent-interactive);
border-color: var(--c-primary);
}
.addFileCard:focus-visible {
outline: 2px solid var(--accent-interactive);
outline: 2px solid var(--c-primary);
outline-offset: 2px;
}
@@ -386,7 +373,7 @@
}
.addFileCard:hover .addFileText {
color: var(--text-primary);
color: var(--c-text);
}
.addFileSubtext {
@@ -75,7 +75,7 @@
box-shadow: var(--shadow-md);
overflow: hidden;
position: relative;
background: var(--bg-surface);
background: var(--c-surface);
transition:
box-shadow 0.15s ease,
transform 0.2s ease;
@@ -91,7 +91,7 @@
height: 100%;
object-fit: contain;
border-radius: 12px;
background: var(--bg-surface);
background: var(--c-surface);
display: block;
position: relative;
z-index: 1;
@@ -115,7 +115,7 @@
.fileName {
font-size: 13px;
font-weight: 600;
color: var(--text-primary);
color: var(--c-text);
line-height: var(--file-name-line-height);
height: calc(var(--file-name-lines) * var(--file-name-line-height));
margin: 0;
@@ -149,7 +149,7 @@
.fileMeta {
font-size: 11px;
color: var(--text-secondary);
color: var(--c-text-muted);
line-height: var(--file-meta-line-height);
height: var(--file-meta-line-height);
overflow: hidden;
@@ -183,7 +183,7 @@
display: flex;
align-items: center;
justify-content: center;
background: rgba(220, 38, 38, 0.12);
background: color-mix(in srgb, var(--p-red-600) 12%, transparent);
border-radius: 12px;
z-index: 2;
pointer-events: none;
@@ -268,7 +268,7 @@
bottom: 6px;
right: 6px;
cursor: grab;
color: var(--text-secondary);
color: var(--c-text-muted);
opacity: 0;
transition: opacity 0.15s ease;
pointer-events: none;
@@ -50,7 +50,7 @@ const DesktopLayout: React.FC = () => {
flex: 1,
display: "flex",
flexDirection: "column",
backgroundColor: "var(--bg-file-list)",
backgroundColor: "var(--c-surface)",
border: "1px solid var(--mantine-color-gray-2)",
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
overflow: "hidden",
@@ -81,8 +81,8 @@ const EmptyFilesState: React.FC = () => {
variant="tertiary"
aria-label={t("emptyFilesState.upload", "Upload")}
style={{
backgroundColor: "var(--bg-file-manager)",
color: "var(--landing-button-color)",
backgroundColor: "var(--c-bg)",
color: "var(--c-accent-fg)",
border: "1px solid var(--landing-button-border)",
borderRadius: isUploadHover ? "2rem" : "1rem",
height: "38px",
@@ -103,7 +103,7 @@ const EmptyFilesState: React.FC = () => {
icon={icons.uploadIconName}
width="1.25rem"
height="1.25rem"
style={{ color: "var(--accent-interactive)" }}
style={{ color: "var(--c-primary)" }}
/>
{isUploadHover && (
<span style={{ marginLeft: ".5rem" }}>
@@ -115,7 +115,7 @@ const EmptyFilesState: React.FC = () => {
{/* Instruction Text */}
<span
className="text-[var(--accent-interactive)]"
className="text-[var(--c-primary)]"
style={{ fontSize: ".8rem", textAlign: "center" }}
>
{terminology.dropFilesHere}
@@ -189,7 +189,7 @@ const FileListItem: React.FC<FileListItemProps> = ({
backgroundColor:
isSelected || shouldShowHovered
? "var(--mantine-color-gray-1)"
: "var(--bg-file-list)",
: "var(--c-surface)",
opacity: 1,
transition: "background-color 0.15s ease",
userSelect: "none",
@@ -47,7 +47,7 @@ const MobileLayout: React.FC = () => {
flex: 1,
display: "flex",
flexDirection: "column",
backgroundColor: "var(--bg-file-list)",
backgroundColor: "var(--c-surface)",
borderRadius: "0.5rem",
border: "1px solid var(--mantine-color-gray-2)",
overflow: "hidden",
@@ -201,7 +201,7 @@ export function FileDetailsPanel({
<img src={single.thumbnailUrl} alt="" />
) : (
<PictureAsPdfIcon
style={{ fontSize: "3rem", color: "var(--text-muted)" }}
style={{ fontSize: "3rem", color: "var(--c-text-subtle)" }}
/>
)}
</div>
@@ -16,7 +16,6 @@ import DriveFileRenameOutlineIcon from "@mui/icons-material/DriveFileRenameOutli
import CloudUploadIcon from "@mui/icons-material/CloudUpload";
import UploadFileIcon from "@mui/icons-material/UploadFile";
import CreateNewFolderIcon from "@mui/icons-material/CreateNewFolder";
import SearchIcon from "@mui/icons-material/Search";
import { FileId } from "@app/types/file";
import { FolderId, FolderRecord, ROOT_FOLDER_ID } from "@app/types/folder";
@@ -90,8 +89,6 @@ interface FileGridProps {
onChangeSortMode?: (mode: FilesPageSortMode) => void;
/** Drives the empty-state copy. */
currentTab?: "all" | "local" | "cloud" | "recent" | "shared" | "sharedByMe";
/** A filter is applied; an empty result then means "no matches", not "no files". */
searchActive?: boolean;
/** Cloud reachability; switches the cloud empty-state copy. */
serverReachable?: boolean;
/** Empty-state CTA handlers; if absent the matching button hides. */
@@ -107,7 +104,6 @@ export function FileGrid(props: FileGridProps & { loading?: boolean }) {
entries,
loading,
currentTab,
searchActive,
serverReachable,
onEmptyUpload,
onEmptyCreateFolder,
@@ -119,28 +115,15 @@ export function FileGrid(props: FileGridProps & { loading?: boolean }) {
}
if (entries.length === 0) {
const emptyState = (
return (
<EmptyState
tab={currentTab}
searchActive={searchActive}
serverReachable={serverReachable}
onUpload={onEmptyUpload}
onCreateFolder={onEmptyCreateFolder}
newFolderDisabledReason={newFolderDisabledReason}
/>
);
// When a filter empties the list view, keep the column headers in place and
// show the no-results message beneath them, rather than replacing the whole
// table. Grid view (cards, no headers) just shows the empty state.
if (viewMode === "list" && searchActive) {
return (
<>
<ListView {...props} />
{emptyState}
</>
);
}
return emptyState;
}
if (viewMode === "list") {
@@ -204,8 +187,6 @@ function SkeletonGrid({ viewMode }: { viewMode: FilesPageViewMode }) {
interface EmptyStateProps {
/** Drives copy + iconography. */
tab?: "all" | "local" | "cloud" | "recent" | "shared" | "sharedByMe";
/** When true the empty list is the result of a filter, not a bare folder. */
searchActive?: boolean;
/** Switches the cloud empty-state copy. */
serverReachable?: boolean;
/** CTA handlers; absent => button hidden. */
@@ -217,35 +198,12 @@ interface EmptyStateProps {
function EmptyState({
tab = "all",
searchActive = false,
serverReachable = true,
onUpload,
onCreateFolder,
newFolderDisabledReason,
}: EmptyStateProps) {
const { t } = useTranslation();
// A filter with no matches isn't an empty folder - say so, and skip the
// upload / new-folder CTAs since clearing the filter is the way out.
if (searchActive) {
return (
<div className="files-page-empty">
<span className="files-page-empty-icon">
<SearchIcon style={{ fontSize: "2.5rem" }} />
</span>
<div className="files-page-empty-title">
{t("filesPage.empty.noResults.title", "No matching files")}
</div>
<div className="files-page-empty-hint">
{t(
"filesPage.empty.noResults.hint",
"No files in this folder match your filter. Try a different term or clear the filter.",
)}
</div>
</div>
);
}
const { titleKey, titleFallback, hintKey, hintFallback } = (() => {
switch (tab) {
case "local":
@@ -541,7 +499,7 @@ function FolderCard({
<div
className="files-page-card-thumb"
style={{
background: `linear-gradient(135deg, color-mix(in srgb, ${folder.color ?? "var(--accent-interactive, #6366f1)"} 18%, var(--bg-surface)), color-mix(in srgb, ${folder.color ?? "var(--accent-interactive, #6366f1)"} 6%, var(--bg-surface)))`,
background: `linear-gradient(135deg, color-mix(in srgb, ${folder.color ?? "var(--c-primary, #6366f1)"} 18%, var(--c-surface)), color-mix(in srgb, ${folder.color ?? "var(--c-primary, #6366f1)"} 6%, var(--c-surface)))`,
}}
>
<FolderThumbnail
@@ -7,19 +7,11 @@ import React, {
} from "react";
import { useTranslation } from "react-i18next";
import { useLocation, useNavigate } from "react-router-dom";
import {
Drawer,
Group,
MultiSelect,
Select,
TextInput,
Tooltip,
} from "@mantine/core";
import { Drawer, Group, MultiSelect, Select, Tooltip } from "@mantine/core";
import { Button } from "@app/ui/Button";
import { ActionIcon } from "@app/ui/ActionIcon";
import { SegmentedControl } from "@app/ui/SegmentedControl";
import { useMediaQuery } from "@mantine/hooks";
import CloseIcon from "@mui/icons-material/Close";
import SearchIcon from "@mui/icons-material/Search";
import UploadFileIcon from "@mui/icons-material/UploadFile";
import QrCode2Icon from "@mui/icons-material/QrCode2";
@@ -59,7 +51,6 @@ import { StirlingFileStub } from "@app/types/fileContext";
import { FolderId, ROOT_FOLDER_ID } from "@app/types/folder";
import { FileGrid, FilesPageEntry } from "@app/components/filesPage/FileGrid";
import SuperSearch from "@app/components/shared/superSearch/SuperSearch";
import { FileDetailsPanel } from "@app/components/filesPage/FileDetailsPanel";
import BulkUploadToServerModal from "@app/components/shared/BulkUploadToServerModal";
import MobileUploadModal from "@app/components/shared/MobileUploadModal";
@@ -694,19 +685,13 @@ export default function FileManagerView() {
}, [navigate]);
// ─── keyboard shortcuts ─────────────────────────────────────────────────
// Focus the super-search input (stable id), used by the "/" shortcut and the
// FileSidebar rail Search button.
const focusSearch = useCallback(() => {
(
document.getElementById("super-search-input") as HTMLInputElement | null
)?.focus();
}, []);
const searchInputRef = useRef<HTMLInputElement | null>(null);
// External focus trigger (used by the FileSidebar rail Search button).
useEffect(() => {
window.addEventListener("files-page:focus-search", focusSearch);
return () =>
window.removeEventListener("files-page:focus-search", focusSearch);
}, [focusSearch]);
const onFocus = () => searchInputRef.current?.focus();
window.addEventListener("files-page:focus-search", onFocus);
return () => window.removeEventListener("files-page:focus-search", onFocus);
}, []);
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
const active = document.activeElement as HTMLElement | null;
@@ -749,19 +734,13 @@ export default function FileManagerView() {
// "/" focuses the search field.
if (e.key === "/" && !inInput) {
e.preventDefault();
focusSearch();
searchInputRef.current?.focus();
return;
}
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [
visibleFiles,
selectedFileIds,
removeFiles,
setSelectedFileIds,
focusSearch,
]);
}, [visibleFiles, selectedFileIds, removeFiles, setSelectedFileIds]);
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
@@ -866,7 +845,7 @@ export default function FileManagerView() {
fontSize: "0.95rem",
fontWeight: 600,
padding: "0.25rem 0.5rem",
color: "var(--text-primary)",
color: "var(--c-text)",
}}
>
{currentTab === "local"
@@ -910,7 +889,11 @@ export default function FileManagerView() {
};
return (
<>
<SuperSearch />
<SearchField
ref={searchInputRef}
value={search}
onChange={setSearch}
/>
<div className="files-page-header-actions">
<Tooltip
label={
@@ -1009,8 +992,8 @@ export default function FileManagerView() {
padding: "0.6rem 1.25rem",
background:
"color-mix(in srgb, var(--mantine-color-red-6, #e03131) 12%, transparent)",
color: "var(--text-primary)",
borderBottom: "1px solid var(--border-subtle)",
color: "var(--c-text)",
borderBottom: "1px solid var(--c-border-subtle)",
fontSize: "0.85rem",
display: "flex",
justifyContent: "space-between",
@@ -1100,15 +1083,15 @@ export default function FileManagerView() {
style={{
background:
currentTab === tab.id
? "var(--hover-bg)"
? "var(--c-hover)"
: "transparent",
border: "none",
borderRadius: "0.3rem",
padding: "0.2rem 0.6rem",
color:
currentTab === tab.id
? "var(--text-primary)"
: "var(--text-muted)",
? "var(--c-text)"
: "var(--c-text-subtle)",
fontWeight: currentTab === tab.id ? 500 : 400,
fontSize: "0.75rem",
cursor: "pointer",
@@ -1359,27 +1342,6 @@ export default function FileManagerView() {
aria-label={t("filesPage.typeFilter.label", "Filter by type")}
/>
)}
<TextInput
size="xs"
value={search}
onChange={(e) => setSearch(e.currentTarget.value)}
placeholder={t("filesPage.search.placeholder", "Filter files…")}
leftSection={<SearchIcon sx={{ fontSize: "1rem" }} />}
rightSection={
search ? (
<ActionIcon
variant="tertiary"
size="sm"
onClick={() => setSearch("")}
aria-label={t("filesPage.search.clear", "Clear filter")}
>
<CloseIcon sx={{ fontSize: "0.9rem" }} />
</ActionIcon>
) : null
}
aria-label={t("filesPage.search.label", "Filter files by name")}
style={{ width: 180 }}
/>
<Select
size="xs"
value={sortMode}
@@ -1471,7 +1433,6 @@ export default function FileManagerView() {
entries={entries}
loading={loading}
currentTab={currentTab}
searchActive={search.trim().length > 0}
serverReachable={folders.serverReachable}
selectedFileIds={selectedFileIds}
activeWorkspaceFileIds={activeWorkspaceFileIdSet}
@@ -1694,6 +1655,39 @@ export default function FileManagerView() {
);
}
const SearchField = React.forwardRef<
HTMLInputElement,
{ value: string; onChange: (v: string) => void }
>(function SearchField({ value, onChange }, ref) {
const { t } = useTranslation();
return (
<div className="files-page-search">
<SearchIcon fontSize="small" style={{ color: "var(--c-text-subtle)" }} />
<input
ref={ref}
type="text"
value={value}
onChange={(e) => onChange(e.currentTarget.value)}
placeholder={t(
"filesPage.searchPlaceholder",
"Search this folder & subfolders",
)}
aria-label={t("filesPage.search", "Search")}
/>
{value && (
<ActionIcon
variant="tertiary"
size="sm"
onClick={() => onChange("")}
aria-label={t("filesPage.clearSearch", "Clear search")}
>
&times;
</ActionIcon>
)}
</div>
);
});
function Breadcrumbs() {
const { t } = useTranslation();
const folders = useFolders();
@@ -28,13 +28,13 @@ const styles = {
},
local: {
background:
"color-mix(in srgb, var(--text-muted, #6b7280) 16%, transparent)",
color: "var(--text-secondary)",
"color-mix(in srgb, var(--c-text-subtle, #6b7280) 16%, transparent)",
color: "var(--c-text-muted)",
},
cloud: {
background:
"color-mix(in srgb, var(--accent-interactive, #6366f1) 16%, transparent)",
color: "var(--accent-interactive, #6366f1)",
"color-mix(in srgb, var(--c-primary, #6366f1) 16%, transparent)",
color: "var(--c-primary, #6366f1)",
},
shared: {
background:
@@ -3,8 +3,8 @@
flex-direction: column;
width: 100%;
height: 100%;
background: var(--bg-background);
color: var(--text-primary);
background: var(--c-bg);
color: var(--c-text);
overflow: hidden;
}
@@ -22,8 +22,8 @@
gap: 1rem;
min-height: 48px;
padding: 0 0.75rem;
border-bottom: 1px solid var(--border-subtle);
background: var(--bg-toolbar);
border-bottom: 1px solid var(--c-border-subtle);
background: var(--c-bg-raised);
flex-shrink: 0;
}
@@ -52,7 +52,7 @@
border: none;
padding: 0.25rem 0.5rem;
border-radius: 0.375rem;
color: var(--text-secondary);
color: var(--c-text-muted);
cursor: pointer;
font-size: inherit;
font-weight: 500;
@@ -64,19 +64,14 @@
overflow: hidden;
text-overflow: ellipsis;
}
.files-page-breadcrumb:hover {
background: var(--hover-bg);
color: var(--text-primary);
}
.files-page-breadcrumb:hover,
.files-page-breadcrumb.is-current {
color: var(--text-primary);
background: var(--hover-bg);
background: var(--c-hover);
color: var(--c-text);
}
.files-page-breadcrumb-sep {
color: var(--text-muted);
color: var(--c-text-subtle);
font-size: 1rem !important;
width: 1rem;
height: 1rem;
@@ -88,8 +83,8 @@
display: flex;
align-items: center;
gap: 0.35rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
border-radius: 999px;
padding: 0.2rem 0.75rem;
/* Fills its grid cell; the cell's minmax(...) clamps to a sensible range. */
@@ -102,7 +97,7 @@
border: none;
outline: none;
flex: 1;
color: var(--text-primary);
color: var(--c-text);
font-size: 0.9rem;
}
@@ -116,8 +111,8 @@
.files-page-tree {
width: 17rem;
flex-shrink: 0;
border-right: 1px solid var(--border-subtle);
background: var(--bg-toolbar);
border-right: 1px solid var(--c-border-subtle);
background: var(--c-bg-raised);
overflow-y: auto;
display: flex;
flex-direction: column;
@@ -135,7 +130,7 @@
font-size: 0.8rem;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--text-muted);
color: var(--c-text-subtle);
}
/* Tree node styles moved to FolderTreePanel.css - that's where the
@@ -156,8 +151,8 @@
align-items: center;
gap: 0.75rem;
padding: 0.55rem 1.25rem;
border-bottom: 1px solid var(--border-subtle);
background: var(--bg-background);
border-bottom: 1px solid var(--c-border-subtle);
background: var(--c-bg);
flex-shrink: 0;
flex-wrap: wrap;
min-height: 3rem;
@@ -165,7 +160,7 @@
.files-page-toolbar-info {
font-size: 0.85rem;
color: var(--text-secondary);
color: var(--c-text-muted);
font-weight: 500;
}
@@ -178,7 +173,7 @@
}
.files-page-toolbar-info span {
color: var(--text-muted);
color: var(--c-text-subtle);
}
.files-page-toolbar-actions {
@@ -226,7 +221,7 @@
.files-page-toolbar-divider {
width: 1px;
height: 1.4rem;
background: var(--border-subtle);
background: var(--c-border-subtle);
margin: 0 0.15rem;
}
@@ -264,7 +259,7 @@
padding: 1.25rem;
position: relative;
scrollbar-width: thin;
scrollbar-color: var(--border-subtle) transparent;
scrollbar-color: var(--c-border-subtle) transparent;
}
.files-page-content::-webkit-scrollbar {
@@ -273,14 +268,14 @@
}
.files-page-content::-webkit-scrollbar-thumb {
background: var(--border-subtle);
background: var(--c-border-subtle);
border-radius: 999px;
border: 2px solid transparent;
background-clip: content-box;
}
.files-page-content::-webkit-scrollbar-thumb:hover {
background: var(--text-muted);
background: var(--c-text-subtle);
background-clip: content-box;
}
@@ -288,7 +283,7 @@
.folder-tree-panel-inner,
.files-page-details-body {
scrollbar-width: thin;
scrollbar-color: var(--border-subtle) transparent;
scrollbar-color: var(--c-border-subtle) transparent;
}
.files-page-tree-list::-webkit-scrollbar,
@@ -300,7 +295,7 @@
.files-page-tree-list::-webkit-scrollbar-thumb,
.folder-tree-panel-inner::-webkit-scrollbar-thumb,
.files-page-details-body::-webkit-scrollbar-thumb {
background: var(--border-subtle);
background: var(--c-border-subtle);
border-radius: 999px;
}
@@ -313,10 +308,10 @@
.files-page-list {
display: flex;
flex-direction: column;
border: 1px solid var(--border-subtle);
border: 1px solid var(--c-border-subtle);
border-radius: 0.6rem;
overflow: hidden;
background: var(--bg-surface);
background: var(--c-surface);
}
.files-page-list-row {
@@ -325,7 +320,7 @@
gap: 0.5rem;
align-items: center;
padding: 0.5rem 0.75rem;
border-bottom: 1px solid var(--border-subtle);
border-bottom: 1px solid var(--c-border-subtle);
cursor: pointer;
font-size: 0.9rem;
transition: background-color 0.12s ease;
@@ -336,8 +331,8 @@
}
.files-page-list-row.is-header {
background: var(--bg-toolbar);
color: var(--text-muted);
background: var(--c-bg-raised);
color: var(--c-text-subtle);
text-transform: uppercase;
font-size: 0.72rem;
letter-spacing: 0.05em;
@@ -356,33 +351,25 @@
}
.files-page-list-row.is-header [data-sortable="true"]:hover {
background: var(--hover-bg);
color: var(--text-primary);
background: var(--c-hover);
color: var(--c-text);
}
.files-page-list-row:not(.is-header):hover {
background: var(--hover-bg);
}
.files-page-list-row:not(.is-header):hover,
.files-page-list-row.is-selected {
background: var(--hover-bg);
background: var(--c-hover);
}
.files-page-list-row.is-drop-target {
background: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 12%,
transparent
);
box-shadow: inset 0 0 0 1px var(--accent-interactive, #6366f1);
background: color-mix(in srgb, var(--c-primary) 12%, transparent);
box-shadow: inset 0 0 0 1px var(--c-primary);
}
.files-page-card {
position: relative;
display: flex;
flex-direction: column;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
border-radius: 0.85rem;
overflow: hidden;
cursor: pointer;
@@ -397,8 +384,8 @@
transform: translateY(-2px);
border-color: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 35%,
var(--border-subtle)
var(--c-primary) 35%,
var(--c-border-subtle)
);
box-shadow:
0 4px 6px -1px rgba(0, 0, 0, 0.08),
@@ -406,16 +393,15 @@
}
.files-page-card:focus-visible {
outline: 2px solid var(--accent-interactive, #6366f1);
outline: 2px solid var(--c-primary);
outline-offset: 2px;
}
.files-page-card.is-selected {
border-color: var(--accent-interactive, #6366f1);
border-color: var(--c-primary);
box-shadow:
0 0 0 2px var(--accent-interactive, #6366f1),
0 6px 18px -6px
color-mix(in srgb, var(--accent-interactive, #6366f1) 35%, transparent);
0 0 0 2px var(--c-primary),
0 6px 18px -6px color-mix(in srgb, var(--c-primary) 35%, transparent);
}
.files-page-card.is-folder {
@@ -426,8 +412,8 @@
aspect-ratio: 4 / 3;
background: linear-gradient(
180deg,
color-mix(in srgb, var(--text-muted) 5%, var(--bg-surface)),
var(--bg-surface)
color-mix(in srgb, var(--c-text-subtle) 5%, var(--c-surface)),
var(--c-surface)
);
display: flex;
align-items: center;
@@ -452,7 +438,7 @@
flex-direction: column;
align-items: center;
gap: 0.4rem;
color: var(--text-muted);
color: var(--c-text-subtle);
font-size: 0.72rem;
font-weight: 600;
letter-spacing: 0.04em;
@@ -472,13 +458,13 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: var(--text-primary);
color: var(--c-text);
letter-spacing: -0.005em;
}
.files-page-card-meta {
font-size: 0.76rem;
color: var(--text-muted);
color: var(--c-text-subtle);
display: flex;
align-items: center;
gap: 0.4rem;
@@ -488,7 +474,7 @@
the user can tell which folder each hit lives in without navigating. */
.files-page-card-path {
font-size: 0.72rem;
color: var(--text-muted);
color: var(--c-text-subtle);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@@ -517,8 +503,8 @@
/* Style the Mantine checkbox so it reads as a soft pill rather than a
bare form control. */
.files-page-card-selector :where(.mantine-Checkbox-input) {
background: var(--bg-surface);
border-color: var(--border-subtle);
background: var(--c-surface);
border-color: var(--c-border-subtle);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
@@ -536,26 +522,26 @@
Use stronger specificity + !important to win over Mantine's
variant=filled inline styles. */
.files-page-card .files-page-card-actions button.mantine-ActionIcon-root {
background-color: var(--bg-raised, var(--bg-surface)) !important;
color: var(--text-primary) !important;
border: 1px solid var(--border-default, var(--border-subtle)) !important;
background-color: var(--c-surface-raised, var(--c-surface)) !important;
color: var(--c-text) !important;
border: 1px solid var(--c-border, var(--c-border-subtle)) !important;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
backdrop-filter: blur(6px);
}
.files-page-card .files-page-card-actions button.mantine-ActionIcon-root:hover {
background-color: var(--hover-bg) !important;
background-color: var(--c-hover) !important;
}
/* Row-view kebab: same high-contrast treatment so it's readable
against selected (tinted) and in-workspace rows. */
.files-page-list-row .mantine-ActionIcon-root[aria-label$="actions"] {
color: var(--text-secondary);
color: var(--c-text-muted);
}
.files-page-list-row .mantine-ActionIcon-root[aria-label$="actions"]:hover {
background-color: var(--hover-bg) !important;
color: var(--text-primary);
background-color: var(--c-hover) !important;
color: var(--c-text);
}
.files-page-card-origin {
@@ -578,7 +564,7 @@
gap: 0.35rem;
padding: 0.22rem 0.55rem;
border-radius: 999px;
background: var(--mantine-color-teal-6, #10b981);
background: var(--mantine-color-teal-6, var(--p-emerald-500));
color: #ffffff;
font-size: 0.68rem;
font-weight: 700;
@@ -614,8 +600,8 @@
.files-page-card.is-in-workspace {
border-color: color-mix(
in srgb,
var(--mantine-color-teal-6, #10b981) 35%,
var(--border-subtle)
var(--mantine-color-teal-6, var(--p-emerald-500)) 35%,
var(--c-border-subtle)
);
}
@@ -627,7 +613,12 @@
pointer-events: none;
background: linear-gradient(
180deg,
color-mix(in srgb, var(--mantine-color-teal-6, #10b981) 6%, transparent) 0%,
color-mix(
in srgb,
var(--mantine-color-teal-6, var(--p-emerald-500)) 6%,
transparent
)
0%,
transparent 40%
);
z-index: 0;
@@ -639,7 +630,7 @@
gap: 0.3rem;
padding: 0.12rem 0.5rem;
border-radius: 999px;
background: var(--mantine-color-teal-6, #10b981);
background: var(--mantine-color-teal-6, var(--p-emerald-500));
color: #ffffff;
font-size: 0.68rem;
font-weight: 700;
@@ -653,7 +644,7 @@
.files-page-list-row.is-in-workspace {
background: color-mix(
in srgb,
var(--mantine-color-teal-6, #10b981) 4%,
var(--mantine-color-teal-6, var(--p-emerald-500)) 4%,
transparent
);
}
@@ -685,13 +676,9 @@
}
.files-page-card.is-drop-target {
background: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 10%,
var(--bg-surface)
);
box-shadow: 0 0 0 2px var(--accent-interactive, #6366f1);
border-color: var(--accent-interactive, #6366f1);
background: color-mix(in srgb, var(--c-primary) 10%, var(--c-surface));
box-shadow: 0 0 0 2px var(--c-primary);
border-color: var(--c-primary);
}
@keyframes files-page-skeleton-pulse {
@@ -707,9 +694,9 @@
display: block;
background: linear-gradient(
90deg,
color-mix(in srgb, var(--text-muted) 12%, transparent) 25%,
color-mix(in srgb, var(--text-muted) 22%, transparent) 50%,
color-mix(in srgb, var(--text-muted) 12%, transparent) 75%
color-mix(in srgb, var(--c-text-subtle) 12%, transparent) 25%,
color-mix(in srgb, var(--c-text-subtle) 22%, transparent) 50%,
color-mix(in srgb, var(--c-text-subtle) 12%, transparent) 75%
);
background-size: 200% 100%;
animation: files-page-skeleton-pulse 1.4s ease-in-out infinite;
@@ -718,14 +705,14 @@
.files-page-skeleton-card {
pointer-events: none;
border-color: var(--border-subtle);
border-color: var(--c-border-subtle);
box-shadow: none;
}
.files-page-skeleton-card:hover {
transform: none;
box-shadow: none;
border-color: var(--border-subtle);
border-color: var(--c-border-subtle);
}
.files-page-skeleton-row {
@@ -743,7 +730,7 @@
justify-content: center;
height: 100%;
gap: 0.75rem;
color: var(--text-muted);
color: var(--c-text-subtle);
padding: 4rem 1.5rem;
text-align: center;
}
@@ -755,25 +742,21 @@
width: 5rem;
height: 5rem;
border-radius: 50%;
background: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 12%,
transparent
);
color: var(--accent-interactive, #6366f1);
background: color-mix(in srgb, var(--c-primary) 12%, transparent);
color: var(--c-primary);
margin-bottom: 0.25rem;
}
.files-page-empty-title {
font-size: 1.15rem;
color: var(--text-primary);
color: var(--c-text);
font-weight: 600;
letter-spacing: -0.01em;
}
.files-page-empty-hint {
font-size: 0.9rem;
color: var(--text-muted);
color: var(--c-text-subtle);
max-width: 30rem;
line-height: 1.5;
}
@@ -797,8 +780,8 @@
.files-page-details {
width: 22rem;
flex-shrink: 0;
border-left: 1px solid var(--border-subtle);
background: var(--bg-toolbar);
border-left: 1px solid var(--c-border-subtle);
background: var(--c-bg-raised);
display: flex;
flex-direction: column;
overflow: hidden;
@@ -817,7 +800,7 @@
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.files-page-details-header strong {
@@ -846,8 +829,8 @@
flex-direction: column;
gap: 0.4rem;
padding: 0.6rem 1.1rem;
border-top: 1px solid var(--border-subtle);
background: var(--bg-toolbar);
border-top: 1px solid var(--c-border-subtle);
background: var(--c-bg-raised);
}
/* Collapsible "File info" header (size/type/dates). */
@@ -857,11 +840,11 @@
justify-content: space-between;
width: 100%;
padding: 0.4rem 0.6rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
border-radius: 0.5rem;
cursor: pointer;
color: var(--text-secondary, var(--text-primary));
color: var(--c-text-muted, var(--c-text));
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 0.04em;
@@ -878,8 +861,8 @@
/* Compact fixed height (was a tall 4:3 box that dominated the panel and
pushed the action buttons off the bottom). */
height: 6.5rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
border-radius: 0.6rem;
display: flex;
align-items: center;
@@ -911,8 +894,8 @@
gap: 0.55rem;
font-size: 0.85rem;
padding: 0.65rem 0.75rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
border-radius: 0.5rem;
}
@@ -923,12 +906,12 @@
}
.files-page-details-field-label {
color: var(--text-muted);
color: var(--c-text-subtle);
font-size: 0.78rem;
}
.files-page-details-field-value {
color: var(--text-primary);
color: var(--c-text);
text-align: right;
word-break: break-word;
font-weight: 500;
@@ -939,8 +922,8 @@
flex-direction: column;
gap: 0.3rem;
padding: 0.5rem 0.6rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
border-radius: 0.5rem;
}
@@ -948,7 +931,7 @@
font-size: 0.72rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-muted);
color: var(--c-text-subtle);
}
/* Filename chip next to the title - "PDF", "DOCX", etc.
@@ -959,9 +942,9 @@
align-items: center;
padding: 0.12rem 0.5rem;
border-radius: 0.4rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
color: var(--text-secondary, var(--text-primary));
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
color: var(--c-text-muted, var(--c-text));
font-size: 0.65rem;
font-weight: 700;
letter-spacing: 0.05em;
@@ -980,8 +963,8 @@
flex-direction: column;
gap: 0.4rem;
padding: 0.55rem 0.7rem 0.7rem;
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
border-radius: 0.5rem;
}
.files-page-details-version-timeline-label {
@@ -991,12 +974,12 @@
font-size: 0.72rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.files-page-details-version-timeline-count {
margin-left: auto;
font-weight: 600;
color: var(--text-secondary, var(--text-muted));
color: var(--c-text-muted, var(--c-text-subtle));
text-transform: none;
letter-spacing: 0;
}
@@ -1026,27 +1009,26 @@
width: 0.55rem;
height: 0.55rem;
border-radius: 50%;
background: var(--bg-toolbar);
border: 2px solid var(--border-strong, var(--border-subtle));
background: var(--c-bg-raised);
border: 2px solid var(--c-border-strong, var(--c-border-subtle));
z-index: 1;
flex-shrink: 0;
}
.files-page-details-version-timeline-rail-dot.is-active {
background: var(--accent-interactive, #6366f1);
border-color: var(--accent-interactive, #6366f1);
box-shadow: 0 0 0 3px
color-mix(in srgb, var(--accent-interactive, #6366f1) 25%, transparent);
background: var(--c-primary);
border-color: var(--c-primary);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 25%, transparent);
}
.files-page-details-version-timeline-rail-dot.is-ellipsis {
width: 0.35rem;
height: 0.35rem;
background: var(--text-muted);
background: var(--c-text-subtle);
border-color: transparent;
}
.files-page-details-version-timeline-rail-line {
width: 2px;
flex: 1;
background: var(--border-subtle);
background: var(--c-border-subtle);
min-height: 0.6rem;
margin-top: 2px;
}
@@ -1062,11 +1044,7 @@
}
.files-page-details-version-timeline-row.is-active
.files-page-details-version-timeline-body {
background: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 10%,
transparent
);
background: color-mix(in srgb, var(--c-primary) 10%, transparent);
}
.files-page-details-version-timeline-summary {
appearance: none;
@@ -1084,11 +1062,11 @@
}
.files-page-details-version-timeline-summary:hover
.files-page-details-version-timeline-chevron {
color: var(--text-primary);
color: var(--c-text);
}
.files-page-details-version-timeline-delta {
font-size: 0.82rem;
color: var(--text-primary);
color: var(--c-text);
font-weight: 500;
white-space: nowrap;
overflow: hidden;
@@ -1099,30 +1077,30 @@
}
.files-page-details-version-timeline-delta.is-origin {
font-weight: 400;
color: var(--text-muted);
color: var(--c-text-subtle);
font-style: italic;
}
.files-page-details-version-timeline-delta-plus {
color: var(--accent-interactive, #6366f1);
color: var(--c-primary);
font-weight: 700;
}
.files-page-details-version-timeline-spacer {
flex: 1;
}
.files-page-details-version-timeline-chevron {
color: var(--text-muted);
color: var(--c-text-subtle);
transition: transform 0.15s ease;
}
.files-page-details-version-timeline-chevron.is-expanded {
transform: rotate(180deg);
color: var(--text-primary);
color: var(--c-text);
}
.files-page-details-version-timeline-meta-line {
display: flex;
align-items: center;
gap: 0.35rem;
font-size: 0.7rem;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.files-page-details-version-timeline-expanded {
display: flex;
@@ -1130,7 +1108,7 @@
gap: 0.4rem;
margin-top: 0.45rem;
padding-top: 0.5rem;
border-top: 1px dashed var(--border-subtle);
border-top: 1px dashed var(--c-border-subtle);
}
.files-page-details-version-timeline-toolchain {
display: flex;
@@ -1139,7 +1117,7 @@
}
.files-page-details-version-timeline-toolchain-label {
font-size: 0.65rem;
color: var(--text-muted);
color: var(--c-text-subtle);
text-transform: uppercase;
letter-spacing: 0.05em;
}
@@ -1147,12 +1125,12 @@
.files-page-details-version-timeline-collapse-btn {
appearance: none;
background: none;
border: 1px dashed var(--border-subtle);
border: 1px dashed var(--c-border-subtle);
border-radius: 0.3rem;
padding: 0.25rem 0.5rem;
margin: 0.1rem 0;
font-size: 0.72rem;
color: var(--text-muted);
color: var(--c-text-subtle);
cursor: pointer;
text-align: left;
transition:
@@ -1161,8 +1139,8 @@
}
.files-page-details-version-timeline-ellipsis-btn:hover,
.files-page-details-version-timeline-collapse-btn:hover {
color: var(--text-primary);
border-color: var(--border-strong, var(--text-muted));
color: var(--c-text);
border-color: var(--c-border-strong, var(--c-text-subtle));
}
.files-page-details-version-timeline-collapse-btn {
align-self: flex-start;
@@ -1172,12 +1150,8 @@
.files-page-drop-overlay {
position: absolute;
inset: 1rem;
background: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 14%,
var(--bg-background)
);
border: 2px dashed var(--accent-interactive, #6366f1);
background: color-mix(in srgb, var(--c-primary) 14%, var(--c-bg));
border: 2px dashed var(--c-primary);
border-radius: 1rem;
display: flex;
flex-direction: column;
@@ -1185,7 +1159,7 @@
justify-content: center;
gap: 1rem;
pointer-events: none;
color: var(--accent-interactive, #6366f1);
color: var(--c-primary);
font-weight: 600;
font-size: 1.1rem;
z-index: 10;
@@ -1200,40 +1174,28 @@
width: 4.5rem;
height: 4.5rem;
border-radius: 50%;
background: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 30%,
transparent
);
background: color-mix(in srgb, var(--c-primary) 30%, transparent);
}
.files-page-drop-overlay-icon svg {
font-size: 2.5rem !important;
color: var(--bg-background);
color: var(--c-bg);
}
.files-page-drop-overlay-sub {
font-size: 0.85rem;
font-weight: 500;
color: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 80%,
var(--text-secondary)
);
color: color-mix(in srgb, var(--c-primary) 80%, var(--c-text-muted));
}
@keyframes files-page-drop-overlay-pulse {
0%,
100% {
border-color: var(--accent-interactive, #6366f1);
border-color: var(--c-primary);
transform: scale(1);
}
50% {
border-color: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 60%,
transparent
);
border-color: color-mix(in srgb, var(--c-primary) 60%, transparent);
transform: scale(1.005);
}
}
@@ -70,7 +70,7 @@ export function FolderAppearancePicker({
borderRadius: "50%",
border:
folder.color === c
? "2px solid var(--text-primary)"
? "2px solid var(--c-text)"
: "2px solid transparent",
background: c,
cursor: disabled ? "not-allowed" : "pointer",
@@ -123,7 +123,7 @@ function Section({
fontSize: "0.7rem",
textTransform: "uppercase",
letterSpacing: "0.05em",
color: "var(--text-muted)",
color: "var(--c-text-subtle)",
fontWeight: 600,
}}
>
@@ -163,13 +163,13 @@ function IconButton({
justifyContent: "center",
fontSize: "1.1rem",
borderRadius: "0.4rem",
background: selected ? "var(--hover-bg)" : "transparent",
background: selected ? "var(--c-hover)" : "transparent",
border: selected
? "1px solid var(--accent-interactive, #6366f1)"
? "1px solid var(--c-primary, #6366f1)"
: "1px solid transparent",
cursor: disabled ? "not-allowed" : "pointer",
padding: 0,
color: "var(--text-primary)",
color: "var(--c-text)",
}}
>
{icon.glyph || "-"}
@@ -30,7 +30,7 @@ export function FolderThumbnail({
size = "thumb",
iconGlyph,
}: FolderThumbnailProps) {
const accent = color ?? "var(--accent-interactive, #6366f1)";
const accent = color ?? "var(--c-primary, #6366f1)";
const px = SIZE_PX[size];
const showBadge = size === "thumb" && (fileCount ?? 0) > 0;
// Per-instance unique ids - `${color}` previously embedded `#` and CSS
@@ -149,7 +149,7 @@ export function FolderThumbnail({
minWidth: "1.4rem",
height: "1.4rem",
borderRadius: "999px",
background: "var(--bg-surface, #fff)",
background: "var(--c-surface, #fff)",
border: `1px solid ${accent}`,
color: accent,
fontSize: "0.7rem",
@@ -15,8 +15,8 @@
.folder-tree-panel {
width: 0;
flex-shrink: 0;
background: var(--bg-toolbar);
border-right: 0 solid var(--border-subtle);
background: var(--c-bg-raised);
border-right: 0 solid var(--c-border-subtle);
overflow: hidden;
height: 100%;
pointer-events: none;
@@ -65,11 +65,7 @@
.folder-tree-panel-resizer:hover,
.folder-tree-panel-resizer:focus-visible {
background: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 35%,
transparent
);
background: color-mix(in srgb, var(--c-primary) 35%, transparent);
outline: none;
}
@@ -87,7 +83,7 @@
font-size: 13px;
font-weight: 600;
letter-spacing: 0.02em;
color: var(--text-muted);
color: var(--c-text-subtle);
text-transform: uppercase;
}
@@ -112,7 +108,7 @@
margin: 0 8px;
cursor: pointer;
user-select: none;
color: var(--text-secondary);
color: var(--c-text-muted);
font-size: 14px;
position: relative;
transition: background-color 0.15s ease;
@@ -120,23 +116,19 @@
}
.files-page-tree-node:hover {
background: var(--hover-bg);
background: var(--c-hover);
}
.files-page-tree-node.is-active {
background: var(--hover-bg);
color: var(--text-primary);
background: var(--c-hover);
color: var(--c-text);
font-weight: 500;
}
.files-page-tree-node.is-drop-target {
background: color-mix(
in srgb,
var(--accent-interactive, #6366f1) 12%,
transparent
);
box-shadow: inset 0 0 0 1px var(--accent-interactive, #6366f1);
color: var(--text-primary);
background: color-mix(in srgb, var(--c-primary) 12%, transparent);
box-shadow: inset 0 0 0 1px var(--c-primary);
color: var(--c-text);
}
.files-page-tree-toggle {
@@ -145,7 +137,7 @@
justify-content: center;
width: 16px;
height: 16px;
color: var(--text-muted);
color: var(--c-text-subtle);
flex-shrink: 0;
}
@@ -165,7 +157,7 @@
align-items: center;
justify-content: center;
flex-shrink: 0;
color: var(--text-muted);
color: var(--c-text-subtle);
margin-left: 8px;
font-size: 18px;
}
@@ -183,7 +175,7 @@
}
.files-page-tree-count {
color: var(--text-muted);
color: var(--c-text-subtle);
font-size: 12px;
flex-shrink: 0;
margin-left: 8px;
@@ -127,7 +127,7 @@ export function MoveToFolderDialog({
</Text>
<div
style={{
border: "1px solid var(--border-subtle)",
border: "1px solid var(--c-border-subtle)",
borderRadius: "0.5rem",
maxHeight: "20rem",
overflowY: "auto",
@@ -343,8 +343,8 @@ function FolderPick({
opacity: disabled ? 0.45 : 1,
gap: "0.5rem",
padding: `0.4rem 0.75rem 0.4rem ${0.75 + depth * 0.85}rem`,
background: isActive ? "var(--hover-bg)" : "transparent",
borderBottom: "1px solid var(--border-subtle)",
background: isActive ? "var(--c-hover)" : "transparent",
borderBottom: "1px solid var(--c-border-subtle)",
boxSizing: "border-box",
fontWeight: isActive ? 600 : 400,
}}
@@ -1,40 +1,3 @@
/* Positioning context for the viewer toolbar's reopen tab, which hangs below
the bar and so must sit outside the overflow-clipped wrapper below. */
.workbenchBarShell {
position: relative;
flex-shrink: 0;
z-index: 51;
}
/* Little pull-tab shown while the viewer tool row is retracted. Anchored to the
bar's bottom-right edge (where the retract handle sat). Small by design - it
just brings the row back. */
.workbenchBarReopenTab {
position: absolute;
top: 100%;
right: 12px;
display: flex;
align-items: center;
justify-content: center;
width: 2.25rem;
height: 0.875rem;
border: 1px solid var(--border-subtle);
border-top: none;
border-radius: 0 0 7px 7px;
background: var(--bg-toolbar);
color: var(--text-muted);
cursor: pointer;
z-index: 52;
transition:
color 0.15s ease,
background-color 0.15s ease;
}
.workbenchBarReopenTab:hover {
color: var(--text-primary);
background: var(--hover-bg);
}
/* WorkbenchBar slide-in/out animation using CSS grid trick */
.workbenchBarWrapper {
display: grid;
@@ -1,8 +1,5 @@
import { useEffect, useState, Suspense, lazy } from "react";
import { useTranslation } from "react-i18next";
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
import { Box, Loader, Center } from "@mantine/core";
import { Button } from "@app/ui/Button";
import { useToolWorkflow } from "@app/contexts/ToolWorkflowContext";
import { useFileHandler } from "@app/hooks/useFileHandler";
import { useFileState } from "@app/contexts/FileContext";
@@ -70,13 +67,10 @@ export default function Workbench() {
const selectedTool = selectedToolId ? toolRegistry[selectedToolId] : null;
const { addFiles } = useFileHandler();
const hasFiles = activeFiles.length > 0;
const { t } = useTranslation();
// The viewer's tool row can be retracted to give the document more height.
// State lives here (not in WorkbenchBar) so the reopen tab can hang below the
// bar, outside the bar's overflow-clipped wrapper. Scoped to the viewer.
const [viewerToolbarCollapsed, setViewerToolbarCollapsed] = useState(false);
const showReopenTab = currentView === "viewer" && viewerToolbarCollapsed;
// Custom workbench views (e.g. Watched Folders) manage their own content and may
// have no workbench files, but still need the bar's view switcher so users can
// navigate back out.
const isCustomViewActive = !isBaseWorkbench(currentView);
// Enable bar transitions after first paint so the initial hidden state shows
// without animating (landing page on load shouldn't animate the bar up).
@@ -224,44 +218,24 @@ export default function Workbench() {
<Box
className="flex-1 h-full min-w-0 relative flex flex-col"
data-tour="workbench"
style={{ backgroundColor: "var(--bg-background)", minWidth: 0 }}
style={{ backgroundColor: "var(--c-bg)", minWidth: 0 }}
>
{/* Workbench Bar - animates in/out based on file presence */}
{currentView !== "myFiles" &&
!customWorkbenchViews.find((v) => v.workbenchId === currentView)
?.hideTopControls && (
<div className={styles.workbenchBarShell}>
<div
className={styles.workbenchBarWrapper}
data-hidden="false"
data-no-transition={String(!barTransitionEnabled)}
>
<div className={styles.workbenchBarInner}>
<WorkbenchBar
currentView={currentView}
setCurrentView={setCurrentView}
hasFiles={hasFiles}
viewerToolbarCollapsed={viewerToolbarCollapsed}
onCollapseViewerToolbar={setViewerToolbarCollapsed}
/>
</div>
</div>
{/* Reopen tab: a little handle hanging off the bar's bottom-right
while the viewer tool row is retracted. */}
{showReopenTab && (
<Button
type="button"
variant="quiet"
className={styles.workbenchBarReopenTab}
onClick={() => setViewerToolbarCollapsed(false)}
aria-expanded={false}
aria-label={t("workbenchBar.showToolbar", "Show toolbar")}
title={t("workbenchBar.showToolbar", "Show toolbar")}
leftSection={
<KeyboardArrowDownIcon sx={{ fontSize: "1rem" }} />
}
<div
className={styles.workbenchBarWrapper}
data-hidden={String(!hasFiles && !isCustomViewActive)}
data-no-transition={String(!barTransitionEnabled)}
>
<div className={styles.workbenchBarInner}>
<WorkbenchBar
currentView={currentView}
setCurrentView={setCurrentView}
hasFiles={hasFiles}
/>
)}
</div>
</div>
)}
@@ -22,7 +22,7 @@
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 16px 32px rgba(15, 23, 42, 0.18);
box-shadow: 0 16px 32px color-mix(in srgb, var(--p-gray-900) 18%, transparent);
animation: heroLogoScale 0.25s ease forwards;
}
@@ -49,10 +49,10 @@
.securityCard {
width: 100%;
max-width: 480px;
background: var(--bg-surface, #ffffff);
background: var(--c-surface, #ffffff);
border-radius: 16px;
padding: 20px;
box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
box-shadow: 0 12px 32px color-mix(in srgb, var(--p-gray-900) 12%, transparent);
display: flex;
flex-direction: column;
gap: 16px;
@@ -65,7 +65,7 @@
font-weight: 500;
font-size: 15px;
line-height: 1.5;
color: var(--onboarding-body, #1f2937);
color: var(--c-text-muted, var(--p-gray-800));
}
.mfaSlideContent {
@@ -77,10 +77,10 @@
.mfaCard {
width: 100%;
max-width: 560px;
background: var(--bg-surface, #ffffff);
background: var(--c-surface, #ffffff);
border-radius: 16px;
padding: 20px;
box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
box-shadow: 0 12px 32px color-mix(in srgb, var(--p-gray-900) 12%, transparent);
}
.mfaSetupGrid {
@@ -94,7 +94,7 @@
padding: 12px;
background: #ffffff;
border-radius: 12px;
box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
box-shadow: 0 8px 16px color-mix(in srgb, var(--p-gray-900) 12%, transparent);
display: flex;
justify-content: center;
}
@@ -102,7 +102,7 @@
.mfaSteps {
margin: 0;
padding-left: 18px;
color: var(--onboarding-body, #1f2937);
color: var(--c-text-muted, var(--p-gray-800));
font-size: 14px;
line-height: 1.5;
}
@@ -149,11 +149,7 @@
padding: 4px;
outline: none;
}
.iconButton:focus {
outline: none;
}
.iconButton:focus,
.iconButton:focus-visible {
outline: none;
}
@@ -194,14 +190,7 @@
text-align: center;
animation: heroLogoEnter 0.25s ease forwards;
}
.title {
text-align: center;
opacity: 0;
transform: translateX(24px);
animation: bodySlideIn 0.25s ease forwards;
}
.title,
.bodyCopy {
text-align: center;
opacity: 0;
@@ -273,13 +262,13 @@
opacity: 1;
border: 1px solid rgba(255, 255, 255, 0.9);
background: rgba(255, 255, 255, 0.9);
color: #1f2933;
color: var(--p-gray-800);
box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}
/* Modal content styles */
.modalContent {
background: var(--bg-surface);
background: var(--c-surface);
position: relative;
}
@@ -299,7 +288,7 @@
sans-serif;
font-weight: 600;
font-size: 22px;
color: var(--onboarding-title);
color: var(--c-text);
}
/* Body text styles */
@@ -313,7 +302,7 @@
Arial,
sans-serif;
font-size: 16px;
color: var(--onboarding-body);
color: var(--c-text-muted);
line-height: 1.5;
}
@@ -335,8 +324,8 @@
}
.v2Badge {
background: #dbefff;
color: #2a4bff;
background: var(--c-primary-tint);
color: var(--c-accent-fg);
padding: 3px 9px;
border-radius: 6px;
font-size: 12px;
@@ -345,7 +334,7 @@
/* Icon styles */
.heroIcon {
color: var(--onboarding-title, #0f172a);
color: var(--c-text, var(--p-gray-900));
}
/* ===================================================================== */
@@ -353,7 +342,7 @@
/* ===================================================================== */
.card {
background: var(--bg-surface);
background: var(--c-surface);
display: flex;
flex-direction: column;
}
@@ -383,7 +372,7 @@
font-size: 17px;
font-weight: 700;
letter-spacing: -0.01em;
color: var(--onboarding-title, #0f172a);
color: var(--c-text, var(--p-gray-900));
}
.headerRight {
@@ -395,8 +384,8 @@
.stepPill {
font-size: 12px;
font-weight: 600;
color: var(--onboarding-body, #64748b);
background: var(--bg-muted, #f1f5f9);
color: var(--c-text-muted, var(--p-gray-500));
background: var(--c-surface-sunken, var(--p-gray-100));
padding: 5px 11px;
border-radius: 9999px;
white-space: nowrap;
@@ -413,17 +402,20 @@
flex: 1;
height: 5px;
border-radius: 9999px;
background: var(--onboarding-step-inactive, #e2e8f0);
background: var(--onboarding-step-inactive, var(--p-gray-250));
transition: background 0.2s ease;
}
.progressSegDone {
background: var(--color-blue, #3b82f6);
background: var(--c-primary, var(--p-blue-500));
}
.divider {
height: 1px;
background: var(--border-subtle, rgba(15, 23, 42, 0.08));
background: var(
--c-border-subtle,
color-mix(in srgb, var(--p-gray-900) 8%, transparent)
);
}
/* ---- content ---- */
@@ -445,7 +437,12 @@
min-height: 128px;
border-radius: 14px;
overflow: hidden;
background: linear-gradient(155deg, #eef1fb 0%, #f6f4fc 55%, #fbf4f7 100%);
background: linear-gradient(
155deg,
var(--p-tint-blue) 0%,
var(--p-tint-violet) 55%,
var(--p-tint-pink) 100%
);
}
.heroArt {
@@ -459,7 +456,9 @@
height: 62px;
border-radius: 15px;
object-fit: contain;
filter: drop-shadow(0 10px 20px rgba(15, 23, 42, 0.16));
filter: drop-shadow(
0 10px 20px color-mix(in srgb, var(--p-gray-900) 16%, transparent)
);
}
.heroTile {
@@ -470,7 +469,7 @@
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
box-shadow: 0 10px 22px color-mix(in srgb, var(--p-gray-900) 14%, transparent);
}
/* ---- title + body (left-aligned, clean) ---- */
@@ -479,14 +478,14 @@
font-weight: 600;
letter-spacing: -0.01em;
line-height: 1.3;
color: var(--onboarding-title, #0f172a);
color: var(--c-text, var(--p-gray-900));
text-align: left;
}
.bodyNew {
font-size: 14px;
line-height: 1.5;
color: var(--onboarding-body, #475569);
color: var(--c-text-muted, var(--p-gray-600));
text-align: left;
}
@@ -515,14 +514,15 @@
/* ---- dark theme surface tuning ---- */
:global([data-mantine-color-scheme="dark"]) .heroPanel {
background: linear-gradient(155deg, #1a2236 0%, #171e30 55%, #201a28 100%);
background: linear-gradient(
155deg,
var(--p-navy-850) 0%,
var(--p-navy-880) 55%,
var(--p-plum-900) 100%
);
}
:global([data-mantine-color-scheme="dark"]) .heroTile {
background: #0f1626;
background: var(--p-navy-900);
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}
:global([data-mantine-color-scheme="dark"]) .divider {
background: rgba(255, 255, 255, 0.08);
}
@@ -116,7 +116,7 @@ export default function OnboardingSlideShell({
content: {
overflow: "hidden",
border: "none",
background: "var(--bg-surface)",
background: "var(--c-surface)",
maxHeight: "90vh",
},
}}
@@ -193,7 +193,7 @@ export default function OnboardingSlideShell({
<div key={`body-${slideKey}`} className={styles.bodyNew}>
{body}
<style>{`.${styles.bodyNew} strong{color: var(--onboarding-title); font-weight: 600;}`}</style>
<style>{`.${styles.bodyNew} strong{color: var(--c-text); font-weight: 600;}`}</style>
</div>
<div className={styles.footer}>
@@ -13,7 +13,7 @@
box-shadow:
0 0 0 2px var(--mantine-primary-color-filled),
0 0 15px var(--mantine-primary-color-filled),
inset 0 0 15px rgba(59, 130, 246, 0.1);
inset 0 0 15px color-mix(in srgb, var(--p-blue-500) 10%, transparent);
border-radius: 8px;
}
@@ -23,13 +23,13 @@
box-shadow:
0 0 0 3px var(--mantine-primary-color-filled),
0 0 20px var(--mantine-primary-color-filled),
inset 0 0 20px rgba(59, 130, 246, 0.1);
inset 0 0 20px color-mix(in srgb, var(--p-blue-500) 10%, transparent);
}
50% {
box-shadow:
0 0 0 3px var(--mantine-primary-color-filled),
0 0 30px var(--mantine-primary-color-filled),
inset 0 0 30px rgba(59, 130, 246, 0.2);
inset 0 0 30px color-mix(in srgb, var(--p-blue-500) 20%, transparent);
}
}
@@ -40,7 +40,7 @@
position: absolute;
border-radius: 50%;
pointer-events: none;
box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
box-shadow: 0 18px 36px color-mix(in srgb, var(--p-gray-900) 12%, transparent);
animation-name: circleSway;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
@@ -129,9 +129,9 @@ export const DesktopInstallTitle: React.FC<DesktopInstallTitleProps> = ({
leftSection={iconKey ? <OsIcon os={iconKey} /> : undefined}
style={{
backgroundColor: isSelected
? "var(--bg-muted, #f1f5f9)"
? "var(--c-surface-sunken, #f1f5f9)"
: "transparent",
color: "var(--onboarding-title, #0f172a)",
color: "var(--c-text, #0f172a)",
fontWeight: isSelected ? 600 : 500,
}}
>
@@ -125,7 +125,7 @@ function FirstLoginForm({
icon="info-rounded"
width={20}
height={20}
style={{ color: "#3B82F6", flexShrink: 0 }}
style={{ color: "var(--p-blue-500)", flexShrink: 0 }}
/>
<span>
{t(
@@ -26,7 +26,7 @@ export default function SecurityCheckSlide({
icon="error"
width={20}
height={20}
style={{ color: "#F04438", flexShrink: 0 }}
style={{ color: "var(--p-red-500)", flexShrink: 0 }}
/>
<span>
{i18n.t(
@@ -28,15 +28,15 @@
.selectionBox {
position: absolute;
border: 2px dashed #3b82f6;
background-color: rgba(59, 130, 246, 0.1);
border: 2px dashed var(--c-primary);
background-color: color-mix(in srgb, var(--c-primary) 10%, transparent);
pointer-events: none;
}
.dropIndicator {
position: absolute;
width: 4px;
background-color: rgba(96, 165, 250, 0.8);
background-color: color-mix(in srgb, var(--c-primary) 80%, transparent);
border-radius: 2px;
pointer-events: none;
}
@@ -50,8 +50,8 @@
position: absolute;
top: -8px;
right: -8px;
background-color: #3b82f6;
color: #ffffff;
background-color: var(--c-primary);
color: var(--c-text-on-primary);
border-radius: 50%;
width: 32px;
height: 32px;
@@ -241,7 +241,7 @@ const FileThumbnail = ({
<CheckboxIndicator
checked={isSelected}
onChange={() => onToggleFile(file.id)}
color="var(--checkbox-checked-bg)"
color="var(--c-primary)"
/>
) : (
<div className={styles.unsupportedPill}>
@@ -372,7 +372,7 @@ const FileThumbnail = ({
objectFit: "contain",
borderRadius: 0,
background: "#ffffff",
border: "1px solid var(--border-default)",
border: "1px solid var(--c-border)",
display: "block",
marginLeft: "auto",
marginRight: "auto",
@@ -21,13 +21,13 @@
@keyframes pageMovedHighlight {
0% {
background-color: rgba(59, 130, 246, 0.32);
background-color: color-mix(in srgb, var(--c-primary) 32%, transparent);
}
60% {
background-color: rgba(59, 130, 246, 0.12);
background-color: color-mix(in srgb, var(--c-primary) 12%, transparent);
}
100% {
background-color: rgba(59, 130, 246, 0);
background-color: color-mix(in srgb, var(--c-primary) 0%, transparent);
}
}
@@ -63,7 +63,7 @@
/* Action styles */
.actionRow:hover {
background: var(--hover-bg);
background: var(--c-hover);
}
.actionDanger {
@@ -72,7 +72,7 @@
.actionsDivider {
height: 1px;
background: var(--border-default);
background: var(--c-border);
margin: 4px 0;
}
@@ -86,7 +86,7 @@
.unsupportedPill {
margin-left: 1.75rem;
background: #6b7280;
background: var(--p-gray-500);
color: white;
padding: 4px 8px;
border-radius: 12px;
@@ -121,8 +121,8 @@ const PageEditorControls = ({
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
boxShadow: "0 -2px 8px rgba(0,0,0,0.04)",
backgroundColor: "var(--bg-toolbar)",
border: "1px solid var(--border-default)",
backgroundColor: "var(--c-bg-raised)",
border: "1px solid var(--c-border)",
borderRadius: "16px 16px 0 0",
pointerEvents: "auto",
minWidth: 360,
@@ -31,7 +31,7 @@
.rightCol {
width: 8rem;
border-left: 0.0625rem solid var(--border-default);
border-left: 0.0625rem solid var(--c-border);
padding-left: 0.75rem;
display: flex;
flex-direction: column;
@@ -47,15 +47,15 @@
width: 100%;
border-radius: 1.25rem;
border: 0.0625rem solid var(--bulk-card-border);
background-color: var(--bulk-card-bg);
color: var(--text-primary);
background-color: var(--c-surface);
color: var(--c-text);
transition: all 0.2s ease;
min-height: 2rem;
}
.operatorChip:hover:not(:disabled) {
border-color: var(--bulk-card-hover-border);
background-color: var(--hover-bg);
background-color: var(--c-hover);
transform: translateY(-0.0625rem);
box-shadow: var(--shadow-sm);
}
@@ -70,24 +70,12 @@
cursor: not-allowed;
}
:global([data-mantine-color-scheme="dark"]) .operatorChip {
background-color: var(--bulk-card-bg);
border-color: var(--bulk-card-border);
color: var(--text-primary);
}
:global([data-mantine-color-scheme="dark"]) .operatorChip:hover:not(:disabled) {
background-color: var(--hover-bg);
border-color: var(--bulk-card-hover-border);
color: var(--text-primary);
}
.dropdownHeader {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem;
border-bottom: 0.0625rem solid var(--border-default);
border-bottom: 0.0625rem solid var(--c-border);
margin-bottom: 0.5rem;
}
@@ -111,7 +99,7 @@
}
.chevron {
color: var(--text-muted);
color: var(--c-text-subtle);
}
/* Icon-based chevrons */
@@ -151,13 +139,13 @@
.selectedList {
max-height: 8rem;
overflow: auto;
background-color: var(--bg-raised);
border: 0.0625rem solid var(--border-default);
background-color: var(--c-surface-raised);
border: 0.0625rem solid var(--c-border);
border-radius: 0.75rem;
padding: 0.5rem 0.75rem;
margin-top: 0.5rem;
min-width: 24rem;
color: var(--text-primary);
color: var(--c-text);
}
.selectedText {
@@ -175,7 +163,7 @@
justify-content: space-between;
align-items: center;
padding: 0.75rem;
border-bottom: 0.0625rem solid var(--border-default);
border-bottom: 0.0625rem solid var(--c-border);
margin-bottom: 0.5rem;
}
@@ -193,26 +181,18 @@
}
.advancedItem:hover {
background-color: var(--hover-bg);
}
:global([data-mantine-color-scheme="dark"]) .advancedItem:hover {
background-color: var(--hover-bg);
background-color: var(--c-hover);
}
.advancedCard {
background-color: var(--bulk-card-bg);
background-color: var(--c-surface);
border: none;
border-radius: 0.75rem;
padding: 0.25rem;
margin-bottom: 0.5rem;
width: 100%;
box-sizing: border-box;
color: var(--text-primary);
}
:global([data-mantine-color-scheme="dark"]) .advancedCard {
background-color: var(--bulk-card-bg);
color: var(--c-text);
}
.inputGroup {
@@ -226,24 +206,17 @@
.applyButton {
min-width: 4rem;
flex-shrink: 0;
}
/* Style inputs and buttons within advanced cards to match bg-raised */
.advancedCard :global(.mantine-NumberInput-input) {
background-color: var(--bg-raised) !important;
border-color: var(--border-default) !important;
color: var(--text-primary) !important;
}
} /* Style inputs and buttons within advanced cards to match bg-raised */
.advancedCard :global(.mantine-NumberInput-input),
.advancedCard :global(.mantine-Button-root) {
background-color: var(--bg-raised) !important;
border-color: var(--border-default) !important;
color: var(--text-primary) !important;
background-color: var(--c-surface-raised) !important;
border-color: var(--c-border) !important;
color: var(--c-text) !important;
}
.advancedCard :global(.mantine-Button-root:hover) {
background-color: var(--hover-bg) !important;
border-color: var(--border-strong) !important;
background-color: var(--c-hover) !important;
border-color: var(--c-border-strong) !important;
}
/* Error helper text above the input */
@@ -254,8 +227,8 @@
/* Compact error container for inline tool settings */
.errorCompact {
background-color: var(--bg-raised);
border: 0.0625rem solid var(--border-default);
background-color: var(--c-surface-raised);
border: 0.0625rem solid var(--c-border);
border-radius: 0.75rem;
padding: 0.5rem 0.75rem;
margin-top: 0.5rem;
@@ -271,11 +244,6 @@
overflow: hidden;
}
/* Dark-mode adjustments */
:global([data-mantine-color-scheme="dark"]) .selectedList {
background-color: var(--bg-raised);
}
/* Small screens: allow the section to shrink instead of enforcing a large min width */
@media (max-width: 480px) {
.panelGroup,
@@ -290,16 +258,16 @@
.panelContainer {
max-height: 95vh;
overflow: auto;
background-color: var(--bulk-panel-bg);
color: var(--text-primary);
background-color: var(--c-surface);
color: var(--c-text);
border-radius: 0.5rem;
}
/* Override Mantine Popover dropdown background */
:global(.mantine-Popover-dropdown) {
background-color: var(--bulk-panel-bg) !important;
background-color: var(--c-surface) !important;
border-color: var(--bulk-card-border) !important;
color: var(--text-primary) !important;
color: var(--c-text) !important;
}
/* Override Mantine Switch outline */
@@ -17,7 +17,7 @@ const OperatorsSection = ({
return (
<div>
<Text size="xs" c="var(--text-muted)" fw={500} mb="xs">
<Text size="xs" c="var(--c-text-subtle)" fw={500} mb="xs">
{t("bulkSelection.keywords.title", "Keywords")}:
</Text>
<Group gap="sm" wrap="nowrap">
@@ -44,7 +44,7 @@ const PageSelectionInput = ({
icon="gpp-maybe-outline-rounded"
width="1rem"
height="1rem"
style={{ color: "var(--text-instruction)" }}
style={{ color: "var(--c-accent-fg)" }}
/>
<Text>
{t("bulkSelection.pageSelection.title", "Page Selection")}
@@ -53,7 +53,7 @@ const PageSelectionInput = ({
</Tooltip>
{typeof advancedOpened === "boolean" && (
<Flex align="center" gap="xs">
<Text size="sm" c="var(--text-secondary)">
<Text size="sm" c="var(--c-text-muted)">
{t("bulkSelection.advanced.title", "Advanced")}
</Text>
<Switch
@@ -50,7 +50,7 @@ const SelectPages = ({
return (
<div className={classes.advancedCard}>
<Text size="sm" fw={600} c="var(--text-secondary)" mb="xs">
<Text size="sm" fw={600} c="var(--c-text-muted)" mb="xs">
{title}
</Text>
{error && (
@@ -1,36 +0,0 @@
// Shared source of truth for a policy category's outline icon, keyed by category
// id (not a parallel icon-name vocabulary). Used by the editor's policy
// definitions and the portal's catalogue cards, summaries, and setup wizard.
import type { ReactNode } from "react";
import type { SxProps, Theme } from "@mui/material";
import LayersOutlinedIcon from "@mui/icons-material/LayersOutlined";
import ShieldOutlinedIcon from "@mui/icons-material/ShieldOutlined";
import LabelOutlinedIcon from "@mui/icons-material/LabelOutlined";
import CheckCircleOutlinedIcon from "@mui/icons-material/CheckCircleOutlined";
import AltRouteOutlinedIcon from "@mui/icons-material/AltRouteOutlined";
import ScheduleOutlinedIcon from "@mui/icons-material/ScheduleOutlined";
type MuiIcon = React.ComponentType<{ sx?: SxProps<Theme>; className?: string }>;
/** Policy category id → outline glyph. */
const POLICY_CATEGORY_ICONS: Record<string, MuiIcon> = {
ingestion: LayersOutlinedIcon,
security: ShieldOutlinedIcon,
classification: LabelOutlinedIcon,
compliance: CheckCircleOutlinedIcon,
routing: AltRouteOutlinedIcon,
retention: ScheduleOutlinedIcon,
};
const FALLBACK_ICON = LabelOutlinedIcon;
// Defaults to inheriting the surrounding font-size so a wrapping box controls size.
export function policyCategoryIcon(
categoryId: string,
sx: SxProps<Theme> = { fontSize: "inherit" },
className?: string,
): ReactNode {
const Icon = POLICY_CATEGORY_ICONS[categoryId] ?? FALLBACK_ICON;
return <Icon sx={sx} className={className} />;
}
@@ -1,28 +1,4 @@
/* AppConfigModal styles */
/* Deep-link highlight: pulses the control the super search jumped to
(navigated via /settings/{section}?focus={anchor}). */
@keyframes settings-focus-pulse {
0% {
box-shadow: 0 0 0 3px var(--mantine-color-blue-5);
background: color-mix(
in srgb,
var(--mantine-color-blue-5) 16%,
transparent
);
}
100% {
box-shadow: 0 0 0 6px transparent;
background: transparent;
}
}
.settings-focus-target {
animation: settings-focus-pulse 1.8s ease-out;
border-radius: 8px;
scroll-margin: 1rem;
}
.modal-container {
display: flex;
gap: 0;
@@ -87,7 +63,8 @@
}
.modal-nav-scroll:hover {
scrollbar-color: rgba(128, 128, 128, 0.5) transparent;
scrollbar-color: color-mix(in srgb, var(--p-gray-mid) 50%, transparent)
transparent;
}
.modal-nav-scroll::-webkit-scrollbar {
@@ -105,11 +82,11 @@
}
.modal-nav-scroll:hover::-webkit-scrollbar-thumb {
background-color: rgba(128, 128, 128, 0.5);
background-color: color-mix(in srgb, var(--p-gray-mid) 50%, transparent);
}
.modal-nav-scroll::-webkit-scrollbar-thumb:hover {
background-color: rgba(128, 128, 128, 0.7);
background-color: color-mix(in srgb, var(--p-gray-mid) 70%, transparent);
}
.modal-nav-section {
@@ -155,7 +132,8 @@
}
.modal-content-scroll:hover {
scrollbar-color: rgba(128, 128, 128, 0.5) transparent;
scrollbar-color: color-mix(in srgb, var(--p-gray-mid) 50%, transparent)
transparent;
}
.modal-content-scroll::-webkit-scrollbar {
@@ -173,11 +151,11 @@
}
.modal-content-scroll:hover::-webkit-scrollbar-thumb {
background-color: rgba(128, 128, 128, 0.5);
background-color: color-mix(in srgb, var(--p-gray-mid) 50%, transparent);
}
.modal-content-scroll::-webkit-scrollbar-thumb:hover {
background-color: rgba(128, 128, 128, 0.7);
background-color: color-mix(in srgb, var(--p-gray-mid) 70%, transparent);
}
.modal-header {
@@ -236,8 +214,8 @@
bottom: 0;
left: 0;
right: 0;
background: var(--modal-content-bg);
border-top: 1px solid var(--modal-header-border);
background: var(--c-surface);
border-top: 1px solid var(--c-border-subtle);
padding: 1rem 2rem;
margin: 0 -2rem;
margin-bottom: -1rem;
@@ -146,33 +146,6 @@ const AppConfigModalInner: React.FC<AppConfigModalProps> = ({
[navigate, urlSync],
);
// Deep-link: /settings/{section}?focus={anchor} scrolls to and briefly
// highlights the matching control (used by the global super search to jump
// straight to an individual setting row).
useEffect(() => {
if (!opened) return;
const focus = new URLSearchParams(location.search).get("focus");
if (!focus) return;
let raf = 0;
// Wait for the (possibly just-switched) section to render before scrolling.
const timer = window.setTimeout(() => {
raf = window.requestAnimationFrame(() => {
const el = document.getElementById(focus);
if (!el) return;
el.scrollIntoView({ behavior: "smooth", block: "center" });
el.classList.add("settings-focus-target");
window.setTimeout(
() => el.classList.remove("settings-focus-target"),
1800,
);
});
}, 150);
return () => {
window.clearTimeout(timer);
if (raf) window.cancelAnimationFrame(raf);
};
}, [opened, active, location.search]);
// Backwards-compat: external `appConfig:navigate` events route through the
// same switchSection path so they get the no-flash treatment too.
useEffect(() => {
@@ -192,13 +165,13 @@ const AppConfigModalInner: React.FC<AppConfigModalProps> = ({
const colors = useMemo(
() => ({
navBg: "var(--modal-nav-bg)",
sectionTitle: "var(--modal-nav-section-title)",
navBg: "var(--c-bg-raised)",
sectionTitle: "var(--c-text-subtle)",
navItem: "var(--modal-nav-item)",
navItemActive: "var(--modal-nav-item-active)",
navItemActiveBg: "var(--modal-nav-item-active-bg)",
contentBg: "var(--modal-content-bg)",
headerBorder: "var(--modal-header-border)",
navItemActive: "var(--c-accent-fg)",
navItemActiveBg: "var(--c-primary-subtle)",
contentBg: "var(--c-surface)",
headerBorder: "var(--c-border-subtle)",
}),
[],
);
@@ -9,15 +9,15 @@
background: none;
cursor: pointer;
border-radius: var(--radius-sm);
color: var(--color-text-4);
color: var(--c-text-subtle);
transition:
background var(--motion-fast),
color var(--motion-fast);
}
.app-switch-btn:hover {
background: var(--color-bg-hover);
color: var(--color-text-2);
background: var(--c-hover);
color: var(--c-text-muted);
}
.app-switch-icon {
@@ -79,8 +79,8 @@ const Badge: React.FC<BadgeProps> = ({
// Default styling
return {
background: "var(--tool-header-badge-bg)",
color: "var(--tool-header-badge-text)",
background: "var(--c-surface-raised)",
color: "var(--c-accent-fg)",
};
};
@@ -78,7 +78,11 @@ export default function EditableSecretField({
)}
{description && (
<p
style={{ margin: "4px 0 12px 0", fontSize: "0.75rem", color: "#666" }}
style={{
margin: "4px 0 12px 0",
fontSize: "0.75rem",
color: "var(--c-text-muted)",
}}
>
{description}
</p>
@@ -117,7 +117,7 @@ export default class ErrorBoundary extends React.Component<
style={{
fontSize: "0.75rem",
overflow: "auto",
backgroundColor: "#f5f5f5",
backgroundColor: "var(--p-gray-100)",
padding: "1rem",
borderRadius: "4px",
maxHeight: "300px",
@@ -74,7 +74,7 @@ const FileCard = ({
<Stack gap={6} align="center">
<Box
style={{
border: "2px solid #e0e0e0",
border: "2px solid var(--c-border)",
borderRadius: 8,
width: 90,
height: 120,
@@ -82,7 +82,7 @@ const FileCard = ({
alignItems: "center",
justifyContent: "center",
margin: "0 auto",
background: "#fafbfc",
background: "var(--c-surface)",
position: "relative",
}}
>
@@ -54,8 +54,8 @@ export const FileDropdownMenu: React.FC<FileDropdownMenuProps> = ({
</Menu.Target>
<Menu.Dropdown
style={{
backgroundColor: "var(--bg-file-manager)",
border: "1px solid var(--border-subtle)",
backgroundColor: "var(--c-bg)",
border: "1px solid var(--c-border-subtle)",
borderRadius: "8px",
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
maxHeight: "50vh",
@@ -1,9 +1,9 @@
/* ── Trigger ─────────────────────────────────────── */
.trigger {
border: 1px solid var(--border-default);
border: 1px solid var(--c-border);
border-radius: var(--radius-md);
padding: 0.5rem 0.75rem;
background: var(--bg-surface);
background: var(--c-surface);
cursor: pointer;
flex: 1;
min-width: 0;
@@ -47,8 +47,8 @@
justify-content: space-between;
padding: 0.3rem 0.45rem;
gap: 0.4rem;
border-bottom: 1px solid var(--border-default);
background: var(--bg-surface);
border-bottom: 1px solid var(--c-border);
background: var(--c-surface);
}
.tabGroup {
@@ -66,7 +66,7 @@
min-width: 0;
min-height: 24px;
max-height: 26px;
border: 1px solid var(--border-default);
border: 1px solid var(--c-border);
border-radius: var(--radius-sm);
background: color-mix(
in srgb,
@@ -185,8 +185,8 @@
/* ── Search / filter row ─────────────────────────── */
.searchRow {
padding: 0.3rem 0.45rem;
border-bottom: 1px solid var(--border-default);
background: var(--bg-surface);
border-bottom: 1px solid var(--c-border);
background: var(--c-surface);
}
.searchInput {
@@ -195,7 +195,7 @@
height: 1.625rem;
padding: 0 0.5rem;
font-size: 0.7rem;
border: 1px solid var(--border-subtle, var(--border-default));
border: 1px solid var(--c-border-subtle, var(--c-border));
border-radius: var(--radius-sm);
background: var(--mantine-color-default-hover);
color: var(--mantine-color-text);
@@ -233,7 +233,7 @@
cursor: pointer;
background: transparent;
border: none;
border-top: 1px solid var(--border-default);
border-top: 1px solid var(--c-border);
text-align: left;
transition: background 0.08s ease;
}
@@ -1,8 +1,8 @@
/* ========== FILE SIDEBAR ========== */
.file-sidebar {
background-color: var(--bg-toolbar);
border-right: 1px solid var(--border-subtle);
background-color: var(--c-bg-raised);
border-right: 1px solid var(--c-border-subtle);
display: flex;
flex-direction: column;
height: 100%;
@@ -24,7 +24,7 @@
/* ---- Native file drag-and-drop ---- */
.file-sidebar[data-file-drag-over] {
outline: 2px dashed var(--mantine-color-blue-6, #3b82f6);
outline: 2px dashed var(--mantine-color-blue-6, var(--p-blue-500));
outline-offset: -4px;
}
@@ -42,20 +42,20 @@
pointer-events: none;
background-color: color-mix(
in srgb,
var(--mantine-color-blue-6, #3b82f6) 12%,
var(--bg-toolbar)
var(--mantine-color-blue-6, var(--p-blue-500)) 12%,
var(--c-bg-raised)
);
}
.file-sidebar-drop-overlay-icon {
color: var(--mantine-color-blue-6, #3b82f6) !important;
color: var(--mantine-color-blue-6, var(--p-blue-500)) !important;
font-size: 28px !important;
}
.file-sidebar-drop-overlay-text {
font-size: 13px;
font-weight: 600;
color: var(--mantine-color-blue-6, #3b82f6);
color: var(--mantine-color-blue-6, var(--p-blue-500));
}
/* ---- Header ---- */
@@ -75,11 +75,11 @@
/* Icons stay left-aligned during animation; overflow:hidden on inner clips text naturally */
.file-sidebar-header:hover {
background-color: var(--hover-bg);
background-color: var(--c-hover);
}
.file-sidebar-menu-icon {
color: var(--text-muted) !important;
color: var(--c-text-subtle) !important;
font-size: 18px !important;
flex-shrink: 0;
}
@@ -129,11 +129,11 @@
}
.file-sidebar-search-row:not(.active):hover {
background-color: var(--hover-bg);
background-color: var(--c-hover);
}
.file-sidebar-search-icon {
color: var(--text-muted) !important;
color: var(--c-text-subtle) !important;
font-size: 18px !important;
flex-shrink: 0;
}
@@ -148,19 +148,19 @@
border: none;
outline: none;
font-size: 14px;
color: var(--text-primary);
color: var(--c-text);
margin-left: 12px;
min-width: 0;
}
.file-sidebar-search-input::placeholder {
color: var(--text-muted);
color: var(--c-text-subtle);
}
.file-sidebar-search-label {
margin-left: 12px;
font-size: 14px;
color: var(--text-secondary);
color: var(--c-text-muted);
}
/* ---- Scrollable content ---- */
@@ -199,7 +199,7 @@
}
.file-sidebar-action-row:hover {
background-color: var(--hover-bg);
background-color: var(--c-hover);
}
.file-sidebar-action-row.disabled {
@@ -212,7 +212,7 @@
}
.file-sidebar-action-icon {
color: var(--text-muted) !important;
color: var(--c-text-subtle) !important;
font-size: 18px !important;
flex-shrink: 0;
display: inline-flex;
@@ -234,7 +234,7 @@
.file-sidebar-action-label {
margin-left: 12px;
font-size: 14px;
color: var(--text-secondary);
color: var(--c-text-muted);
white-space: nowrap;
}
@@ -253,7 +253,7 @@
}
.file-sidebar-cloud-row:not(.disabled):hover {
background-color: var(--hover-bg);
background-color: var(--c-hover);
}
.file-sidebar-cloud-row.disabled {
@@ -320,19 +320,19 @@
border: none;
background: transparent;
cursor: pointer;
color: var(--text-default, var(--color-text-1));
color: var(--text-default, var(--c-text));
border-radius: 0;
font-size: 13px;
font-weight: 600;
text-align: left;
}
.file-sidebar-group-header:hover {
background: var(--hover-bg, var(--color-bg-hover));
background: var(--c-hover, var(--c-hover));
}
.file-sidebar-group-icon {
flex: none;
color: var(--text-muted, var(--color-text-3));
color: var(--c-text-subtle, var(--c-text-subtle));
}
.file-sidebar-group-label {
@@ -347,7 +347,7 @@
flex: none;
font-size: 11px;
font-weight: 500;
color: var(--text-muted, var(--color-text-3));
color: var(--c-text-subtle, var(--c-text-subtle));
}
/* Full-width, flat rows: no inset, no radius, so the hover/selected highlight
@@ -363,7 +363,10 @@
}
/* Hover reads neutral (not the default blue tint); selected stays blue. */
.file-sidebar-group-items .file-sidebar-file-item:hover:not(.selected) {
background-color: var(--color-bg-hover, rgba(120, 120, 120, 0.1));
background-color: var(
--c-hover,
color-mix(in srgb, var(--p-gray-mid) 10%, transparent)
);
}
/* A plain circle where the selected check sits — on hover, and blue when selected. */
.file-sidebar-group-items .file-sidebar-file-checkbox-hover,
@@ -413,7 +416,7 @@
border: none;
background: transparent;
cursor: pointer;
color: var(--color-blue, #2563eb);
color: var(--c-primary, var(--p-blue-600));
font-size: 12px;
font-weight: 500;
border-radius: 6px;
@@ -424,7 +427,10 @@
display: none;
}
.file-sidebar-view-all:hover {
background: var(--color-bg-hover, rgba(120, 120, 120, 0.1));
background: var(
--c-hover,
color-mix(in srgb, var(--p-gray-mid) 10%, transparent)
);
}
.file-sidebar-file-list::-webkit-scrollbar {
@@ -438,11 +444,11 @@
border-radius: 2px;
}
.file-sidebar-file-list::-webkit-scrollbar-thumb:hover {
background: var(--text-muted);
background: var(--c-text-subtle);
}
.file-sidebar-section-divider {
border-top: 1px solid var(--border-subtle);
border-top: 1px solid var(--c-border-subtle);
margin: 10px 14px 6px 14px;
}
@@ -457,7 +463,7 @@
.file-sidebar-section-header {
position: relative;
border-top: 1px solid var(--border-subtle);
border-top: 1px solid var(--c-border-subtle);
padding-top: 10px;
margin-top: 4px;
flex-shrink: 0;
@@ -467,7 +473,7 @@
font-size: 13px;
font-weight: 600;
letter-spacing: 0.02em;
color: var(--text-muted);
color: var(--c-text-subtle);
text-transform: uppercase;
}
@@ -481,7 +487,7 @@
align-items: center;
justify-content: space-between;
font-size: 11px;
color: var(--text-muted);
color: var(--c-text-subtle);
margin-bottom: 4px;
}
.file-sidebar-bulk-add-count {
@@ -490,19 +496,23 @@
.file-sidebar-bulk-add-track {
height: 3px;
border-radius: 999px;
background: color-mix(in srgb, var(--color-blue, #3b82f6) 15%, transparent);
background: color-mix(
in srgb,
var(--c-primary, var(--p-blue-500)) 15%,
transparent
);
overflow: hidden;
}
.file-sidebar-bulk-add-bar {
height: 100%;
border-radius: 999px;
background: var(--color-blue, #3b82f6);
background: var(--c-primary, var(--p-blue-500));
transition: width 0.15s ease-out;
}
.file-sidebar-section-count {
font-size: 11px;
color: var(--text-muted);
color: var(--c-text-subtle);
}
.file-sidebar-section-btn {
@@ -515,7 +525,7 @@
background: transparent;
border-radius: 4px;
cursor: pointer;
color: var(--text-muted);
color: var(--c-text-subtle);
padding: 0;
outline: none;
transition:
@@ -525,13 +535,13 @@
}
.file-sidebar-section-btn:focus-visible {
outline: 2px solid #3b82f6;
outline: 2px solid var(--c-primary);
outline-offset: 1px;
}
.file-sidebar-section-btn:hover {
background-color: var(--hover-bg);
color: var(--text-primary);
background-color: var(--c-hover);
color: var(--c-text);
}
.file-sidebar-section-btn-external {
@@ -576,7 +586,7 @@
align-items: center;
gap: 8px;
padding: 8px 10px;
border-top: 1px solid var(--border-subtle);
border-top: 1px solid var(--c-border-subtle);
flex-shrink: 0;
min-height: 48px;
}
@@ -587,7 +597,7 @@
width: 28px;
height: 28px;
border-radius: 50%;
background-color: var(--mantine-color-blue-6, #3b82f6);
background-color: var(--mantine-color-blue-6, var(--p-blue-500));
color: #fff;
font-size: 12px;
font-weight: 600;
@@ -615,7 +625,7 @@
flex: 1;
font-size: 13px;
font-weight: 500;
color: var(--text-primary);
color: var(--c-text);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@@ -623,11 +633,11 @@
}
.file-sidebar-bottom-bar[role="button"]:hover {
background-color: var(--hover-bg);
background-color: var(--c-hover);
}
.file-sidebar-bottom-bar[role="button"]:focus-visible {
outline: 2px solid #3b82f6;
outline: 2px solid var(--c-primary);
outline-offset: -2px;
}
@@ -638,7 +648,7 @@
width: 28px;
height: 28px;
border-radius: 6px;
color: var(--text-muted);
color: var(--c-text-subtle);
padding: 0;
flex-shrink: 0;
margin-left: auto;
@@ -33,9 +33,11 @@ import { Wordmark } from "@app/components/shared/Wordmark";
import { AppSwitcher } from "@app/components/shared/AppSwitcher";
import type { StirlingFileStub } from "@app/types/fileContext";
import MenuIcon from "@mui/icons-material/Menu";
import SearchIcon from "@mui/icons-material/Search";
import FolderOpenIcon from "@mui/icons-material/FolderOpen";
import FolderSpecialIcon from "@mui/icons-material/FolderSpecial";
import UploadFileIcon from "@mui/icons-material/UploadFile";
import CloseIcon from "@mui/icons-material/Close";
import AddIcon from "@mui/icons-material/Add";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
import SettingsIcon from "@mui/icons-material/Settings";
@@ -99,6 +101,8 @@ export interface FileSidebarProps {
onUploadFiles?: (files: File[]) => void | Promise<void>;
/** Override the Google Drive handler. */
onPickGoogleDriveFiles?: (files: File[]) => void | Promise<void>;
/** Override the Search row click (e.g. focus the /files search input). */
onSearchClick?: () => void;
/** Extra action row inserted under Open-from-computer (e.g. New folder). */
extraAction?: {
icon: React.ReactNode;
@@ -152,6 +156,7 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
toggleIcon,
onUploadFiles,
onPickGoogleDriveFiles,
onSearchClick,
extraAction,
},
ref,
@@ -162,6 +167,9 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
// Classification off (non-SaaS / AI-off) → never show the per-row label chip,
// even if a stub carries labels from an imported PDF; keeps the row plain.
const classificationEnabled = useClassificationEnabled();
const [searchActive, setSearchActive] = useState(false);
const [searchQuery, setSearchQuery] = useState("");
const searchInputRef = useRef<HTMLInputElement>(null);
const nativeFileInputRef = useRef<HTMLInputElement>(null);
// State (not ref) so setting it triggers a re-render - avoids racing addFiles state updates.
const [pendingViewFileId, setPendingViewFileId] = useState<string | null>(
@@ -430,9 +438,14 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
}
}, [pendingViewFileId, state.files.ids, setActiveFileId, navActions]);
// File filtering now lives in the global super search (top bar); the
// sidebar simply lists every stored file.
const filteredFileStubs = allFileStubs;
// Memoized so an unrelated re-render (e.g. a policy-run store tick) keeps a
// stable array identity — avoids re-running the grouping memo + backfill effect.
const filteredFileStubs = useMemo(() => {
const q = searchQuery.trim().toLowerCase();
return q
? allFileStubs.filter((stub) => stub.name.toLowerCase().includes(q))
: allFileStubs;
}, [allFileStubs, searchQuery]);
// SaaS groups by classification label; core returns null → one flat, recency-sorted list.
const fileGroups = useFileSidebarGroups(filteredFileStubs);
@@ -459,6 +472,29 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
[],
);
// Handle search activation
const handleSearchClick = useCallback(() => {
if (onSearchClick) {
onSearchClick();
return;
}
if (collapsed && onToggleCollapse) {
onToggleCollapse();
}
setSearchActive(true);
}, [collapsed, onToggleCollapse, onSearchClick]);
const handleSearchClose = useCallback(() => {
setSearchActive(false);
setSearchQuery("");
}, []);
useEffect(() => {
if (searchActive && searchInputRef.current) {
searchInputRef.current.focus();
}
}, [searchActive]);
// Handle Google Drive
const handleGoogleDriveClick = useCallback(async () => {
if (!isGoogleDriveEnabled) return;
@@ -849,6 +885,56 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
</div>
</Tooltip>
{/* Search row */}
<Tooltip
label={t("fileSidebar.search", "Search")}
position="right"
withinPortal
disabled={!collapsed}
>
<div
className={`file-sidebar-search-row${searchActive && !collapsed ? " active" : ""}`}
onClick={!searchActive ? handleSearchClick : undefined}
role={!searchActive ? "button" : undefined}
tabIndex={!searchActive ? 0 : undefined}
onKeyDown={
!searchActive
? (e) => e.key === "Enter" && handleSearchClick()
: undefined
}
>
{searchActive && !collapsed ? (
<CloseIcon
className="file-sidebar-search-icon"
onClick={(e) => {
e.stopPropagation();
handleSearchClose();
}}
/>
) : (
<SearchIcon className="file-sidebar-search-icon" />
)}
{!collapsed &&
(searchActive ? (
<input
ref={searchInputRef}
className="file-sidebar-search-input sidebar-content-fade"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
placeholder={t(
"fileSidebar.searchPlaceholder",
"Search files...",
)}
onClick={(e) => e.stopPropagation()}
/>
) : (
<span className="file-sidebar-search-label sidebar-content-fade">
{t("fileSidebar.search", "Search")}
</span>
))}
</div>
</Tooltip>
{/* Scrollable content */}
<div className="file-sidebar-scroll">
{/* Hidden native file input - kept outside the !collapsed gate so
@@ -1028,7 +1114,7 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
<div className="file-sidebar-cloud-icon-wrapper">
<GoogleDriveIcon
className="file-sidebar-cloud-icon-gray"
style={{ color: "var(--text-secondary)" }}
style={{ color: "var(--c-text-muted)" }}
/>
{isGoogleDriveEnabled && (
<GoogleDriveIcon
@@ -1059,7 +1145,7 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
aria-label={t("watchedFolders.sidebarTitle", "Watched Folders")}
style={
isWatchedFoldersActive
? { backgroundColor: "var(--active-bg)" }
? { backgroundColor: "var(--c-active)" }
: undefined
}
>
@@ -1111,7 +1197,7 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
{!stubsLoaded ? (
<div className="file-sidebar-loading">
<Loader size="sm" color="var(--text-muted)" />
<Loader size="sm" color="var(--c-text-subtle)" />
</div>
) : filteredFileStubs.length > 0 ? (
<div className="file-sidebar-file-list">
@@ -1196,14 +1282,16 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
)}
</div>
) : (
<div className="file-sidebar-empty">
<p className="file-sidebar-empty-text">
{t("fileSidebar.noFiles", "No files yet")}
</p>
<p className="file-sidebar-empty-hint">
{t("fileSidebar.dropHint", "Open files to get started")}
</p>
</div>
!searchActive && (
<div className="file-sidebar-empty">
<p className="file-sidebar-empty-text">
{t("fileSidebar.noFiles", "No files yet")}
</p>
<p className="file-sidebar-empty-hint">
{t("fileSidebar.dropHint", "Open files to get started")}
</p>
</div>
)
)}
</div>
)}
@@ -17,7 +17,7 @@
background: transparent;
}
.file-sidebar-file-list::-webkit-scrollbar-thumb {
background: rgb(var(--border));
background: var(--c-border);
border-radius: 2px;
}
@@ -64,15 +64,15 @@
}
.file-sidebar-file-item:hover:not(.selected) {
background-color: rgba(59, 130, 246, 0.06);
background-color: color-mix(in srgb, var(--c-primary) 6%, transparent);
}
.file-sidebar-file-item.selected {
background-color: rgba(59, 130, 246, 0.12);
background-color: color-mix(in srgb, var(--c-primary) 12%, transparent);
}
.file-sidebar-file-item.active:not(.selected) {
background-color: rgba(59, 130, 246, 0.06);
background-color: color-mix(in srgb, var(--c-primary) 6%, transparent);
}
/* Icon wrapper */
@@ -96,7 +96,7 @@
width: 20px;
height: 20px;
border-radius: 5px;
border: 1.5px solid var(--border-hover, var(--border-strong));
border: 1.5px solid var(--c-border-strong);
}
.file-sidebar-file-item:hover .file-sidebar-file-checkbox-hover {
@@ -117,7 +117,7 @@
width: 20px;
height: 20px;
border-radius: 5px;
background-color: #3b82f6;
background-color: var(--c-primary);
display: flex;
align-items: center;
justify-content: center;
@@ -125,7 +125,7 @@
}
.file-sidebar-check-svg {
color: white;
color: var(--c-text-on-primary);
flex-shrink: 0;
}
@@ -180,14 +180,14 @@
display: block;
font-size: 13px;
font-weight: 500;
color: var(--text-primary);
color: var(--c-text);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.file-sidebar-file-item.selected .file-sidebar-file-name {
color: #3b82f6;
color: var(--c-accent-fg);
}
.file-sidebar-file-meta-row {
@@ -200,7 +200,7 @@
.file-sidebar-file-meta {
font-size: 11px;
color: var(--text-muted);
color: var(--c-text-subtle);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@@ -212,7 +212,7 @@
align-items: center;
justify-content: center;
flex-shrink: 0;
color: var(--accent-interactive, #6366f1);
color: var(--c-primary);
}
/* ---- Folder membership tags ---- */
@@ -251,7 +251,7 @@
font-size: 10px;
font-weight: 600;
line-height: 1.2;
color: var(--text-secondary);
color: var(--c-text-muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@@ -261,7 +261,7 @@
font-size: 10px;
font-weight: 600;
line-height: 1;
color: var(--text-muted);
color: var(--c-text-subtle);
cursor: default;
flex-shrink: 0;
}
@@ -278,7 +278,7 @@
background: transparent;
border-radius: 4px;
cursor: pointer;
color: var(--text-muted);
color: var(--c-text-subtle);
padding: 0;
opacity: 0;
transition:
@@ -298,48 +298,45 @@
bottom: 0;
z-index: 2;
/* solid base + green tint overlay so content behind doesn't bleed through */
background-color: var(--bg-toolbar);
background-color: var(--c-bg-raised);
background-image: linear-gradient(
rgba(34, 197, 94, 0.1),
rgba(34, 197, 94, 0.1)
color-mix(in srgb, var(--p-green-500) 10%, transparent),
color-mix(in srgb, var(--p-green-500) 10%, transparent)
);
}
.file-sidebar-file-item.viewed .file-sidebar-file-name {
color: #22c55e;
color: var(--p-green-500);
}
.file-sidebar-file-item.viewed .file-sidebar-file-check {
background-color: #22c55e;
background-color: var(--p-green-500);
}
/* viewed takes precedence over selected */
.file-sidebar-file-item.viewed.selected {
background-color: var(--bg-toolbar);
background-color: var(--c-bg-raised);
background-image: linear-gradient(
rgba(34, 197, 94, 0.1),
rgba(34, 197, 94, 0.1)
color-mix(in srgb, var(--p-green-500) 10%, transparent),
color-mix(in srgb, var(--p-green-500) 10%, transparent)
);
}
/* Always show eye for the currently viewed file */
.file-sidebar-file-item.viewed .file-sidebar-eye-btn {
opacity: 1;
color: #22c55e;
color: var(--p-green-500);
}
.file-sidebar-eye-btn:hover {
color: var(--text-primary);
color: var(--c-text);
}
/* Eye open: shown by default */
.file-sidebar-eye-open {
display: block !important;
}
.file-sidebar-eye-closed {
display: none !important;
}
.file-sidebar-eye-closed,
/* On hover over a viewed item: swap to eye-closed */
.file-sidebar-file-item.viewed:hover .file-sidebar-eye-open {
display: none !important;
@@ -360,7 +357,7 @@
background: transparent;
border-radius: 4px;
cursor: pointer;
color: var(--text-muted);
color: var(--c-text-subtle);
padding: 0;
opacity: 0;
transition:
@@ -375,14 +372,14 @@
}
.file-sidebar-kebab-btn:hover {
color: var(--text-primary);
color: var(--c-text);
}
/* ---- Date group headers ---- */
.file-sidebar-date-group-header {
font-size: 11px;
font-weight: 500;
color: var(--text-muted);
color: var(--c-text-subtle);
padding: 0 10px 2px 10px;
margin-top: 8px;
user-select: none;
@@ -409,13 +406,13 @@
.file-sidebar-empty-text {
font-size: 12px;
color: var(--text-muted);
color: var(--c-text-subtle);
margin: 0 0 2px 0;
}
.file-sidebar-empty-hint {
font-size: 11px;
color: var(--text-muted);
color: var(--c-text-subtle);
opacity: 0.7;
margin: 0;
}
@@ -425,8 +422,8 @@
position: fixed;
z-index: 9999;
transform: translateY(-50%);
background: var(--bg-surface, #fff);
border: 1px solid var(--border-subtle);
background: var(--c-surface);
border: 1px solid var(--c-border-subtle);
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
padding: 4px;
@@ -54,8 +54,8 @@ export default function Footer({
<div
style={{
height: "var(--footer-height)",
backgroundColor: "var(--bg-surface)",
borderTop: "1px solid var(--border-subtle)",
backgroundColor: "var(--c-surface)",
borderTop: "1px solid var(--c-border-subtle)",
display: "flex",
flexDirection: "column",
justifyContent: "center",

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