Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(switchdash): stop the alert action overlapping the alert text (CHOO-1736)

Louis Amaudruza3455b5d7fb4
diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/ui/alert.tsx b/dash/apps/switchdash-desktop/src/renderer/lib/ui/alert.tsx
index 419f16510..64fc41ec2 100644
--- a/dash/apps/switchdash-desktop/src/renderer/lib/ui/alert.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/lib/ui/alert.tsx
@@ -3,7 +3,7 @@ import * as React from 'react';
import { cn } from '@renderer/utils/utils';
const alertVariants = cva(
- "group/alert relative grid w-full gap-0.5 rounded-lg border px-3 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",
+ "group/alert relative grid w-full gap-0.5 rounded-lg border px-3 py-2 text-left text-sm has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 has-data-[slot=alert-action]:grid-cols-[1fr_auto] has-data-[slot=alert-action]:gap-x-2.5 has-[>svg]:has-data-[slot=alert-action]:grid-cols-[auto_1fr_auto] *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",
{
variants: {
variant: {
@@ -61,11 +61,20 @@ function AlertDescription({ className, ...props }: React.ComponentProps<'div'>)
);
}
+/**
+ * Occupies the alert's trailing grid column rather than floating over the text.
+ * Absolute positioning paired with a fixed reserved gutter only holds while the
+ * action is narrower than the gutter; anything wider silently overlaps the
+ * description.
+ */
function AlertAction({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="alert-action"
- className={cn('absolute top-2.5 right-3', className)}
+ className={cn(
+ 'col-start-2 row-span-2 row-start-1 self-center justify-self-end group-has-[>svg]/alert:col-start-3',
+ className
+ )}
{...props}
/>
);
diff --git a/dash/apps/switchdash-desktop/src/renderer/tests/browser/version-drift-notice-layout.test.tsx b/dash/apps/switchdash-desktop/src/renderer/tests/browser/version-drift-notice-layout.test.tsx
new file mode 100644
index 000000000..7da6f9e3d
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/tests/browser/version-drift-notice-layout.test.tsx
@@ -0,0 +1,100 @@
+import { act } from 'react';
+import { createRoot } from 'react-dom/client';
+import { afterEach, describe, expect, it } from 'vitest';
+import { VersionDriftNotice } from '@renderer/features/switch-servers/VersionDriftNotice';
+import '@renderer/index.css';
+
+/**
+ * `AlertAction` used to be positioned absolutely over a fixed `pr-18` gutter,
+ * which only clears the text while the action stays narrower than that gutter.
+ * "Restart to update" is roughly twice as wide, so the drift description ran
+ * underneath the button (CHOO-1736).
+ *
+ * These assertions are on measured geometry rather than class strings: the bug
+ * was invisible at the markup level — every class was present and correct — and
+ * only a real layout reveals the overlap.
+ */
+
+const PANEL_WIDTH = 660;
+
+let container: HTMLDivElement | null = null;
+
+async function renderNotice(deployed: string, expected: string): Promise<HTMLDivElement> {
+ container = document.createElement('div');
+ container.style.width = `${PANEL_WIDTH}px`;
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ await act(async () =>
+ root.render(
+ <VersionDriftNotice
+ drift={{ direction: 'upgrade', deployed, expected }}
+ disabled={false}
+ onRestart={() => {}}
+ />
+ )
+ );
+ return container;
+}
+
+function rectsOverlap(a: DOMRect, b: DOMRect): boolean {
+ return a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
+}
+
+afterEach(() => {
+ container?.remove();
+ container = null;
+});
+
+describe('version drift notice layout', () => {
+ it('keeps the restart button clear of the description text', async () => {
+ const el = await renderNotice('0.11.0', '0.12.1');
+ const button = el.querySelector('button');
+ const description = el.querySelector('[data-slot="alert-description"]');
+
+ expect(button).not.toBeNull();
+ expect(description).not.toBeNull();
+
+ const buttonRect = button!.getBoundingClientRect();
+ const descriptionRect = description!.getBoundingClientRect();
+
+ // Guard the guard: a zero-width button would trivially satisfy the overlap
+ // check while proving nothing.
+ expect(buttonRect.width).toBeGreaterThan(100);
+ expect(descriptionRect.width).toBeGreaterThan(100);
+
+ expect(rectsOverlap(buttonRect, descriptionRect)).toBe(false);
+ });
+
+ it('keeps the title clear of the restart button', async () => {
+ const el = await renderNotice('0.11.0', '0.12.1');
+ const button = el.querySelector('button');
+ const title = el.querySelector('[data-slot="alert-title"]');
+
+ const buttonRect = button!.getBoundingClientRect();
+ const titleRect = title!.getBoundingClientRect();
+
+ expect(rectsOverlap(buttonRect, titleRect)).toBe(false);
+ });
+
+ it('still clears the text when the version strings are long', async () => {
+ const el = await renderNotice('0.11.0-rc.20260806+build.5', '0.12.1-rc.20260807+build.9');
+ const button = el.querySelector('button');
+ const description = el.querySelector('[data-slot="alert-description"]');
+
+ const buttonRect = button!.getBoundingClientRect();
+ const descriptionRect = description!.getBoundingClientRect();
+
+ expect(rectsOverlap(buttonRect, descriptionRect)).toBe(false);
+ });
+
+ it('keeps the notice within its container', async () => {
+ const el = await renderNotice('0.11.0', '0.12.1');
+ const alert = el.querySelector('[data-slot="alert"]');
+ const button = el.querySelector('button');
+
+ const alertRect = alert!.getBoundingClientRect();
+ const buttonRect = button!.getBoundingClientRect();
+
+ expect(buttonRect.right).toBeLessThanOrEqual(alertRect.right + 0.5);
+ });
+});
diff --git a/dash/apps/switchdash-desktop/vitest.config.ts b/dash/apps/switchdash-desktop/vitest.config.ts
index a0cd1e11b..5f53b9fa1 100644
--- a/dash/apps/switchdash-desktop/vitest.config.ts
+++ b/dash/apps/switchdash-desktop/vitest.config.ts
@@ -1,4 +1,5 @@
import { resolve } from 'node:path';
+import tailwindcss from '@tailwindcss/vite';
import { playwright } from '@vitest/browser-playwright';
import { defineConfig } from 'vitest/config';
@@ -96,6 +97,10 @@ export default defineConfig({
entries: ['src/renderer/tests/browser/**/*.test.{ts,tsx}'],
include: ['react/jsx-dev-runtime'],
},
+ // Layout assertions need the real utility classes, not just the class
+ // strings. Only the renderer build carries this plugin, so a browser
+ // test importing index.css would otherwise get no Tailwind output.
+ plugins: [tailwindcss()],
test: {
name: 'browser',
browser: {