Skip to content

Modern Docker Management, Designed for Everyone

fix: improve Monaco IntelliSense based on compose spec (#1190)

Kyle Mendellb2280163ffbf
diff --git a/frontend/src/lib/components/arcane-button/arcane-button.svelte b/frontend/src/lib/components/arcane-button/arcane-button.svelte
index b303c4e6f..c59e710b8 100644
--- a/frontend/src/lib/components/arcane-button/arcane-button.svelte
+++ b/frontend/src/lib/components/arcane-button/arcane-button.svelte
@@ -1,12 +1,13 @@
<script lang="ts" module>
import type { WithChildren, WithoutChildren } from 'bits-ui';
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
- import type { ArcaneButtonSize, Action } from './variants';
+ import type { ArcaneButtonSize, Action, ArcaneButtonHoverEffect } from './variants';
export type ArcaneButtonPropsWithoutHTML = WithChildren<{
ref?: HTMLElement | null;
action: Action;
size?: ArcaneButtonSize;
+ hoverEffect?: ArcaneButtonHoverEffect;
loading?: boolean;
showLabel?: boolean;
customLabel?: string;
@@ -45,6 +46,7 @@
ref = $bindable(null),
action,
size = 'default',
+ hoverEffect = undefined,
href = undefined,
type = 'button',
loading = false,
@@ -79,7 +81,7 @@
aria-disabled={href ? disabled : undefined}
role={href && disabled ? 'link' : undefined}
tabindex={href && disabled ? -1 : tabindex}
- class={cn('relative', arcaneButtonVariants({ tone: config.tone, size }), className)}
+ class={cn('relative', arcaneButtonVariants({ tone: config.tone, size, hoverEffect }), className)}
aria-label={hasChildren ? undefined : isIconOnlyButton ? displayLabel : undefined}
bind:this={ref}
onclick={async (e: any) => {
diff --git a/frontend/src/lib/components/arcane-table/arcane-table-filter.svelte b/frontend/src/lib/components/arcane-table/arcane-table-filter.svelte
index 62f50ff69..bf5d7c5dd 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table-filter.svelte
+++ b/frontend/src/lib/components/arcane-table/arcane-table-filter.svelte
@@ -35,9 +35,9 @@
{#snippet child({ props })}
<Button
{...props}
- variant="outline"
+ variant="ghost"
size="sm"
- class="h-8 border-dashed"
+ class="border-input hover:bg-card/60 h-8 min-w-24 border border-dashed hover:text-inherit"
data-testid={`facet-${title.toLowerCase()}-trigger`}
>
<FilterIcon />
@@ -65,7 +65,7 @@
{/snippet}
</Popover.Trigger>
<Popover.Content class="w-[240px] p-0" align="start" data-testid={`facet-${title.toLowerCase()}-content`}>
- <Command.Root>
+ <Command.Root class="rounded-none bg-transparent">
<Command.Input placeholder={title} />
<Command.List>
<Command.Empty>{m.common_no_results_found()}</Command.Empty>
diff --git a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
index 718e5da5c..c37c2bc8a 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
+++ b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
@@ -110,6 +110,7 @@
<ArcaneButton
action="remove"
size="sm"
+ hoverEffect="none"
customLabel={m.common_remove_selected_count({ count: selectedIds?.length ?? 0 })}
onclick={() => onRemoveSelected?.(selectedIds!)}
/>
diff --git a/frontend/src/lib/components/arcane-table/arcane-table-view-options.svelte b/frontend/src/lib/components/arcane-table/arcane-table-view-options.svelte
index ec27e2818..5b9e46061 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table-view-options.svelte
+++ b/frontend/src/lib/components/arcane-table/arcane-table-view-options.svelte
@@ -22,9 +22,9 @@
<DropdownMenu.Root>
<DropdownMenu.Trigger
class={buttonVariants({
- variant: 'outline',
+ variant: 'ghost',
size: 'sm',
- class: 'h-8'
+ class: 'border-input hover:bg-card/60 h-8 border hover:text-inherit'
})}
>
<ViewOptionsIcon />
diff --git a/frontend/src/lib/components/arcane-tooltip/arcane-tooltip-content.svelte b/frontend/src/lib/components/arcane-tooltip/arcane-tooltip-content.svelte
index 11e415be4..cf34f0faf 100644
--- a/frontend/src/lib/components/arcane-tooltip/arcane-tooltip-content.svelte
+++ b/frontend/src/lib/components/arcane-tooltip/arcane-tooltip-content.svelte
@@ -2,6 +2,7 @@
import * as Tooltip from '$lib/components/ui/tooltip/index.js';
import * as Popover from '$lib/components/ui/popover/index.js';
import { getArcaneTooltipContext } from './context.svelte.js';
+ import { cn } from '$lib/utils.js';
import type { Snippet } from 'svelte';
let {
@@ -21,7 +22,15 @@
</script>
{#if ctx.isTouch}
- <Popover.Content {side} {align} class={className} {...restProps}>
+ <Popover.Content
+ {side}
+ {align}
+ class={cn(
+ 'bg-popover/90 border-border/50 w-fit max-w-[min(calc(100vw-2rem),320px)] px-3 py-1.5 text-xs text-balance shadow-lg backdrop-blur-md',
+ className
+ )}
+ {...restProps}
+ >
{@render children?.()}
</Popover.Content>
{:else}
diff --git a/frontend/src/lib/components/arcane-tooltip/arcane-tooltip-trigger.svelte b/frontend/src/lib/components/arcane-tooltip/arcane-tooltip-trigger.svelte
index 439a7608a..7352947c3 100644
--- a/frontend/src/lib/components/arcane-tooltip/arcane-tooltip-trigger.svelte
+++ b/frontend/src/lib/components/arcane-tooltip/arcane-tooltip-trigger.svelte
@@ -3,6 +3,7 @@
import * as Popover from '$lib/components/ui/popover/index.js';
import { getArcaneTooltipContext } from './context.svelte.js';
import { Tooltip as TooltipPrimitive } from 'bits-ui';
+ import { cn } from '$lib/utils.js';
type ChildProps = { props: Record<string, unknown> };
@@ -71,39 +72,27 @@
</script>
{#if ctx.isTouch}
- {#if ctx.interactive}
- <Popover.Trigger>
- {#snippet child({ props }: ChildProps)}
- <span
- {...props}
- class={className}
- ontouchstart={handleTouchStart}
- ontouchend={handleTouchEnd}
- ontouchcancel={handleTouchCancel}
- ontouchmove={handleTouchMove}
- onclick={handleClick}
- role="button"
- tabindex="0"
- >
- {#if child}
- {@render child({ props: {} })}
- {:else}
- {@render children?.()}
- {/if}
- </span>
- {/snippet}
- </Popover.Trigger>
- {:else}
- <Popover.Trigger class={className}>
- {#if child}
- {#snippet child({ props }: ChildProps)}
- {@render child({ props })}
- {/snippet}
- {:else}
- {@render children?.()}
- {/if}
- </Popover.Trigger>
- {/if}
+ <Popover.Trigger>
+ {#snippet child({ props }: ChildProps)}
+ <span
+ {...props}
+ class={cn('inline-flex max-w-full min-w-0', className)}
+ ontouchstart={ctx.interactive ? handleTouchStart : undefined}
+ ontouchend={ctx.interactive ? handleTouchEnd : undefined}
+ ontouchcancel={ctx.interactive ? handleTouchCancel : undefined}
+ ontouchmove={ctx.interactive ? handleTouchMove : undefined}
+ onclick={ctx.interactive ? handleClick : undefined}
+ role="button"
+ tabindex="0"
+ >
+ {#if child}
+ {@render child({ props: {} })}
+ {:else}
+ {@render children?.()}
+ {/if}
+ </span>
+ {/snippet}
+ </Popover.Trigger>
{:else}
<Tooltip.Trigger class={className}>
{#if child}
diff --git a/frontend/src/lib/components/monaco-code-editor/editor.svelte b/frontend/src/lib/components/monaco-code-editor/editor.svelte
index 2c6838ff2..58268a0ff 100644
--- a/frontend/src/lib/components/monaco-code-editor/editor.svelte
+++ b/frontend/src/lib/components/monaco-code-editor/editor.svelte
@@ -1,14 +1,9 @@
<script lang="ts">
- import { onDestroy, onMount } from 'svelte';
+ import { onMount, onDestroy } from 'svelte';
import { monaco, initShiki } from './monaco';
import { mode } from 'mode-watcher';
import jsyaml from 'js-yaml';
- function getCurrentTheme(): string {
- const isDark = mode.current === 'dark';
- return isDark ? 'catppuccin-mocha' : 'catppuccin-latte';
- }
-
type CodeLanguage = 'yaml' | 'env';
let {
@@ -16,61 +11,75 @@
language = 'yaml' as CodeLanguage,
readOnly = false,
fontSize = '12px',
- fileUri = undefined
+ fileUri = undefined,
+ autoHeight = false
}: {
value: string;
language: CodeLanguage;
readOnly?: boolean;
fontSize?: string;
fileUri?: string;
+ autoHeight?: boolean;
} = $props();
- let editorElement: HTMLDivElement;
- let editor: monaco.editor.IStandaloneCodeEditor;
+ let editorElement = $state<HTMLDivElement>();
+ let editor = $state.raw<monaco.editor.IStandaloneCodeEditor | null>(null);
+ let model = $state.raw<monaco.editor.ITextModel | null>(null);
+ let ownsModel = $state(false);
let resizeObserver: ResizeObserver | null = null;
- let model: monaco.editor.ITextModel | null = null;
- let ownsModel = false;
+ let changeDisposable: monaco.IDisposable | null = null;
- function validateYaml() {
- if (!model || language !== 'yaml' || readOnly) {
- if (model) monaco.editor.setModelMarkers(model, 'yaml-linter', []);
- return;
- }
+ const langId = $derived(language === 'env' ? 'ini' : language);
+ const theme = $derived(mode.current === 'dark' ? 'catppuccin-mocha' : 'catppuccin-latte');
+
+ const markers = $derived.by(() => {
+ if (!model || language !== 'yaml' || readOnly) return [];
- const content = model.getValue();
try {
- jsyaml.load(content);
- monaco.editor.setModelMarkers(model, 'yaml-linter', []);
+ jsyaml.load(value);
+ return [];
} catch (e: unknown) {
- const markers: monaco.editor.IMarkerData[] = [];
const err = e as { mark?: { line: number; column: number }; reason?: string; message?: string };
const mark = err.mark;
if (mark) {
- markers.push({
- severity: monaco.MarkerSeverity.Error,
- message: err.reason || err.message || 'YAML error',
- startLineNumber: mark.line + 1,
- startColumn: mark.column + 1,
- endLineNumber: mark.line + 1,
- endColumn: model.getLineMaxColumn(mark.line + 1)
- });
- } else {
- markers.push({
+ const lineCount = model.getLineCount();
+ const lineNumber = Math.min(Math.max(1, mark.line + 1), lineCount);
+ const maxColumn = model.getLineMaxColumn(lineNumber);
+
+ return [
+ {
+ severity: monaco.MarkerSeverity.Error,
+ message: err.reason || err.message || 'YAML error',
+ startLineNumber: lineNumber,
+ startColumn: Math.min(mark.column + 1, maxColumn),
+ endLineNumber: lineNumber,
+ endColumn: maxColumn
+ }
+ ];
+ }
+ return [
+ {
severity: monaco.MarkerSeverity.Error,
message: err.message || 'YAML error',
startLineNumber: 1,
startColumn: 1,
endLineNumber: 1,
endColumn: 1
- });
- }
- monaco.editor.setModelMarkers(model, 'yaml-linter', markers);
+ }
+ ];
}
+ });
+
+ function updateHeight() {
+ if (!editor || !editorElement || !autoHeight) return;
+ const contentHeight = editor.getContentHeight();
+ editorElement.style.height = `${contentHeight}px`;
+ editor.layout();
}
onMount(async () => {
- const langId = language === 'env' ? 'ini' : language;
+ if (!editorElement) return;
await initShiki(monaco);
@@ -85,64 +94,99 @@
editor = monaco.editor.create(editorElement, {
model: model,
- automaticLayout: true,
- theme: getCurrentTheme(),
- readOnly: readOnly,
+ automaticLayout: false,
+ theme,
+ readOnly,
fontSize: parseInt(fontSize.replace('px', '')),
minimap: { enabled: false },
scrollBeyondLastLine: false,
fontFamily:
'"Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
- padding: { top: 10, bottom: 10 }
+ padding: { top: 10, bottom: 10 },
+ scrollbar: autoHeight
+ ? {
+ vertical: 'hidden',
+ handleMouseWheel: false
+ }
+ : undefined
});
- model.onDidChangeContent(() => {
+ changeDisposable = model.onDidChangeContent(() => {
value = model?.getValue() || '';
- validateYaml();
});
resizeObserver = new ResizeObserver(() => {
- editor?.layout();
+ requestAnimationFrame(() => {
+ editor?.layout();
+ });
});
resizeObserver.observe(editorElement);
+ });
- // Force layout update
- editor.layout();
- validateYaml();
+ onDestroy(() => {
+ changeDisposable?.dispose();
+ resizeObserver?.disconnect();
+ editor?.dispose();
+ if (ownsModel) model?.dispose();
});
+ // Sync value to model
$effect(() => {
if (model && value !== model.getValue()) {
model.setValue(value);
}
});
+ // Sync language
$effect(() => {
if (model) {
- const langId = language === 'env' ? 'ini' : language;
monaco.editor.setModelLanguage(model, langId);
- validateYaml();
}
});
+ // Sync markers
+ $effect(() => {
+ if (model) {
+ monaco.editor.setModelMarkers(model, 'yaml-linter', markers);
+ }
+ });
+
+ // Sync options and layout
$effect(() => {
if (editor) {
- editor.updateOptions({ readOnly });
- validateYaml();
+ editor.updateOptions({
+ readOnly,
+ theme,
+ fontSize: parseInt(fontSize.replace('px', '')),
+ scrollbar: autoHeight
+ ? {
+ vertical: 'hidden',
+ handleMouseWheel: false
+ }
+ : {
+ vertical: 'auto',
+ handleMouseWheel: true
+ }
+ });
+ editor.layout();
}
});
- // Watch for theme changes and update globally
+ // Auto-height handling
$effect(() => {
- monaco.editor.setTheme(getCurrentTheme());
+ if (editor && autoHeight) {
+ const disposable = editor.onDidContentSizeChange(updateHeight);
+ updateHeight();
+ return () => disposable.dispose();
+ } else if (editorElement) {
+ editorElement.style.height = '';
+ }
});
- onDestroy(() => {
- resizeObserver?.disconnect();
- resizeObserver = null;
- editor?.dispose();
- if (ownsModel) model?.dispose();
+ // Global theme sync
+ $effect(() => {
+ monaco.editor.setTheme(theme);
});
</script>
-<div class="relative h-full min-h-0 w-full overflow-visible" bind:this={editorElement}></div>
+<div class="relative {autoHeight ? '' : 'h-full'} min-h-0 w-full overflow-visible" bind:this={editorElement}></div>
diff --git a/frontend/src/lib/components/monaco-code-editor/monaco.ts b/frontend/src/lib/components/monaco-code-editor/monaco.ts
index ae912379e..656bfb0a9 100644
--- a/frontend/src/lib/components/monaco-code-editor/monaco.ts
+++ b/frontend/src/lib/components/monaco-code-editor/monaco.ts
@@ -51,8 +51,12 @@ export async function initShiki(monacoInstance: typeof monaco) {
return shikiPromise;
}
-// Register YAML language providers
-registerYamlProviders(monaco);
+// Register YAML language providers (only once, survives hot reload)
+const globalWithFlag = globalThis as typeof globalThis & { _yamlProvidersRegistered?: boolean };
+if (!globalWithFlag._yamlProvidersRegistered) {
+ registerYamlProviders(monaco);
+ globalWithFlag._yamlProvidersRegistered = true;
+}
if (typeof window !== 'undefined') {
(window as unknown as { monaco: typeof monaco }).monaco = monaco;
diff --git a/frontend/src/lib/components/monaco-code-editor/yaml-providers.ts b/frontend/src/lib/components/monaco-code-editor/yaml-providers.ts
index 5ed8a6d3e..2933bb186 100644
--- a/frontend/src/lib/components/monaco-code-editor/yaml-providers.ts
+++ b/frontend/src/lib/components/monaco-code-editor/yaml-providers.ts
@@ -1,34 +1,280 @@
import type * as Monaco from 'monaco-editor';
/**
- * Docker Compose schema definitions for auto-completion and validation
+ * Arcane-specific extensions to the Docker Compose spec
*/
-const composeSchema = {
- version: ['3.8', '3.9', '3'],
- services: {
- image: 'Image name (e.g., nginx:latest)',
- container_name: 'Custom container name',
- ports: 'Port mappings (e.g., "8080:80")',
- volumes: 'Volume mounts',
- environment: 'Environment variables',
- networks: 'Networks to attach',
- depends_on: 'Service dependencies',
- command: 'Override default command',
- entrypoint: 'Override entrypoint',
- restart: ['no', 'always', 'on-failure', 'unless-stopped'],
- build: 'Build configuration',
- labels: 'Container labels',
- healthcheck: 'Health check configuration',
- deploy: 'Deploy configuration (Swarm mode)',
- configs: 'Configuration references',
- secrets: 'Secret references'
+const ARCANE_CUSTOM_SCHEMA = {
+ properties: {
+ models: {
+ type: 'object',
+ description: 'Language models that will be used by your application.'
+ }
},
- networks: 'Network definitions',
- volumes: 'Volume definitions',
- configs: 'Config definitions',
- secrets: 'Secret definitions'
+ definitions: {
+ model: {
+ type: 'object',
+ description: 'Language Model for the Compose application.',
+ properties: {
+ name: { type: 'string', description: 'Custom name for this model.' },
+ model: { type: 'string', description: 'Language Model to run.' },
+ context_size: { type: 'integer' },
+ runtime_flags: {
+ type: 'array',
+ items: { type: 'string' },
+ description: 'Raw runtime flags to pass to the inference engine.'
+ }
+ },
+ required: ['model']
+ }
+ }
};
+/**
+ * Schema Manager to handle Docker Compose specification
+ */
+class ComposeSchemaManager {
+ private schema: any = ARCANE_CUSTOM_SCHEMA;
+ private suggestionsMap: Map<string, any[]> = new Map();
+ public readonly ready: Promise<void>;
+
+ constructor() {
+ this.parseSchema();
+ this.ready = this.fetchLatestSchema();
+ }
+
+ private async fetchLatestSchema(retries = 2): Promise<void> {
+ try {
+ const response = await fetch(
+ 'https://raw.githubusercontent.com/compose-spec/compose-go/refs/heads/main/schema/compose-spec.json'
+ );
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
+
+ const latestSchema = await response.json();
+ // Merge latest official schema with our custom fields
+ this.schema = {
+ ...latestSchema,
+ properties: {
+ ...(latestSchema.properties || {}),
+ ...ARCANE_CUSTOM_SCHEMA.properties
+ },
+ definitions: {
+ ...(latestSchema.definitions || {}),
+ ...ARCANE_CUSTOM_SCHEMA.definitions
+ }
+ };
+ // Clear and re-parse
+ this.suggestionsMap.clear();
+ this.parseSchema();
+ } catch (e) {
+ if (retries > 0) {
+ await new Promise((r) => setTimeout(r, 1000));
+ return this.fetchLatestSchema(retries - 1);
+ }
+ console.error('Failed to fetch Docker Compose schema after retries', e);
+ }
+ }
+
+ private parseSchema() {
+ // 1. Parse Root properties
+ const rootSuggestions: any[] = [];
+ if (this.schema.properties) {
+ for (const [key, value] of Object.entries(this.schema.properties)) {
+ const val = value as any;
+ rootSuggestions.push({
+ label: key,
+ kind: 1, // Property
+ documentation: this.getDescription(val),
+ insertText: this.generateInsertText(key, val)
+ });
+ }
+ }
+ this.suggestionsMap.set('root', rootSuggestions);
+
+ // 2. Parse all definitions dynamically
+ if (this.schema.definitions) {
+ for (const [defName, defValue] of Object.entries(this.schema.definitions)) {
+ const def = defValue as any;
+ if (def.properties) {
+ const suggestions: any[] = [];
+ for (const [key, value] of Object.entries(def.properties)) {
+ const val = value as any;
+ suggestions.push({
+ label: key,
+ kind: 1, // Property
+ documentation: this.getDescription(val),
+ insertText: this.generateInsertText(key, val)
+ });
+ }
+ this.suggestionsMap.set(defName, suggestions);
+ }
+ }
+ }
+ }
+
+ private getDescription(val: any, visited = new Set<string>()): string {
+ if (!val) return '';
+ if (val.description) return val.description;
+
+ // Resolve $ref
+ if (val.$ref) {
+ if (visited.has(val.$ref)) return ''; // Circular reference
+ visited.add(val.$ref);
+ // Handle #/definitions/name format and simple #name format
+ const defName = val.$ref.includes('/') ? val.$ref.split('/').pop() : val.$ref.replace('#', '');
+ const def = this.schema.definitions?.[defName];
+ if (def && def.description) return def.description;
+ if (def) return this.getDescription(def, visited);
+ }
+
+ // Resolve oneOf/anyOf
+ const nested = val.oneOf || val.anyOf || [];
+ for (const sub of nested) {
+ const desc = this.getDescription(sub, visited);
+ if (desc) return desc;
+ }
+
+ return '';
+ }
+
+ private generateInsertText(key: string, val: any): string {
+ // Handle array of types or single type
+ const type = Array.isArray(val.type) ? val.type[0] : val.type;
+
+ if (type === 'array') {
+ return `${key}:\n - \${1}`;
+ }
+ // If it has properties, a $ref, or is explicitly an object, treat as nested
+ if (type === 'object' || val.$ref || val.properties || val.oneOf || val.anyOf) {
+ return `${key}:\n \${1}`;
+ }
+ // Default for strings, numbers, booleans
+ return `${key}: `;
+ }
+
+ getSuggestions(context: string) {
+ const suggestions = this.suggestionsMap.get(context);
+ if (suggestions && suggestions.length > 0) return suggestions;
+
+ // Fallback: search for a property named 'context' in all definitions
+ // and return its sub-properties if it has any.
+ // This handles cases like 'build' which are not top-level definitions.
+ if (this.schema.definitions) {
+ for (const def of Object.values(this.schema.definitions) as any[]) {
+ if (def.properties?.[context]) {
+ const prop = def.properties[context];
+ // Try to find properties directly or inside oneOf/anyOf
+ const subProps =
+ prop.properties ||
+ prop.oneOf?.find((p: any) => p.properties)?.properties ||
+ prop.anyOf?.find((p: any) => p.properties)?.properties;
+
+ if (subProps) {
+ return Object.entries(subProps).map(([key, value]) => ({
+ label: key,
+ kind: 1, // Property
+ documentation: (value as any).description || '',
+ insertText: this.generateInsertText(key, value)
+ }));
+ }
+ }
+ }
+ }
+
+ return [];
+ }
+
+ getDocumentation(word: string): string | null {
+ // 1. Check root properties
+ if (this.schema.properties?.[word]) {
+ return `**${word}**\n\n${this.getDescription(this.schema.properties[word])}`;
+ }
+
+ // 2. Check if the word itself is a definition (e.g. "service", "network")
+ if (this.schema.definitions?.[word]) {
+ return `**${word}**\n\n${this.schema.definitions[word].description || ''}`;
+ }
+
+ // 3. Search through all properties of all definitions
+ if (this.schema.definitions) {
+ for (const [defName, def] of Object.entries(this.schema.definitions) as any[]) {
+ // Check direct properties
+ if (def.properties?.[word]) {
+ return `**${word}** (in ${defName})\n\n${this.getDescription(def.properties[word])}`;
+ }
+
+ // Check properties inside oneOf/anyOf/allOf
+ const nested = [...(def.oneOf || []), ...(def.anyOf || []), ...(def.allOf || [])];
+ for (const sub of nested) {
+ if (sub.properties?.[word]) {
+ return `**${word}** (in ${defName})\n\n${this.getDescription(sub.properties[word])}`;
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
+
+const schemaManager = new ComposeSchemaManager();
+
+/**
+ * Detect the current context in the YAML file
+ */
+function getContext(model: Monaco.editor.ITextModel, position: Monaco.Position): string {
+ const lineContent = model.getLineContent(position.lineNumber);
+ const indent = lineContent.match(/^\s*/)?.[0].length || 0;
+
+ if (indent === 0) return 'root';
+
+ let currentIndent = indent;
+ let parentKey = null;
+ let grandParentKey = null;
+
+ for (let i = position.lineNumber - 1; i >= 1; i--) {
+ const line = model.getLineContent(i);
+ const lineIndent = line.match(/^\s*/)?.[0].length || 0;
+ if (lineIndent < currentIndent) {
+ const match = line.match(/^\s*([\w-]+):/);
+ if (match) {
+ if (parentKey === null) {
+ parentKey = match[1];
+ currentIndent = lineIndent;
+ } else {
+ grandParentKey = match[1];
+ break;
+ }
+ }
+ }
+ }
+
+ // Map plural root keys to singular definition names
+ const contextMap: Record<string, string> = {
+ services: 'service',
+ networks: 'network',
+ volumes: 'volume',
+ models: 'model',
+ configs: 'config',
+ secrets: 'secret',
+ // Common nested keys that map to definitions
+ build: 'build',
+ deploy: 'deployment',
+ healthcheck: 'healthcheck',
+ resources: 'resources',
+ limits: 'limits',
+ reservations: 'reservations',
+ restart_policy: 'restart_policy',
+ update_config: 'update_config',
+ rollback_config: 'rollback_config',
+ logging: 'logging'
+ };
+
+ // 1. Check if parent or grandparent is a known root key
+ if (parentKey && contextMap[parentKey]) return contextMap[parentKey];
+ if (grandParentKey && contextMap[grandParentKey]) return contextMap[grandParentKey];
+
+ return 'unknown';
+}
+
/**
* Register YAML completion provider for Docker Compose files
*/
@@ -36,10 +282,7 @@ export function registerYamlCompletionProvider(monaco: typeof Monaco) {
return monaco.languages.registerCompletionItemProvider('yaml', {
triggerCharacters: [' ', ':'],
provideCompletionItems: (model, position) => {
- const lineContent = model.getLineContent(position.lineNumber);
- const lineUntilPosition = lineContent.substring(0, position.column - 1);
const word = model.getWordUntilPosition(position);
-
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
@@ -47,58 +290,14 @@ export function registerYamlCompletionProvider(monaco: typeof Monaco) {
endColumn: word.endColumn
};
- const suggestions: Monaco.languages.CompletionItem[] = [];
-
- // Root level suggestions
- if (!lineUntilPosition.trim() || lineUntilPosition.match(/^\s*$/)) {
- suggestions.push(
- {
- label: 'version',
- kind: monaco.languages.CompletionItemKind.Property,
- documentation: 'Docker Compose file version',
- insertText: 'version: "3.8"',
- range
- },
- {
- label: 'services',
- kind: monaco.languages.CompletionItemKind.Property,
- documentation: 'Service definitions',
- insertText: 'services:\n ${1:service_name}:\n image: ${2:image_name}',
- insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
- range
- },
- {
- label: 'networks',
- kind: monaco.languages.CompletionItemKind.Property,
- documentation: 'Network definitions',
- insertText: 'networks:\n ${1:network_name}:\n driver: ${2:bridge}',
- insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
- range
- },
- {
- label: 'volumes',
- kind: monaco.languages.CompletionItemKind.Property,
- documentation: 'Volume definitions',
- insertText: 'volumes:\n ${1:volume_name}:',
- insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
- range
- }
- );
- }
-
- // Service property suggestions
- if (lineUntilPosition.match(/^\s{2,}\w*$/) && model.getValue().includes('services:')) {
- Object.entries(composeSchema.services).forEach(([key, value]) => {
- const isArray = Array.isArray(value);
- suggestions.push({
- label: key,
- kind: monaco.languages.CompletionItemKind.Property,
- documentation: isArray ? `Options: ${value.join(', ')}` : value,
- insertText: isArray ? `${key}: ${value[0]}` : `${key}: `,
- range
- });
- });
- }
+ const context = getContext(model, position);
+ const suggestions = schemaManager.getSuggestions(context).map((s) => ({
+ ...s,
+ range,
+ insertTextRules: s.insertText.includes('$')
+ ? monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
+ : undefined
+ }));
return { suggestions };
}
@@ -114,26 +313,15 @@ export function registerYamlHoverProvider(monaco: typeof Monaco) {
const word = model.getWordAtPosition(position);
if (!word) return null;
- const docs: Record<string, string> = {
- version: '**Docker Compose version**\n\nRecommended: `3.8` or `3.9`',
- services: '**Services**\n\nDefine containers that make up your application',
- image: '**Image**\n\nDocker image to use (e.g., `nginx:latest`, `postgres:13`)',
- container_name: '**Container Name**\n\nCustom name for the container',
- ports: '**Ports**\n\nPort mappings between host and container\n\nFormat: `"HOST:CONTAINER"`',
- volumes: '**Volumes**\n\nBind mounts or named volumes\n\nFormat: `"./local:/container"`',
- environment: '**Environment Variables**\n\nSet environment variables in the container',
- networks: '**Networks**\n\nNetworks to attach this service to',
- depends_on: '**Dependencies**\n\nServices that must start before this one',
- restart: '**Restart Policy**\n\nOptions: `no`, `always`, `on-failure`, `unless-stopped`',
- build: '**Build**\n\nBuild configuration for custom images',
- command: '**Command**\n\nOverride the default command',
- healthcheck: '**Health Check**\n\nConfigure container health monitoring'
- };
-
- const documentation = docs[word.word];
+ const documentation = schemaManager.getDocumentation(word.word);
if (documentation) {
return {
- range: new monaco.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn),
+ range: new monaco.Range(
+ position.lineNumber,
+ word.startColumn,
+ position.lineNumber,
+ word.endColumn
+ ),
contents: [{ value: documentation }]
};
}
@@ -149,3 +337,4 @@ export function registerYamlHoverProvider(monaco: typeof Monaco) {
export function registerYamlProviders(monaco: typeof Monaco) {
return [registerYamlCompletionProvider(monaco), registerYamlHoverProvider(monaco)];
}
+
diff --git a/frontend/src/lib/components/ui/popover/popover-content.svelte b/frontend/src/lib/components/ui/popover/popover-content.svelte
index bef5d3a3a..7174cfa65 100644
--- a/frontend/src/lib/components/ui/popover/popover-content.svelte
+++ b/frontend/src/lib/components/ui/popover/popover-content.svelte
@@ -22,7 +22,7 @@
{sideOffset}
{align}
class={cn(
- 'bg-popover/20 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--bits-popover-content-transform-origin) rounded-xl border p-4 shadow-md outline-hidden backdrop-blur-2xl backdrop-saturate-150',
+ 'bg-popover/20 text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--bits-popover-content-transform-origin) overflow-hidden rounded-xl border p-4 shadow-md outline-hidden backdrop-blur-2xl backdrop-saturate-150',
className
)}
{...restProps}
diff --git a/frontend/src/lib/components/ui/sidebar/sidebar-provider.svelte b/frontend/src/lib/components/ui/sidebar/sidebar-provider.svelte
index 676852e55..331c7a961 100644
--- a/frontend/src/lib/components/ui/sidebar/sidebar-provider.svelte
+++ b/frontend/src/lib/components/ui/sidebar/sidebar-provider.svelte
@@ -75,7 +75,7 @@
<div
data-slot="sidebar-wrapper"
style="--sidebar-width: {SIDEBAR_WIDTH}; --sidebar-width-icon: {SIDEBAR_WIDTH_ICON}; {style}"
- class={cn('group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full', className)}
+ class={cn('group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex h-dvh w-full', className)}
bind:this={ref}
{...restProps}
>
diff --git a/frontend/src/lib/components/ui/sidebar/sidebar.svelte b/frontend/src/lib/components/ui/sidebar/sidebar.svelte
index ee74bbd4e..5d8ded43d 100644
--- a/frontend/src/lib/components/ui/sidebar/sidebar.svelte
+++ b/frontend/src/lib/components/ui/sidebar/sidebar.svelte
@@ -56,7 +56,7 @@
<div
data-slot="sidebar-container"
class={cn(
- 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) overflow-x-hidden transition-[left,right,width] duration-200 ease-out md:flex',
+ 'fixed inset-y-0 z-10 hidden h-dvh w-(--sidebar-width) overflow-x-hidden transition-[left,right,width] duration-200 ease-out md:flex',
side === 'left'
? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
: 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
diff --git a/frontend/src/lib/components/ui/tooltip/tooltip-trigger.svelte b/frontend/src/lib/components/ui/tooltip/tooltip-trigger.svelte
index 1acdaa47b..5631d1b4c 100644
--- a/frontend/src/lib/components/ui/tooltip/tooltip-trigger.svelte
+++ b/frontend/src/lib/components/ui/tooltip/tooltip-trigger.svelte
@@ -1,5 +1,5 @@
<script lang="ts">
- import { Tooltip as TooltipPrimitive } from "bits-ui";
+ import { Tooltip as TooltipPrimitive } from 'bits-ui';
let { ref = $bindable(null), ...restProps }: TooltipPrimitive.TriggerProps = $props();
</script>
diff --git a/frontend/src/lib/layouts/tabbed-page-layout.svelte b/frontend/src/lib/layouts/tabbed-page-layout.svelte
index 0ad061f3d..2aa52512a 100644
--- a/frontend/src/lib/layouts/tabbed-page-layout.svelte
+++ b/frontend/src/lib/layouts/tabbed-page-layout.svelte
@@ -51,7 +51,7 @@
});
</script>
-<div class={cn('bg-background flex h-dvh min-h-0 flex-col', className)}>
+<div class={cn('bg-background flex h-full min-h-0 flex-col', className)}>
<Tabs.Root value={selectedTab} class="flex min-h-0 w-full flex-1 flex-col">
<div
class="sticky top-0 border-b transition-all duration-300"
@@ -102,7 +102,7 @@
{/if}
<div class="min-h-0 flex-1 overflow-y-auto" bind:this={scrollContainer}>
- <div class="h-full px-1 py-4 pb-2 sm:px-4">
+ <div class="flex h-full min-h-0 flex-col px-1 py-4 pb-2 sm:px-4">
{@render tabContent(selectedTab)}
</div>
</div>
diff --git a/frontend/src/routes/(app)/+layout.svelte b/frontend/src/routes/(app)/+layout.svelte
index c706ed857..c53a248bb 100644
--- a/frontend/src/routes/(app)/+layout.svelte
+++ b/frontend/src/routes/(app)/+layout.svelte
@@ -76,8 +76,8 @@
{:else}
<Sidebar.Provider>
<AppSidebar {versionInformation} {user} />
- <main class="flex-1">
- <section class="p-5">
+ <main class="h-dvh flex-1 overflow-hidden">
+ <section class="h-full p-3 sm:p-5">
{@render children()}
</section>
</main>
diff --git a/frontend/src/routes/(app)/customize/templates/default/+page.svelte b/frontend/src/routes/(app)/customize/templates/default/+page.svelte
index 082d40442..03c1fee44 100644
--- a/frontend/src/routes/(app)/customize/templates/default/+page.svelte
+++ b/frontend/src/routes/(app)/customize/templates/default/+page.svelte
@@ -84,7 +84,7 @@
}
</script>
-<div class="container mx-auto flex h-dvh min-h-0 max-w-full flex-col gap-6 overflow-hidden p-2 pb-10 sm:p-6 sm:pb-10">
+<div class="container mx-auto flex h-full min-h-0 max-w-full flex-col gap-6 overflow-hidden p-2 pb-10 sm:p-6 sm:pb-10">
<div class="space-y-3 sm:space-y-4">
<Button variant="ghost" onclick={() => goto('/customize/templates')} class="w-fit gap-2">
<ArrowLeftIcon class="size-4" />
@@ -113,8 +113,8 @@
</div>
</div>
- <div class="grid min-h-0 flex-1 grid-cols-1 gap-6 lg:grid-cols-5 lg:items-stretch">
- <Card.Root class="flex h-full min-h-0 min-w-0 flex-col lg:col-span-3">
+ <div class="flex min-h-0 flex-1 flex-col gap-6 lg:grid lg:grid-cols-5 lg:grid-rows-1 lg:items-stretch">
+ <Card.Root class="flex min-h-0 min-w-0 flex-1 flex-col lg:col-span-3">
<Card.Header icon={CodeIcon} class="shrink-0">
<div class="flex flex-col space-y-1.5">
<Card.Title>
@@ -142,7 +142,7 @@
{/if}
</Card.Root>
- <Card.Root class="flex h-full min-h-0 min-w-0 flex-col lg:col-span-2">
+ <Card.Root class="flex min-h-0 min-w-0 flex-1 flex-col lg:col-span-2">
<Card.Header icon={VariableIcon} class="shrink-0">
<div class="flex flex-col space-y-1.5">
<Card.Title>
diff --git a/frontend/src/routes/(app)/dashboard/+page.svelte b/frontend/src/routes/(app)/dashboard/+page.svelte
index 259847588..ae5383344 100644
--- a/frontend/src/routes/(app)/dashboard/+page.svelte
+++ b/frontend/src/routes/(app)/dashboard/+page.svelte
@@ -287,7 +287,7 @@
}
</script>
-<div class="flex min-h-[calc(100vh-5rem-2.5rem)] flex-col space-y-8">
+<div class="flex min-h-full flex-col space-y-8">
<div class="flex flex-col gap-4">
<div class="flex items-start justify-between gap-3">
<div class="flex-1 space-y-1">
diff --git a/frontend/src/routes/(app)/environments/[id]/+page.svelte b/frontend/src/routes/(app)/environments/[id]/+page.svelte
index faa7eff81..e26ba0e44 100644
--- a/frontend/src/routes/(app)/environments/[id]/+page.svelte
+++ b/frontend/src/routes/(app)/environments/[id]/+page.svelte
@@ -311,7 +311,13 @@
<Card.Content class="space-y-4 p-4">
<div>
<Label for="env-name" class="text-sm font-medium">{m.common_name()}</Label>
- <Input id="env-name" type="text" bind:value={formName} class="mt-1.5" placeholder={m.environments_name_placeholder()} />
+ <Input
+ id="env-name"
+ type="text"
+ bind:value={formName}
+ class="mt-1.5 w-full"
+ placeholder={m.environments_name_placeholder()}
+ />
</div>
<div class="flex items-center justify-between rounded-lg border p-4">
@@ -420,7 +426,7 @@
<Label for="api-url" class="text-sm font-medium">{m.environments_api_url()}</Label>
{#if environment.id === '0'}
<ArcaneTooltip.Root>
- <ArcaneTooltip.Trigger>
+ <ArcaneTooltip.Trigger class="w-full">
<Input
id="api-url"
type="url"
@@ -440,7 +446,7 @@
id="api-url"
type="url"
bind:value={formApiUrl}
- class="mt-1.5 font-mono"
+ class="mt-1.5 w-full font-mono"
placeholder={m.environments_api_url_placeholder()}
required
/>
diff --git a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
index 390f0b42f..7ad23e89c 100644
--- a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
+++ b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
@@ -334,7 +334,7 @@
<div class="min-h-0 flex-1">
{#if layoutMode === 'tree'}
<div class="flex h-full min-h-0 flex-col gap-4 lg:flex-row">
- <Card.Root class="mb-10 flex min-h-0 w-full flex-1 flex-col overflow-hidden lg:w-fit lg:max-w-xs lg:min-w-48">
+ <Card.Root class="flex min-h-0 w-full flex-1 flex-col overflow-hidden lg:w-fit lg:max-w-xs lg:min-w-48">
<Card.Header icon={FileTextIcon} class="flex-shrink-0 items-center">
<Card.Title>
<h2>{m.project_files()}</h2>
@@ -406,6 +406,7 @@
title={includeFile.relativePath}
language="yaml"
bind:value={includeFilesState[includeFile.relativePath]}
+ autoHeight={true}
/>
{/if}
{/if}
@@ -437,18 +438,17 @@
{#if selectedIncludeTab}
{@const includeFile = project?.includeFiles?.find((f) => f.relativePath === selectedIncludeTab)}
{#if includeFile}
- <div class="flex-1">
- <CodePanel
- bind:open={includeFilesPanelStates[includeFile.relativePath]}
- title={includeFile.relativePath}
- language="yaml"
- bind:value={includeFilesState[includeFile.relativePath]}
- />
- </div>
+ <CodePanel
+ bind:open={includeFilesPanelStates[includeFile.relativePath]}
+ title={includeFile.relativePath}
+ language="yaml"
+ bind:value={includeFilesState[includeFile.relativePath]}
+ autoHeight={true}
+ />
{/if}
{:else}
- <div class="grid min-h-0 flex-1 grid-cols-1 gap-4 lg:grid-cols-5">
- <div class="flex min-h-0 flex-col lg:col-span-3">
+ <div class="flex min-h-0 flex-1 flex-col gap-4 lg:grid lg:grid-cols-5 lg:grid-rows-1">
+ <div class="flex min-h-0 flex-1 flex-col lg:col-span-3">
<CodePanel
bind:open={composeOpen}
title="compose.yaml"
@@ -458,7 +458,7 @@
/>
</div>
- <div class="flex min-h-0 flex-col lg:col-span-2">
+ <div class="flex min-h-0 flex-1 flex-col lg:col-span-2">
<CodePanel
bind:open={envOpen}
title=".env"
diff --git a/frontend/src/routes/(app)/projects/components/CodePanel.svelte b/frontend/src/routes/(app)/projects/components/CodePanel.svelte
index c96ed88e2..5b92b92ae 100644
--- a/frontend/src/routes/(app)/projects/components/CodePanel.svelte
+++ b/frontend/src/routes/(app)/projects/components/CodePanel.svelte
@@ -2,6 +2,7 @@
import * as Card from '$lib/components/ui/card';
import CodeEditor from '$lib/components/monaco-code-editor/editor.svelte';
import { CodeIcon } from '$lib/icons';
+ import { IsMobile } from '$lib/hooks/is-mobile.svelte.js';
type CodeLanguage = 'yaml' | 'env';
@@ -10,25 +11,36 @@
open = $bindable(),
language,
value = $bindable(),
- error
+ error,
+ autoHeight = false
}: {
title: string;
open: boolean;
language: CodeLanguage;
value: string;
error?: string;
+ autoHeight?: boolean;
} = $props();
+
+ const isMobile = new IsMobile();
+ const effectiveAutoHeight = $derived(autoHeight || isMobile.current);
</script>
-<Card.Root class="mb-10 flex h-full min-h-0 flex-col overflow-hidden">
+<Card.Root class="flex {effectiveAutoHeight ? '' : 'flex-1'} min-h-0 flex-col overflow-hidden">
<Card.Header icon={CodeIcon} class="flex-shrink-0 items-center">
<Card.Title>
<h2>{title}</h2>
</Card.Title>
</Card.Header>
- <Card.Content class="relative z-0 flex min-h-0 flex-1 flex-col overflow-visible p-0">
- <div class="relative z-10 min-h-0 w-full min-w-0 flex-1">
- <CodeEditor bind:value {language} fontSize="13px" />
+ <Card.Content class="relative z-0 flex min-h-0 {effectiveAutoHeight ? '' : 'flex-1'} flex-col overflow-visible p-0">
+ <div class="{effectiveAutoHeight ? '' : 'relative flex-1'} min-h-0 w-full min-w-0">
+ {#if effectiveAutoHeight}
+ <CodeEditor bind:value {language} fontSize="13px" autoHeight={true} />
+ {:else}
+ <div class="absolute inset-0">
+ <CodeEditor bind:value {language} fontSize="13px" />
+ </div>
+ {/if}
</div>
{#if error}
<p class="text-destructive px-4 py-2 text-xs">{error}</p>
diff --git a/frontend/src/routes/(app)/projects/new/+page.svelte b/frontend/src/routes/(app)/projects/new/+page.svelte
index 56f609974..f9a344b5d 100644
--- a/frontend/src/routes/(app)/projects/new/+page.svelte
+++ b/frontend/src/routes/(app)/projects/new/+page.svelte
@@ -161,7 +161,7 @@
'data-[disabled]:opacity-50 data-[disabled]:pointer-events-none';
</script>
-<div class="bg-background flex h-dvh min-h-0 flex-col">
+<div class="bg-background flex h-full min-h-0 flex-col">
<div class="sticky top-0 border-b">
<div class="mx-auto flex h-16 max-w-full items-center justify-between gap-4 px-6">
<div class="flex items-center gap-4">
@@ -274,8 +274,8 @@
<div class="flex min-h-0 flex-1 overflow-hidden">
<div class="mx-auto h-full w-full max-w-full min-w-0">
- <div class="flex h-full min-h-0 flex-col gap-4 p-6 pb-10">
- <div class="block flex-shrink-0 sm:hidden">
+ <div class="flex h-full min-h-0 flex-col gap-4">
+ <div class="block flex-shrink-0 pt-4 sm:hidden">
<EditableName
bind:value={$inputs.name.value}
bind:ref={nameInputRef}
@@ -288,11 +288,10 @@
</div>
<form
- class="grid min-h-0 flex-1 grid-cols-1 gap-4 lg:grid-cols-5 lg:items-stretch"
- style="grid-template-rows: 1fr;"
+ class="flex min-h-0 flex-1 flex-col gap-4 lg:grid lg:grid-cols-5 lg:grid-rows-1 lg:items-stretch"
onsubmit={preventDefault(handleSubmit)}
>
- <div class="flex min-h-0 flex-col lg:col-span-3">
+ <div class="flex min-h-0 flex-1 flex-col lg:col-span-3">
<CodePanel
bind:open={composeOpen}
title={m.compose_compose_file_title()}
@@ -302,7 +301,7 @@
/>
</div>
- <div class="flex min-h-0 flex-col lg:col-span-2">
+ <div class="flex min-h-0 flex-1 flex-col lg:col-span-2">
<CodePanel
bind:open={envOpen}
title={m.compose_env_title()}
@@ -376,12 +375,3 @@
onSelect={handleTemplateSelect}
onDownloadSuccess={invalidateAll}
/>
-
-<style>
- :global(.arcane-dd-content [data-arrow]) {
- background: color-mix(in srgb, var(--background), transparent 5%);
- border: 1px solid color-mix(in srgb, var(--primary), transparent 70%);
- box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.12);
- z-index: 10;
- }
-</style>