Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Single SvelteKit application (not a monorepo).
├── src/
│ ├── lib/
│ │ ├── server/ # Server-only code: auth, db, logging, metrics, feature flags, trino/, storage/
│ │ ├── components/ # Svelte components (shared ones at top level, per-module subfolders)
│ │ ├── components/ # Svelte components: ui/ (generic), app-wide at top level and layout/, per-module subfolders
│ │ ├── client/ # Client-only utilities
│ │ ├── stores/ # Svelte stores (*.svelte.ts)
│ │ ├── storage/ # Client-side storage module logic
Expand Down Expand Up @@ -140,6 +140,16 @@ Environment variables are parsed with zod at startup using the helpers in `src/l

Document new variables in `README.md` and `.env.example`; don't read `env` ad hoc.

### Component Layers

`src/lib/components/` is split by what a component depends on. Each layer may only use the layers above it:

1. **`ui/`** — generic building blocks (`Modal`, `TooltipTrigger`, `TabBar`, ...). Data comes in through props, results go out through callbacks or `bind:`. They may import Svelte, icons, Paraglide messages, `$lib/types` and other `ui/` components, nothing else (enforced by ESLint).
2. **Top level and `layout/`** — app-wide components that know the app (stores, routes, session), e.g. `ErrorPanel`, `ToastHost`, the header and sidebar.
3. **`<module>/`** — feature components. Pieces shared only within one module go into `<module>/shared/`; move them to `ui/` once a second module needs them and they have no module dependencies.

Before writing a new component, check DaisyUI and the existing `ui/` components.

### Code Style & Best Practices

- Run `npm run format`.
Expand Down Expand Up @@ -213,7 +223,7 @@ pre-commit run --all-files # All of the above plus markdownlint, yamllint, she

Most conventions in this file are checked automatically; fix violations instead of disabling rules.

- **ESLint** (`eslint.config.js`): no server imports from client code (`src/lib/client`, `stores`, `storage`, `editor`, `types`) and vice versa, file naming (PascalCase components, stores as `*.svelte.ts`), file size limits (`max-lines`), no `<dialog>` outside `Modal.svelte`, a subset of hard-coded colour classes (`bg-white`, `text-gray-*`, ...), no `console` in server code.
- **ESLint** (`eslint.config.js`): no server imports from client code (`src/lib/client`, `stores`, `storage`, `editor`, `types`) and vice versa, file naming (PascalCase components, stores as `*.svelte.ts`), file size limits (`max-lines`), no `<dialog>` outside `ui/Modal.svelte`, `ui/` components importing app code, a subset of hard-coded colour classes (`bg-white`, `text-gray-*`, ...), no `console` in server code.
- **Architecture tests** (`npm run test:arch`, `src/architecture-tests/`): no circular dependencies in `src/lib` and `src/routes`, i18n key parity and no unused message keys, no static English `aria-label`, no native date inputs, `<img>` with `alt`, no clickable `<div>`/`<span>`, no low-opacity `text-base-content` for text (use `text-muted`). `npm run test:arch:report` additionally writes dependency/metrics reports to `reports/`.

When you add a new architectural rule, prefer an ESLint rule; otherwise add a `.spec.ts` in `src/architecture-tests/` following the existing patterns.
Expand Down
62 changes: 62 additions & 0 deletions e2e/storage/context-menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,68 @@ test.describe('Storage S3 — Context Menu', () => {
}
});

test('a right-click elsewhere replaces the open context menu', async ({ page }, testInfo) => {
const credentials = requireGarageCredentials();
const client = createS3Client(credentials);
const prefix = uniquePrefix(testInfo, 'ctx-replace');
const cleanupKeys = [`${prefix}first.txt`, `${prefix}second.txt`];

try {
for (const key of cleanupKeys) await putTextObject(client, credentials.bucket, key, 'x');

await connectAndOpenPrefix(page, credentials, prefix);

const menu = page.getByRole('menu');
await rowByName(page, 'first.txt').click({ button: 'right' });
await expect(menu).toBeVisible();

// Another row of the same list moves the menu and keeps that row selected.
await rowByName(page, 'second.txt').click({ button: 'right', position: { x: 10, y: 10 } });
await expect(menu).toHaveCount(1);
await expect(menu.getByRole('menuitem', { name: 'Preview' })).toBeVisible();
await expect(page.getByText('1 selected')).toBeVisible();

// Another component's target opens its own menu instead.
const sidebar = page.getByRole('navigation', { name: 'Buckets' });
await sidebar.getByText(credentials.bucket).click({ button: 'right' });
await expect(menu).toHaveCount(1);
await expect(menu.getByRole('menuitem', { name: 'Details' })).toBeVisible();
} finally {
await deleteKnownKeys(client, credentials.bucket, cleanupKeys);
}
});

test('unpins a pinned location from its sidebar menu', async ({ page }, testInfo) => {
const credentials = requireGarageCredentials();
const client = createS3Client(credentials);
const prefix = uniquePrefix(testInfo, 'ctx-unpin');
const cleanupKeys = [`${prefix}file.txt`];

try {
await putTextObject(client, credentials.bucket, cleanupKeys[0], 'x');
await connectAndOpenPrefix(page, credentials, prefix);

const breadcrumb = page.getByRole('navigation', { name: 'Breadcrumb' });
await breadcrumb.getByText(credentials.bucket).hover();
await page
.getByRole('button', { name: 'Pin this location' })
.filter({ visible: true })
.first()
.click();
const sidebar = page.getByRole('navigation', { name: 'Buckets' });
await expect(sidebar.getByText('Pinned Access')).toBeVisible();

await sidebar.getByRole('button', { name: 'More options' }).click({ force: true });
const menu = page.getByRole('menu', { name: 'Actions' });
await menu.getByRole('menuitem', { name: 'Unpin' }).click();

await expect(menu).toHaveCount(0);
await expect(sidebar.getByText('Pinned Access')).toHaveCount(0);
} finally {
await deleteKnownKeys(client, credentials.bucket, cleanupKeys);
}
});

test('deletes a single file via context menu', async ({ page }, testInfo) => {
const credentials = requireGarageCredentials();
const client = createS3Client(credentials);
Expand Down
46 changes: 46 additions & 0 deletions e2e/storage/details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,52 @@ test.describe('Storage S3 — Details Modal', () => {
}
});

test('treemap context menu works on top of the details modal', async ({
page,
context,
browserName
}, testInfo) => {
const credentials = requireGarageCredentials();
const client = createS3Client(credentials);
const prefix = uniquePrefix(testInfo, 'details-treemap');
const cleanupKeys = [`${prefix}subdir/big.txt`];

try {
await putTextObject(client, credentials.bucket, cleanupKeys[0], 'x'.repeat(2048));
// Firefox cannot grant clipboard permissions; the copy itself still runs there.
if (browserName === 'chromium') {
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
}

await connectAndOpenPrefix(page, credentials, prefix);
await rowByName(page, 'subdir').click({ button: 'right' });
await page.getByRole('menuitem', { name: 'Details' }).click();

const modal = modalBox(page);
await modal.getByRole('button', { name: 'Calculate directory size' }).click();
await modal.getByRole('tab', { name: 'Size composition' }).click();
const leaf = modal.getByRole('treeitem', { name: /big\.txt/ });

// Escape closes only the menu, not the modal underneath.
const menu = page.getByRole('menu');
await leaf.click({ button: 'right' });
await expect(menu).toBeVisible();
await page.keyboard.press('Escape');
await expect(menu).toHaveCount(0);
await expect(modal).toBeVisible();

await leaf.click({ button: 'right' });
await menu.getByRole('menuitem', { name: 'Copy file name' }).click();
await expect(menu).toHaveCount(0);
await expect(modal).toBeVisible();
if (browserName === 'chromium') {
expect(await page.evaluate(() => navigator.clipboard.readText())).toBe('big.txt');
}
} finally {
await deleteKnownKeys(client, credentials.bucket, cleanupKeys);
}
});

test('explains a failed size calculation', async ({ page }, testInfo) => {
const credentials = requireGarageCredentials();
const client = createS3Client(credentials);
Expand Down
31 changes: 30 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,38 @@ export default defineConfig(
}
},
{
files: ['src/lib/components/Modal.svelte'],
files: ['src/lib/components/ui/Modal.svelte'],
rules: { 'svelte/no-restricted-html-elements': 'off' }
},
{
// Generic building blocks: everything comes in through props, so they must not depend on app
// state, routing or feature modules (see "Component Layers" in AGENTS.md).
files: ['src/lib/components/ui/**/*.{svelte,ts}'],
// Specs may load the global stylesheet to test against the real styles.
ignores: ['src/lib/components/ui/**/*.spec.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['$lib/*', '!$lib/paraglide', '!$lib/types', '!$lib/components'],
message: 'ui/ components may only import Paraglide messages, shared types and ui/.'
},
{
group: ['$lib/components/*', '!$lib/components/ui'],
message: 'ui/ components must not import app or feature components.'
},
{
group: ['$app/*'],
message: 'ui/ components must not depend on SvelteKit app state.'
},
{ group: ['../*'], message: 'ui/ components must not import from outside ui/.' }
]
}
]
}
},
{
files: [
'src/lib/client/**/*.ts',
Expand Down
1 change: 0 additions & 1 deletion src/architecture-tests/ui-pattern-enforcement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('UI Pattern Enforcement', () => {
const KNOWN_VIOLATION_PATHS = [
'src/lib/components/catalog/CatalogTree.svelte',
'src/lib/components/storage/explorer/OperationsButton.svelte',
'src/lib/components/storage/shared/FloatingMenu.svelte',
'src/lib/components/trino/StatementResult.svelte'
];

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/dashboard/AddBookmarkModal.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { untrack } from 'svelte';
import Modal from '$lib/components/Modal.svelte';
import Modal from '$lib/components/ui/Modal.svelte';
import { getProduct, PRODUCTS, type Product } from '$lib/dashboard/products';
import ProductIcon from './ProductIcon.svelte';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/layout/SessionExpiredModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { resolve } from '$app/paths';
import IconLogin from 'virtual:icons/material-symbols/login';
import * as m from '$lib/paraglide/messages.js';
import Modal from '$lib/components/Modal.svelte';
import Modal from '$lib/components/ui/Modal.svelte';
import { checkSession, sessionState } from '$lib/client/session.svelte';

const SESSION_CHECK_INTERVAL_MS = 60_000;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/layout/sidebar/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import ProductIcon from '$lib/components/dashboard/ProductIcon.svelte';
import type { BookmarkLink } from '$lib/dashboard/types';
import stackableLogo from '$lib/logos/stackable.svg?enhanced';
import TooltipTrigger from '$lib/components/TooltipTrigger.svelte';
import TooltipTrigger from '$lib/components/ui/TooltipTrigger.svelte';

let {
collapsed = $bindable(false),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/storage/StorageSearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { goto } from '$app/navigation';
import { onDestroy } from 'svelte';
import { resolve } from '$app/paths';
import Modal from '$lib/components/Modal.svelte';
import Modal from '$lib/components/ui/Modal.svelte';
import StorageSearchForm from '$lib/components/storage/StorageSearchForm.svelte';
import StorageSearchHistory from '$lib/components/storage/StorageSearchHistory.svelte';
import StorageSearchResults from '$lib/components/storage/StorageSearchResults.svelte';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/storage/StorageSearchHistory.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import * as m from '$lib/paraglide/messages.js';
import Modal from '$lib/components/Modal.svelte';
import Modal from '$lib/components/ui/Modal.svelte';
import StorageSearchHistoryEntry from '$lib/components/storage/StorageSearchHistoryEntry.svelte';
import type { RecentSearchEntry } from '$lib/storage/types.js';
import IconDelete from 'virtual:icons/material-symbols/delete';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import * as m from '$lib/paraglide/messages.js';
import TooltipTrigger from '$lib/components/TooltipTrigger.svelte';
import TooltipTrigger from '$lib/components/ui/TooltipTrigger.svelte';
import type { RecentSearchEntry } from '$lib/storage/types.js';
import IconExpandLess from 'virtual:icons/material-symbols/expand-less';
import IconExpandMore from 'virtual:icons/material-symbols/expand-more';
Expand Down
112 changes: 0 additions & 112 deletions src/lib/components/storage/explorer/ContextMenu.svelte

This file was deleted.

3 changes: 1 addition & 2 deletions src/lib/components/storage/explorer/FileExplorer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { getTabsState } from '$lib/storage/context.js';
import { collectDroppedFiles } from '$lib/storage/file-collection.js';
import { storageTransferEnabled } from '$lib/client/feature-flags.js';
import type { ContextMenuAction } from '$lib/storage/types.js';
import type { ActionName } from '$lib/storage/types.js';
import IconVisibility from 'virtual:icons/material-symbols/visibility';
import IconDownload from 'virtual:icons/material-symbols/download';
Expand All @@ -27,7 +26,7 @@
import StorageBreadcrumb from './StorageBreadcrumb.svelte';
import TabBar from './TabBar.svelte';
import ObjectTable from './ObjectTable.svelte';
import ContextMenu from './ContextMenu.svelte';
import ContextMenu, { type ContextMenuAction } from '$lib/components/ui/ContextMenu.svelte';
import Pagination from '$lib/components/Pagination.svelte';

const storage = getStorageState();
Expand Down
5 changes: 2 additions & 3 deletions src/lib/components/storage/explorer/StorageBreadcrumb.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
import { storageTransferEnabled } from '$lib/client/feature-flags.js';
import { parseStorageDrop, canStorageDrop } from '$lib/storage/drag-handlers.js';
import OperationsButton from './OperationsButton.svelte';
import ContextMenu from './ContextMenu.svelte';
import TooltipTrigger from '$lib/components/TooltipTrigger.svelte';
import type { ContextMenuAction } from '$lib/storage/types.js';
import ContextMenu, { type ContextMenuAction } from '$lib/components/ui/ContextMenu.svelte';
import TooltipTrigger from '$lib/components/ui/TooltipTrigger.svelte';

const storage = getStorageState();
const uid = $props.id();
Expand Down
Loading