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

voidmatcha pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new 258d27b6d9 [ZEPPELIN-6778] Keep Send visible and preserve focus in the 
Assistant composer
258d27b6d9 is described below

commit 258d27b6d95e544bad67e02df82d899e944a34bb
Author: Minho Jang <[email protected]>
AuthorDate: Sat Nov 28 19:33:21 2026 +0900

    [ZEPPELIN-6778] Keep Send visible and preserve focus in the Assistant 
composer
    
    ### What is this PR for?
    
    On short viewports, a multiline question can push **Send** outside the 
visible Assistant sidebar. The textarea now scrolls within the available space 
so **Send** stays visible and keyboard-accessible.
    
    Submitting with **Send** or Enter returns focus to the question input. If 
the user moves focus back to the notebook, streaming updates and answer 
completion leave it there. The input remains read-only while a response is in 
progress, as before.
    
    ### What type of PR is it?
    Improvement
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-6778
    
    ### How should this be tested?
    With Zeppelin running, set `PLAYWRIGHT_BASE_URL` to the server address. 
From `zeppelin-web-angular`, run:
    
    ```bash
    npm run e2e -- e2e/tests/notebook/assistant/assistant-conversation.spec.ts 
--project=chromium -g 'keeps Send reachable on a short viewport'
    ```
    
    The scenario uses a controlled Assistant stream. It checks that the 
textarea scrolls and **Send** stays fully inside the sidebar and reachable by 
Tab, that both submission paths return focus to the input, and that streaming 
and completion do not steal focus from the notebook.
    
    ### Questions:
    
    * Does the license files need to update? No.
    * Is there breaking changes for older versions? No.
    * Does this needs documentation? No.
    
    Closes #5620 from miinhho/ZEPPELIN-6778-assistant-composer-visibility-focus.
    
    Signed-off-by: YONGJAE LEE <[email protected]>
---
 .../e2e/models/assistant-conversation-page.util.ts | 23 +++++--
 .../assistant/assistant-conversation.spec.ts       | 80 ++++++++++++++++++++++
 .../entities/assistant/ui/AssistantComposer.css.ts |  6 ++
 .../assistant/ui/AssistantComposer.spec.tsx        | 14 +++-
 .../entities/assistant/ui/AssistantComposer.tsx    | 11 ++-
 .../ui/AssistantConversationPanel.css.ts           |  4 +-
 6 files changed, 124 insertions(+), 14 deletions(-)

diff --git 
a/zeppelin-web-angular/e2e/models/assistant-conversation-page.util.ts 
b/zeppelin-web-angular/e2e/models/assistant-conversation-page.util.ts
index a349400d9f..99e20c45fa 100644
--- a/zeppelin-web-angular/e2e/models/assistant-conversation-page.util.ts
+++ b/zeppelin-web-angular/e2e/models/assistant-conversation-page.util.ts
@@ -110,7 +110,12 @@ export class AssistantConversationWireMock {
   readonly restRequests: Array<{ method: string; path: string; body?: unknown 
}> = [];
   private noteId?: string;
   private readonly conversations = new Map<string, { metadata: 
ConversationMetadata; messages: RawMessage[] }>();
-  private readonly runs: Array<{ socket: WebSocketRoute; request: SendMessage; 
completed: boolean }> = [];
+  private readonly runs: Array<{
+    socket: WebSocketRoute;
+    request: SendMessage;
+    completed: boolean;
+    streamedContent: string;
+  }> = [];
   private createdCount = 0;
 
   static async install(page: Page): Promise<AssistantConversationWireMock> {
@@ -146,13 +151,20 @@ export class AssistantConversationWireMock {
     ]);
   }
 
+  appendRunDelta(index: number, delta: string): void {
+    const run = this.runs[index];
+    if (!run || run.completed) throw new Error(`No pending assistant run at 
index ${index}`);
+    run.streamedContent += delta;
+    this.emit(run.socket, run.request.conversationId, 'message.delta', { 
messageId: `run-${index}-answer`, delta });
+  }
+
   // No timer can complete a stream: the test releases it after observing the 
