You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/10/16 04:30:12 UTC

(maka) branch main updated: fix(desktop): keep conversations centered with classic scrollbars (#6102)

This is an automated email from the ASF dual-hosted git repository.

Astro-Han pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/main by this push:
     new a7094259de fix(desktop): keep conversations centered with classic scrollbars (#6102)
a7094259de is described below

commit a7094259dea462a53ffc3f236e2755eb14ff7383
Author: jiang1997 <ji...@live.cn>
AuthorDate: Fri Oct 16 12:30:07 2026 +0800

    fix(desktop): keep conversations centered with classic scrollbars (#6102)
    
    Classic scrollbars consume space on the right of the Desktop chat layout, shifting the centered transcript and composer to the left.
    
    Add `scrollbar-gutter: stable both-edges` to keep both centered and their available width stable when the scrollbar appears or disappears. Overlay scrollbars reserve no additional space.
    
    Enable native scrollbars in the Storybook smoke runner and extend the existing EmptyHome scenario to check centering as content grows and shrinks.
    
    Generated-by: Codex
---
 apps/desktop/e2e-budget.json                     |  2 +-
 apps/desktop/e2e/session-workbar.spec.ts         |  4 ++--
 apps/desktop/src/renderer/styles/chat-header.css |  4 ++++
 apps/desktop/src/renderer/styles/workhub.css     |  3 ++-
 apps/desktop/stories/app-shell.stories.tsx       | 25 ++++++++++++++++++++++--
 scripts/storybook-visual-smoke.mjs               | 10 ++++++----
 6 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/apps/desktop/e2e-budget.json b/apps/desktop/e2e-budget.json
index 3f0fa9a9f2..db038c77ed 100644
--- a/apps/desktop/e2e-budget.json
+++ b/apps/desktop/e2e-budget.json
@@ -47,7 +47,7 @@
     },
     "session-workbar.spec.ts": {
       "tests": 5,
-      "electron": "Git changes re-read on native window focus; native PTY ownership survives Session navigation and renderer replacement, while Stop/exit cross preload/main into the terminal view; Side Chat owns a Host fork lifecycle; first send reaches the Host; the composer usage entry opens a workbar whose per-Session visibility survives renderer reload."
+      "electron": "Git changes re-read on native window focus; native PTY ownership survives Session navigation and renderer replacement, while Stop/exit cross preload/main into the terminal view; Side Chat owns a Host fork lifecycle; first send reaches the Host; the Trace launcher opens a workbar whose per-Session visibility survives renderer reload."
     },
     "settings.spec.ts": {
       "tests": 2,
diff --git a/apps/desktop/e2e/session-workbar.spec.ts b/apps/desktop/e2e/session-workbar.spec.ts
index 745e91de99..737aa43dc3 100644
--- a/apps/desktop/e2e/session-workbar.spec.ts
+++ b/apps/desktop/e2e/session-workbar.spec.ts
@@ -60,11 +60,11 @@ test('right workbar visibility belongs to each Session and survives reload', asy
   const first = await createSession(page, 'first workbar owner');
   const panel = page.locator('.maka-session-workbar[data-placement="right"]');
   await page.getByRole('button', { name: '展开任务工作栏' }).click();
+  // Trace remains available through the launcher when a narrow composer hides its usage shortcut.
   await page
     .getByRole('list', { name: '打开工具' })
-    .getByRole('button', { name: /变更.*查看当前 Git 工作区变化/ })
+    .getByRole('button', { name: /追踪.*检查任务调用、工具与耗时记录/ })
     .click();
-  await page.getByRole('button', { name: '打开用量追踪' }).click();
   await expect(page.locator(
     '.maka-session-workbar-panel[data-overlay][data-placement="right"] [data-maka-contract="session-inspector"]',
   )).toBeVisible();
diff --git a/apps/desktop/src/renderer/styles/chat-header.css b/apps/desktop/src/renderer/styles/chat-header.css
index 85fab934fc..ea4e1311ee 100644
--- a/apps/desktop/src/renderer/styles/chat-header.css
+++ b/apps/desktop/src/renderer/styles/chat-header.css
@@ -169,6 +169,10 @@
 
 .maka-chat-layout {
   overscroll-behavior: contain;
+  /* Classic Windows/Linux scrollbars consume inline space. Reserve matching
+     gutters so the transcript and composer stay centered as content grows.
+     Platforms with overlay scrollbars do not reserve either gutter. */
+  scrollbar-gutter: stable both-edges;
 }
 
 .maka-chat-shell {
diff --git a/apps/desktop/src/renderer/styles/workhub.css b/apps/desktop/src/renderer/styles/workhub.css
index 357e828e71..659911032b 100644
--- a/apps/desktop/src/renderer/styles/workhub.css
+++ b/apps/desktop/src/renderer/styles/workhub.css
@@ -111,7 +111,8 @@
   }
   .workHubLive[data-placement='floating'][data-conversation-expanded='false'], body:has(.workHubLive[data-placement='floating'][data-conversation-expanded='false'])::after { border-radius: 20px; }
   .workHubLive[data-placement='floating'][data-conversation-expanded='false']::before { opacity: 1; }
-  .workHubLive[data-placement='floating'] .maka-chat-layout { background: transparent; }
+  /* The floating dock's animated inset owns its edge spacing. */
+  .workHubLive[data-placement='floating'] .maka-chat-layout { background: transparent; scrollbar-gutter: auto; }
   /* Keep the sticky dock bottom-aligned even before the native window has
      grown enough to fit its composer, 32px scroll button and 12px gaps. */
   .workHubLive[data-placement='floating'][data-conversation-expanded='true'] > .workHubWorkspace {
diff --git a/apps/desktop/stories/app-shell.stories.tsx b/apps/desktop/stories/app-shell.stories.tsx
index 6e945c1ba3..151759449a 100644
--- a/apps/desktop/stories/app-shell.stories.tsx
+++ b/apps/desktop/stories/app-shell.stories.tsx
@@ -1712,6 +1712,26 @@ export const EmptyHome: Story = {
     await waitFor(() => expect(emptyComposerSend).toHaveBeenCalledWith('send and clear', undefined));
     await waitFor(() => expect(editor.textContent).toBe(''));
     assertLineBox();
+
+    const layout = canvasElement.querySelector<HTMLElement>('.maka-chat-layout')!;
+    const columns = canvasElement.querySelectorAll<HTMLElement>('.maka-chatContent, .maka-composer-astryx');
+    expect(columns).toHaveLength(2);
+    // Native scrollbars appearing and disappearing must keep both columns centered.
+    for (const messages of [[], longConversation, []]) {
+      await transition({ messages });
+      await waitFor(() => {
+        expect(layout.scrollHeight > layout.clientHeight).toBe(messages.length > 0);
+        if (messages.length > 0) {
+          expect(layout.offsetWidth - layout.clientWidth).toBeGreaterThan(0);
+        }
+        const box = layout.getBoundingClientRect();
+        for (const column of columns) {
+          const content = column.getBoundingClientRect();
+          expect(Math.abs(content.left + content.width / 2 - (box.left + box.width / 2)))
+            .toBeLessThanOrEqual(1);
+        }
+      });
+    }
   },
 };
 
@@ -1720,19 +1740,20 @@ type EmptyComposerState = {
   chatHidden: boolean;
   draftKey: string;
   disabled: boolean;
+  messages: StoredMessage[];
 };
 let setEmptyComposerState: ((next: Partial<EmptyComposerState>) => void) | undefined;
 const emptyComposerSend = fn();
 function EmptyComposerLifecycle() {
   const [state, setState] = useState<EmptyComposerState>({
-    switchingSession: false, chatHidden: false, draftKey: 'session:caret-a', disabled: false,
+    switchingSession: false, chatHidden: false, draftKey: 'session:caret-a', disabled: false, messages: [],
   });
   useEffect(() => {
     emptyComposerSend.mockClear();
     setEmptyComposerState = (next) => setState((current) => ({ ...current, ...next }));
     return () => { setEmptyComposerState = undefined; };
   }, []);
-  return <ComposedShell chat={{ messages: [] }} switchingSession={state.switchingSession}
+  return <ComposedShell chat={{ messages: state.messages }} switchingSession={state.switchingSession}
     chatHidden={state.chatHidden} composer={{ draftKey: state.draftKey, disabled: state.disabled, onSend: emptyComposerSend }} />;
 }
 
diff --git a/scripts/storybook-visual-smoke.mjs b/scripts/storybook-visual-smoke.mjs
index 6a9ef6bddd..b678020eed 100644
--- a/scripts/storybook-visual-smoke.mjs
+++ b/scripts/storybook-visual-smoke.mjs
@@ -549,10 +549,12 @@ async function runCli() {
     );
   }
   const { chromium } = await import('@playwright/test');
-  // Headless Chromium paints no platform scrollbar, so anything a scrollbar
-  // can occlude is inert here and on CI. `SMOKE_HEADED=1` is how you check
-  // those by hand, on the platform whose scrollbar overlays the content.
-  const browser = await chromium.launch({ headless: process.env.SMOKE_HEADED !== '1' });
+  // Keep native scrollbar geometry in headless layout checks. Playwright hides
+  // scrollbars by default, masking the space classic scrollbars consume.
+  const browser = await chromium.launch({
+    headless: process.env.SMOKE_HEADED !== '1',
+    ignoreDefaultArgs: ['--hide-scrollbars'],
+  });
   const server = await startStaticServer(staticDir);
   let problems;
   try {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org