Skip to content

Modern Docker Management, Designed for Everyone

fix: resizing window discards edits in compose editors (#2719)

Kyle Mendellf201e6b662b8
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 116fa5c89..a143749ad 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -163,6 +163,9 @@
"common_all_changes_saved": "All changes saved",
"common_remove_selected_count": "Remove Selected ({count})",
"common_toggle_columns": "Toggle columns",
+ "common_resize_panels": "Resize panels",
+ "common_show_left_panel": "Show left panel",
+ "common_show_right_panel": "Show right panel",
"common_select_all": "Select all",
"common_select_row": "Select row",
"common_showing_of_total": "Showing {shown} of {total} item(s).",
@@ -631,6 +634,11 @@
"container_compose_view_project": "View Project",
"compose_editor_editing_info": "Editing {file} for project {project}",
"compose_editor_viewing_info": "Viewing {file} for project {project}",
+ "compose_editor_toggle_outline": "Toggle outline",
+ "compose_editor_toggle_diff": "Toggle diff",
+ "compose_editor_command_palette": "Command palette",
+ "compose_editor_resize_files_panel": "Resize project files panel",
+ "compose_editor_resize_compose_env": "Resize compose and env editors",
"tabs_compose": "Compose",
"tabs_inspect": "Inspect",
"tabs_environment": "Environment",
diff --git a/frontend/src/lib/components/resizable-split.svelte b/frontend/src/lib/components/resizable-split.svelte
index 3ec95170e..68fc1ddcc 100644
--- a/frontend/src/lib/components/resizable-split.svelte
+++ b/frontend/src/lib/components/resizable-split.svelte
@@ -3,6 +3,7 @@
import { onDestroy, onMount } from 'svelte';
import { PersistedState } from 'runed';
import { DoubleArrowLeftIcon, DoubleArrowRightIcon } from '$lib/icons';
+ import { m } from '$lib/paraglide/messages';
interface Props {
first: Snippet;
@@ -14,6 +15,7 @@
allowCollapse?: boolean;
collapseThreshold?: number;
handleSize?: number;
+ stackBelow?: number;
class?: string;
firstClass?: string;
secondClass?: string;
@@ -34,11 +36,12 @@
allowCollapse = true,
collapseThreshold = 28,
handleSize = 8,
+ stackBelow,
class: className = '',
firstClass = '',
secondClass = '',
handleClass = '',
- ariaLabel = 'Resize panels',
+ ariaLabel,
persistKey,
persistStorage = 'session',
onResizeEnd = () => {}
@@ -47,13 +50,22 @@
let containerRef = $state<HTMLDivElement | null>(null);
let isResizing = $state(false);
let collapsedSide = $state<'first' | 'second' | null>(null);
+ let isStacked = $state(false);
let lastSize = 0;
let persistedState = $state<PersistedState<number | null> | null>(null);
let persistedKey = $state<string | null>(null);
+ let resizeObserver: ResizeObserver | null = null;
let resizeStartX = 0;
let resizeStartWidth = 0;
+ const evaluateStacked = () => {
+ if (stackBelow === undefined) return;
+ if (!containerRef && typeof window === 'undefined') return;
+ const width = containerRef ? containerRef.getBoundingClientRect().width : window.innerWidth;
+ isStacked = width < stackBelow;
+ };
+
const clampSize = (value: number, minValue: number, maxValue: number) => Math.min(Math.max(value, minValue), maxValue);
const getAvailableWidth = () => {
@@ -123,6 +135,19 @@
const handleWindowResize = () => {
if (isResizing) return;
+ evaluateStacked();
+ if (isStacked) return;
+ if (size === null) {
+ ensureInitialSize();
+ if (size === null) return;
+ }
+ applySize(size);
+ };
+
+ const handleContainerResize = () => {
+ if (isResizing) return;
+ evaluateStacked();
+ if (isStacked) return;
if (size === null) {
ensureInitialSize();
if (size === null) return;
@@ -173,14 +198,25 @@
});
$effect(() => {
- if (!containerRef || size === null || isResizing) return;
+ if (!containerRef || size === null || isResizing || isStacked) return;
applySize(size, false);
});
onMount(() => {
- ensureInitialSize();
+ evaluateStacked();
+ if (!isStacked) {
+ ensureInitialSize();
+ }
window.addEventListener('resize', handleWindowResize);
- return () => window.removeEventListener('resize', handleWindowResize);
+ if (stackBelow !== undefined && typeof ResizeObserver !== 'undefined' && containerRef) {
+ resizeObserver = new ResizeObserver(handleContainerResize);
+ resizeObserver.observe(containerRef);
+ }
+ return () => {
+ window.removeEventListener('resize', handleWindowResize);
+ resizeObserver?.disconnect();
+ resizeObserver = null;
+ };
});
onDestroy(() => {
@@ -189,53 +225,55 @@
});
</script>
-<div bind:this={containerRef} class={`flex min-h-0 min-w-0 ${className}`}>
+<div bind:this={containerRef} class={['flex min-h-0 min-w-0', isStacked && 'flex-col gap-4', className]}>
<div
- class={`min-h-0 min-w-0 flex-none overflow-hidden ${firstClass}`}
- style={`width: ${size ?? 0}px;`}
- aria-hidden={collapsedSide === 'first'}
+ class={['min-h-0 min-w-0 overflow-hidden', isStacked ? 'flex-1' : 'flex-none', firstClass]}
+ style={isStacked ? '' : `width: ${size ?? 0}px;`}
+ aria-hidden={!isStacked && collapsedSide === 'first'}
>
- {#if collapsedSide !== 'first'}
+ {#if isStacked || collapsedSide !== 'first'}
{@render first()}
{/if}
</div>
- <div
- role="separator"
- aria-orientation="vertical"
- aria-label={ariaLabel}
- class={`group relative z-20 flex shrink-0 cursor-col-resize items-stretch justify-center overflow-visible ${handleClass}`}
- style={`width: ${handleSize}px;`}
- onpointerdown={startResize}
- >
- <div class="bg-border group-hover:bg-primary/50 my-2 w-0.5 rounded-full transition-colors"></div>
- {#if collapsedSide}
- <button
- class="bg-background border-border text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute inset-0 z-10 m-auto flex size-6 items-center justify-center rounded-full border shadow-sm focus-visible:ring-2 focus-visible:outline-none"
- onclick={(event) => {
- event.stopPropagation();
- restoreCollapsed();
- }}
- onpointerdown={(event) => event.stopPropagation()}
- aria-label={collapsedSide === 'first' ? 'Show left panel' : 'Show right panel'}
- title={collapsedSide === 'first' ? 'Show left panel' : 'Show right panel'}
- type="button"
- >
- {#if collapsedSide === 'first'}
- <DoubleArrowRightIcon class="size-4" />
- {:else}
- <DoubleArrowLeftIcon class="size-4" />
- {/if}
- </button>
- {/if}
- </div>
+ {#if !isStacked}
+ <div
+ role="separator"
+ aria-orientation="vertical"
+ aria-label={ariaLabel ?? m.common_resize_panels()}
+ class={['group relative z-20 flex shrink-0 cursor-col-resize items-stretch justify-center overflow-visible', handleClass]}
+ style={`width: ${handleSize}px;`}
+ onpointerdown={startResize}
+ >
+ <div class="bg-border group-hover:bg-primary/50 my-2 w-0.5 rounded-full transition-colors"></div>
+ {#if collapsedSide}
+ <button
+ class="bg-background border-border text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute inset-0 z-10 m-auto flex size-6 items-center justify-center rounded-full border shadow-sm focus-visible:ring-2 focus-visible:outline-none"
+ onclick={(event) => {
+ event.stopPropagation();
+ restoreCollapsed();
+ }}
+ onpointerdown={(event) => event.stopPropagation()}
+ aria-label={collapsedSide === 'first' ? m.common_show_left_panel() : m.common_show_right_panel()}
+ title={collapsedSide === 'first' ? m.common_show_left_panel() : m.common_show_right_panel()}
+ type="button"
+ >
+ {#if collapsedSide === 'first'}
+ <DoubleArrowRightIcon class="size-4" />
+ {:else}
+ <DoubleArrowLeftIcon class="size-4" />
+ {/if}
+ </button>
+ {/if}
+ </div>
+ {/if}
<div
- class={`min-h-0 min-w-0 flex-1 overflow-hidden ${secondClass}`}
- style={collapsedSide === 'second' ? 'flex: 0 0 0px; width: 0px;' : ''}
- aria-hidden={collapsedSide === 'second'}
+ class={['min-h-0 min-w-0 flex-1 overflow-hidden', secondClass]}
+ style={!isStacked && collapsedSide === 'second' ? 'flex: 0 0 0px; width: 0px;' : ''}
+ aria-hidden={!isStacked && collapsedSide === 'second'}
>
- {#if collapsedSide !== 'second'}
+ {#if isStacked || collapsedSide !== 'second'}
{@render second()}
{/if}
</div>
diff --git a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
index 07cd72faf..c7d8935d9 100644
--- a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
+++ b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
@@ -29,7 +29,6 @@
import ProjectsLogsPanel from '../components/ProjectLogsPanel.svelte';
import ResizableSplit from '$lib/components/resizable-split.svelte';
import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';
- import { IsTablet } from '$lib/hooks/is-tablet.svelte.js';
import { untrack } from 'svelte';
import { projectService } from '$lib/services/project-service';
import { imageService } from '$lib/services/image-service';
@@ -44,7 +43,6 @@
let { data } = $props();
let projectId = $derived(data.projectId);
const queryClient = useQueryClient();
- const isTablet = new IsTablet();
let isLoading = $state({
deploying: false,
@@ -875,10 +873,22 @@
<div class="min-h-0 flex-1">
{#if layoutMode === 'tree'}
- {#if isTablet.current}
- <div class="flex h-full min-h-0 flex-col gap-4">
+ <ResizableSplit
+ class="h-full min-h-0 lg:gap-2"
+ firstClass="flex min-h-0 flex-col"
+ secondClass="flex min-h-0 flex-col"
+ bind:size={treePaneWidth}
+ minSize={minTreePaneWidth}
+ minSecondSize={minEditorPaneWidth}
+ defaultRatio={0.3}
+ stackBelow={1024}
+ ariaLabel={m.compose_editor_resize_files_panel()}
+ persistKey={`arcane.compose.split:${project.id}:tree`}
+ onResizeEnd={persistPrefs}
+ >
+ {#snippet first()}
<Card.Root class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
- <Card.Header icon={FileTextIcon} class="flex-shrink-0 items-center">
+ <Card.Header icon={FileTextIcon} class="shrink-0 items-center">
<Card.Title>
<h2>{m.project_files()}</h2>
</Card.Title>
@@ -933,8 +943,10 @@
</TreeView.Root>
</Card.Content>
</Card.Root>
+ {/snippet}
- <div class="flex min-h-0 flex-1 flex-col">
+ {#snippet second()}
+ <div class="flex h-full min-h-0 flex-1 flex-col">
{#if selectedFile === 'compose'}
<CodePanel
bind:open={composeOpen}
@@ -1019,168 +1031,8 @@
{/if}
{/if}
</div>
- </div>
- {:else}
- <ResizableSplit
- class="h-full min-h-0 lg:gap-2"
- firstClass="flex min-h-0 flex-col"
- secondClass="flex min-h-0 flex-col"
- bind:size={treePaneWidth}
- minSize={minTreePaneWidth}
- minSecondSize={minEditorPaneWidth}
- defaultRatio={0.3}
- ariaLabel="Resize project files panel"
- persistKey={`arcane.compose.split:${project.id}:tree`}
- onResizeEnd={persistPrefs}
- >
- {#snippet first()}
- <Card.Root class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
- <Card.Header icon={FileTextIcon} class="shrink-0 items-center">
- <Card.Title>
- <h2>{m.project_files()}</h2>
- </Card.Title>
- </Card.Header>
- <Card.Content class="min-h-0 flex-1 overflow-auto p-2">
- <TreeView.Root class="min-w-max p-2 whitespace-nowrap">
- <TreeView.File
- name={composeFileName}
- onclick={selectComposeFile}
- class={selectedFile === 'compose' ? 'bg-accent' : ''}
- >
- {#snippet icon()}
- <FileTextIcon class="size-4 text-blue-500" />
- {/snippet}
- </TreeView.File>
-
- <TreeView.File name=".env" onclick={selectEnvFile} class={selectedFile === 'env' ? 'bg-accent' : ''}>
- {#snippet icon()}
- <FileTextIcon class="size-4 text-green-500" />
- {/snippet}
- </TreeView.File>
-
- {#if project?.includeFiles && project.includeFiles.length > 0}
- <TreeView.Folder name={m.project_includes()}>
- {#each project.includeFiles as includeFile (includeFile.relativePath)}
- <TreeView.File
- name={includeFile.relativePath}
- onclick={() => selectIncludeFile(includeFile.relativePath)}
- class={selectedFile === includeFile.relativePath ? 'bg-accent' : ''}
- >
- {#snippet icon()}
- <FileTextIcon class="size-4 text-amber-500" />
- {/snippet}
- </TreeView.File>
- {/each}
- </TreeView.Folder>
- {/if}
-
- {#if project?.directoryFiles && project.directoryFiles.length > 0}
- {#each project.directoryFiles as dirFile (dirFile.relativePath)}
- <TreeView.File
- name={dirFile.relativePath}
- onclick={() => selectDirectoryFile(dirFile.relativePath)}
- class={selectedFile === `dir:${dirFile.relativePath}` ? 'bg-accent' : ''}
- >
- {#snippet icon()}
- <FileTextIcon class="text-muted-foreground size-4" />
- {/snippet}
- </TreeView.File>
- {/each}
- {/if}
- </TreeView.Root>
- </Card.Content>
- </Card.Root>
- {/snippet}
-
- {#snippet second()}
- <div class="flex h-full min-h-0 flex-1 flex-col">
- {#if selectedFile === 'compose'}
- <CodePanel
- bind:open={composeOpen}
- title={composeFileName}
- language="yaml"
- bind:value={$inputs.composeContent.value}
- error={$inputs.composeContent.error ?? undefined}
- readOnly={!canEditCompose}
- bind:hasErrors={composeHasErrors}
- bind:validationReady={composeValidationReady}
- fileId={`project:${projectId}:compose`}
- originalValue={serverComposeContent}
- enableDiff={true}
- editorContext={codeEditorContext}
- />
- {:else if selectedFile === 'env'}
- <CodePanel
- bind:open={envOpen}
- title=".env"
- language="env"
- bind:value={$inputs.envContent.value}
- error={$inputs.envContent.error ?? undefined}
- readOnly={!canEditEnv}
- bind:hasErrors={envHasErrors}
- bind:validationReady={envValidationReady}
- fileId={`project:${projectId}:env`}
- originalValue={serverEnvContent}
- enableDiff={true}
- editorContext={codeEditorContext}
- />
- {:else if selectedFile.startsWith('dir:')}
- {@const dirRelPath = selectedFile.slice(4)}
- {@const dirFile = project?.directoryFiles?.find((f) => f.relativePath === dirRelPath)}
- {#if dirFile}
- {#await getProjectFileResource('directory', dirRelPath)}
- <div class="text-muted-foreground flex h-full min-h-0 items-center justify-center rounded-lg border">
- {m.common_loading()}
- </div>
- {:then loadedFile}
- <CodePanel
- open={true}
- title={loadedFile.relativePath}
- language="yaml"
- value={loadedFile.content ?? ''}
- readOnly={true}
- />
- {:catch error}
- <div
- class="text-destructive flex h-full min-h-0 items-center justify-center rounded-lg border px-4 text-sm"
- >
- {error instanceof Error ? error.message : String(error)}
- </div>
- {/await}
- {/if}
- {:else}
- {@const includeFile = project?.includeFiles?.find((f) => f.relativePath === selectedFile)}
- {#if includeFile}
- {#await getProjectFileResource('include', includeFile.relativePath)}
- <div class="text-muted-foreground flex h-full min-h-0 items-center justify-center rounded-lg border">
- {m.common_loading()}
- </div>
- {:then}
- <CodePanel
- bind:open={includeFilesPanelStates[includeFile.relativePath]}
- title={includeFile.relativePath}
- language="yaml"
- bind:value={includeFilesState[includeFile.relativePath]}
- bind:hasErrors={includeFilesHasErrors[includeFile.relativePath]}
- bind:validationReady={includeFilesValidationReady[includeFile.relativePath]}
- fileId={`project:${projectId}:include:${includeFile.relativePath}`}
- originalValue={serverIncludeFiles[includeFile.relativePath] ?? ''}
- enableDiff={true}
- editorContext={codeEditorContext}
- />
- {:catch error}
- <div
- class="text-destructive flex h-full min-h-0 items-center justify-center rounded-lg border px-4 text-sm"
- >
- {error instanceof Error ? error.message : String(error)}
- </div>
- {/await}
- {/if}
- {/if}
- </div>
- {/snippet}
- </ResizableSplit>
- {/if}
+ {/snippet}
+ </ResizableSplit>
{:else}
<div class="flex h-full min-h-0 flex-col gap-4">
{#if project?.includeFiles && project.includeFiles.length > 0}
@@ -1229,37 +1081,6 @@
</div>
{/await}
{/if}
- {:else if isTablet.current}
- <div class="flex min-h-0 flex-1 flex-col gap-4">
- <CodePanel
- bind:open={composeOpen}
- title={composeFileName}
- language="yaml"
- bind:value={$inputs.composeContent.value}
- error={$inputs.composeContent.error ?? undefined}
- readOnly={!canEditCompose}
- bind:hasErrors={composeHasErrors}
- bind:validationReady={composeValidationReady}
- fileId={`project:${projectId}:compose`}
- originalValue={serverComposeContent}
- enableDiff={true}
- editorContext={codeEditorContext}
- />
- <CodePanel
- bind:open={envOpen}
- title=".env"
- language="env"
- bind:value={$inputs.envContent.value}
- error={$inputs.envContent.error ?? undefined}
- readOnly={!canEditEnv}
- bind:hasErrors={envHasErrors}
- bind:validationReady={envValidationReady}
- fileId={`project:${projectId}:env`}
- originalValue={serverEnvContent}
- enableDiff={true}
- editorContext={codeEditorContext}
- />
- </div>
{:else}
<ResizableSplit
class="min-h-0 flex-1 lg:gap-2"
@@ -1269,7 +1090,8 @@
minSize={minComposePaneWidth}
minSecondSize={minEnvPaneWidth}
defaultRatio={0.6}
- ariaLabel="Resize compose and env editors"
+ stackBelow={1024}
+ ariaLabel={m.compose_editor_resize_compose_env()}
persistKey={`arcane.compose.split:${project.id}:classic`}
onResizeEnd={persistPrefs}
>
diff --git a/frontend/src/routes/(app)/projects/components/CodePanel.svelte b/frontend/src/routes/(app)/projects/components/CodePanel.svelte
index 7708f60f6..92d097ce4 100644
--- a/frontend/src/routes/(app)/projects/components/CodePanel.svelte
+++ b/frontend/src/routes/(app)/projects/components/CodePanel.svelte
@@ -4,6 +4,7 @@
import CodeEditor from '$lib/components/code-editor/editor.svelte';
import { CodeIcon, FileTextIcon, SearchIcon, ArrowsUpDownIcon } from '$lib/icons';
import { IsMobile } from '$lib/hooks/is-mobile.svelte.js';
+ import { m } from '$lib/paraglide/messages';
import type { CodeLanguage, DiagnosticSummary, EditorContext } from '$lib/components/code-editor/analysis/types';
let {
@@ -70,7 +71,7 @@
size="icon"
showLabel={false}
icon={FileTextIcon}
- customLabel="Toggle outline"
+ customLabel={m.compose_editor_toggle_outline()}
onclick={() => (outlineOpen = !outlineOpen)}
/>
{#if enableDiff && originalValue !== undefined}
@@ -80,7 +81,7 @@
size="icon"
showLabel={false}
icon={ArrowsUpDownIcon}
- customLabel="Toggle diff"
+ customLabel={m.compose_editor_toggle_diff()}
onclick={() => (diffOpen = !diffOpen)}
/>
{/if}
@@ -90,19 +91,19 @@
size="icon"
showLabel={false}
icon={SearchIcon}
- customLabel="Command palette"
+ customLabel={m.compose_editor_command_palette()}
onclick={() => (commandPaletteOpen = true)}
/>
</Card.Action>
</Card.Header>
<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}
+ <div class={effectiveAutoHeight ? '' : 'absolute inset-0'}>
<CodeEditor
bind:value
{language}
fontSize="13px"
- autoHeight={true}
+ autoHeight={effectiveAutoHeight}
{readOnly}
bind:hasErrors
bind:validationReady
@@ -115,26 +116,7 @@
bind:diffOpen
bind:commandPaletteOpen
/>
- {:else}
- <div class="absolute inset-0">
- <CodeEditor
- bind:value
- {language}
- fontSize="13px"
- {readOnly}
- bind:hasErrors
- bind:validationReady
- bind:diagnosticSummary
- {fileId}
- {originalValue}
- {enableDiff}
- {editorContext}
- bind:outlineOpen
- bind:diffOpen
- bind:commandPaletteOpen
- />
- </div>
- {/if}
+ </div>
</div>
{#if error}
<p class="text-destructive px-4 py-2 text-xs">{error}</p>