busy DOM.
   completeRun(index: number): void {
     const run = this.runs[index];
     if (!run || run.completed) throw new Error(`No pending assistant run at 
index ${index}`);
     run.completed = true;
     const content = [
-      STREAM_PREFIX,
+      run.streamedContent,
       run.request.conversationId === 'c2'
         ? '| Region | Summary |\n| --- | --- |\n| Europe | Strongest regional 
growth |'
         : '| Region | Revenue |\n| --- | --- |\n| Europe | 118 |'
@@ -240,15 +252,12 @@ export class AssistantConversationWireMock {
     const request = { noteId: data.noteId, conversationId: 
data.conversationId, content: data.content };
     const index = this.runs.length;
     this.sent.push(request);
-    this.runs.push({ socket, request, completed: false });
+    this.runs.push({ socket, request, completed: false, streamedContent: '' });
     this.conversations
       .get(request.conversationId)!
       .messages.push(message(`run-${index}-user`, 'user', request.content));
     this.emit(socket, request.conversationId, 'run.started', { runId: 
`run-${index}`, createdAt: CREATED_AT });
-    this.emit(socket, request.conversationId, 'message.delta', {
-      messageId: `run-${index}-answer`,
-      delta: STREAM_PREFIX
-    });
+    this.appendRunDelta(index, STREAM_PREFIX);
   }
 
   private emit(socket: WebSocketRoute, conversationId: string, type: string, 
payload: unknown): void {
diff --git 
a/zeppelin-web-angular/e2e/tests/notebook/assistant/assistant-conversation.spec.ts
 
b/zeppelin-web-angular/e2e/tests/notebook/assistant/assistant-conversation.spec.ts
index aeb6811b53..55cfcddd26 100644
--- 
a/zeppelin-web-angular/e2e/tests/notebook/assistant/assistant-conversation.spec.ts
+++ 
b/zeppelin-web-angular/e2e/tests/notebook/assistant/assistant-conversation.spec.ts
@@ -92,6 +92,86 @@ test.describe('Notebook AI Assistant conversations over REST 
and WebSocket', ()
     await expect(answer.getByRole('table')).toBeVisible();
   });
 
+  test('keeps Send reachable on a short viewport and only refocuses the 
composer on submission', async ({ page }) => {
+    const viewport = { width: 1000, height: 300 };
+    await page.setViewportSize(viewport);
+    const { panel, question, sendButton, messages } = assistant;
+    const conversation = panel.getByRole('region', { name: 'Assistant 
conversation panel' });
+    const initialLines = Array.from({ length: 6 }, (_, index) => `Question 
line ${index + 1}`).join('\n');
+    const lastLine = 'Question line 7';
+    const multilineQuestion = `${initialLines}\n${lastLine}`;
+
+    await question.fill(initialLines);
+    await question.press('Shift+Enter');
+    await page.keyboard.insertText(lastLine);
+    await expect(question).toHaveValue(multilineQuestion);
+    await expect
+      .poll(() =>
+        question.evaluate(element => ({
+          overflowing: element.clientHeight > 0 && element.scrollHeight > 
element.clientHeight,
+          overflowY: getComputedStyle(element).overflowY
+        }))
+      )
+      .toEqual({ overflowing: true, overflowY: 'auto' });
+    await expect.poll(() => question.evaluate(element => 
element.scrollTop)).toBeGreaterThan(0);
+
+    // Playwright's visibility check alone also passes for a button clipped by 
an overflow:hidden ancestor.
+    await expect
+      .poll(
+        async () => {
+          const [button, sidebar, section] = await Promise.all([
+            sendButton.boundingBox(),
+            panel.boundingBox(),
+            conversation.boundingBox()
+          ]);
+          if (!button || !sidebar || !section) return false;
+          return [{ x: 0, y: 0, ...viewport }, sidebar, section].every(
+            bounds =>
+              button.x >= bounds.x &&
+              button.y >= bounds.y &&
+              button.x + button.width <= bounds.x + bounds.width &&
+              button.y + button.height <= bounds.y + bounds.height
+          );
+        },
+        { message: 'Send fits fully within the viewport and both clipped 
Assistant containers' }
+      )
+      .toBe(true);
+
+    await page.keyboard.press('Tab');
+    await expect(sendButton).toBeFocused();
+    await sendButton.click();
+    await expect(question).toBeFocused();
+    const firstSend = { noteId, conversationId: 'c-created-1', content: 
multilineQuestion };
+    await expect.poll(() => wire.sent).toEqual([firstSend]);
+    await expect(question).not.toBeEditable();
+    await question.press('Enter');
+    wire.completeRun(0);
+    await expect(question).toBeEditable();
+
+    const followUp = 'Show the regional breakdown.';
+    await question.fill(followUp);
+    await question.press('Enter');
+    await expect(question).toBeFocused();
+    const expectedSends = [firstSend, { ...firstSend, content: followUp }];
+    await expect.poll(() => wire.sent).toEqual(expectedSends);
+
+    const notebookControl = page.getByRole('button', { name: 'Toggle Table of 
Contents' });
+    await notebookControl.focus();
+    await expect(notebookControl).toBeFocused();
+    const delta = 'The results are grouped by region.';
+    wire.appendRunDelta(1, ` ${delta}`);
+    const answer = messages.getByRole('article', { name: 'Assistant answer', 
exact: true }).filter({ hasText: delta });
+    await expect(answer).toHaveAttribute('aria-busy', 'true');
+    await expect(notebookControl).toBeFocused();
+
+    wire.completeRun(1);
+    await expect(answer.getByRole('table')).toBeVisible();
+    await expect(answer).not.toHaveAttribute('aria-busy', 'true');
+    await expect(question).toBeEditable();
+    await expect(notebookControl).toBeFocused();
+    expect(wire.sent).toEqual(expectedSends);
+  });
+
   test('keeps B draft and results separate when switching away from an active 
A run', async () => {
     const aQuestion = 'Compare revenue for conversation A.';
     const bQuestion = 'Summarize the regions for conversation B.';
diff --git 
a/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.css.ts
 
b/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.css.ts
index 0b93ea9448..26712ae9ee 100644
--- 
a/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.css.ts
+++ 
b/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.css.ts
@@ -16,6 +16,7 @@ import { scope, vars } from 
'@/shared/ui/assistant-theme/AssistantScope.css';
 export const composer = style({
   display: 'flex',
   flexDirection: 'column',
+  minHeight: 0,
   gap: vars.space2
 });
 
@@ -31,6 +32,7 @@ export const note = style({
 export const field = style({
   display: 'flex',
   flexDirection: 'column',
+  minHeight: 0,
   gap: vars.space1,
   padding: vars.space2,
   borderRadius: vars.radiusLg,
@@ -45,6 +47,9 @@ export const field = style({
 });
 
 export const input = style({
+  // Ant's inline autosize styles know the row count, not the space left in 
the panel.
+  minHeight: '0 !important',
+  overflowY: 'auto !important' as 'auto',
   padding: `${vars.space1} ${vars.space2}`,
   fontSize: vars.fontSize
 });
@@ -55,6 +60,7 @@ globalStyle(`${scope} ${input}::placeholder`, { color: 
vars.textTertiary });
 
 export const footer = style({
   display: 'flex',
+  flexShrink: 0,
   alignItems: 'center',
   justifyContent: 'space-between',
   gap: vars.space2,
diff --git 
a/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.spec.tsx
 
b/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.spec.tsx
index 7c8fa0ad27..32e80acf0e 100644
--- 
a/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.spec.tsx
+++ 
b/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.spec.tsx
@@ -43,10 +43,18 @@ describe('AssistantComposer', () => {
     expect(onSubmit).toHaveBeenCalledWith('Explain this notebook');
   });
 
-  it('sends the trimmed question from the button and from Enter', () => {
-    const { onSubmit } = renderComposer({ value: '  Explain this notebook\n' 
});
-    fireEvent.click(send());
+  it('focuses the input during accepted submission and sends the trimmed 
question', () => {
+    const onSubmit = vi.fn(() => expect(document.activeElement).toBe(input()));
+    renderComposer({ value: '  Explain this notebook\n', onSubmit });
+
+    const button = send();
+    button.focus();
+    expect(document.activeElement).toBe(button);
+    fireEvent.click(button);
+    expect(document.activeElement).toBe(input());
+
     pressEnter();
+    expect(document.activeElement).toBe(input());
     expect(onSubmit.mock.calls).toEqual([['Explain this notebook'], ['Explain 
this notebook']]);
   });
 
diff --git 
a/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.tsx
 
b/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.tsx
index de556bd915..ec620867d3 100644
--- 
a/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.tsx
+++ 
b/zeppelin-web-angular/projects/zeppelin-react/src/entities/assistant/ui/AssistantComposer.tsx
@@ -11,8 +11,8 @@
  */
 
 import { ArrowUpOutlined, LockOutlined } from '@ant-design/icons';
-import { Button, Input } from 'antd';
-import { useId, type FormEvent, type KeyboardEvent } from 'react';
+import { Button, Input, type GetRef } from 'antd';
+import { useId, useRef, type FormEvent, type KeyboardEvent } from 'react';
 import * as styles from './AssistantComposer.css';
 
 export interface AssistantComposerProps {
@@ -39,12 +39,16 @@ export const AssistantComposer = ({
   sending = false
 }: AssistantComposerProps) => {
   const hintId = useId();
+  const inputRef = useRef<GetRef<typeof Input.TextArea>>(null);
   const question = value.trim();
   // The server rejects a blank question, and it accepts one question per 
conversation at a time.
   const canSubmit = question !== '' && !readOnly && !sending && 
!submitDisabled;
 
   const submit = () => {
-    if (canSubmit) onSubmit(question);
+    if (!canSubmit) return;
+
+    inputRef.current?.focus({ preventScroll: true });
+    onSubmit(question);
   };
   const handleSubmit = (event: FormEvent) => {
     event.preventDefault();
@@ -68,6 +72,7 @@ export const AssistantComposer = ({
       )}
       <div className={styles.field} data-disabled={readOnly || sending || 
undefined}>
         <Input.TextArea
+          ref={inputRef}
           className={styles.input}
           variant="borderless"
           autoSize={{ minRows: 2, maxRows: 8 }}
diff --git 
a/zeppelin-web-angular/projects/zeppelin-react/src/pages/assistant-workspace/ui/AssistantConversationPanel.css.ts
 
b/zeppelin-web-angular/projects/zeppelin-react/src/pages/assistant-workspace/ui/AssistantConversationPanel.css.ts
index d93b7df162..902b6fcd13 100644
--- 
a/zeppelin-web-angular/projects/zeppelin-react/src/pages/assistant-workspace/ui/AssistantConversationPanel.css.ts
+++ 
b/zeppelin-web-angular/projects/zeppelin-react/src/pages/assistant-workspace/ui/AssistantConversationPanel.css.ts
@@ -83,8 +83,10 @@ export const empty = style({
 });
 
 export const composer = style({
-  flexShrink: 0,
+  display: 'flex',
+  flexDirection: 'column',
   minWidth: 0,
+  minHeight: 0,
   margin: 0,
   padding: 0,
   border: 0

Reply via email to