Просмотр исходного кода

fix(workbench): 修复复测发现的列遮挡与放大填充延迟

- D7-R: 任务管理状态列前置并压缩列宽,避免被右侧固定操作列遮挡,「生成中」标签首屏可见
- R-1: 工作台壳高变化后显式广播事件,聊天区即时重算;真实大幅调整窗口立即跟随,小幅视口扰动仍防抖
cc 4 дней назад
Родитель
Сommit
f1969bbf25

+ 25 - 3
ai-electron/frontend/src/workbench/layouts/WorkbenchLayout.vue

@@ -31,7 +31,7 @@
 </template>
 
 <script lang="ts" setup name="WorkbenchLayout">
-  import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
+  import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
   import { Button, Tooltip } from 'ant-design-vue';
   import { useRoute, useRouter } from 'vue-router';
   import AppTopBar from '@/core/components/Application/src/AppTopBar.vue';
@@ -61,17 +61,39 @@
    *
    * <p>不直接用 CSS {@code 100vh}:内嵌浏览器在路由切换 / 页面发请求的瞬间会临时改变视口高度
    * (约 50ms,实测 +32px),{@code 100vh} 跟着跳会表现为「整个页面抖一下」。
-   * 这里按窗口 resize 防抖更新:瞬时变化被吞掉,真正拖拽窗口时在停止后补一次。</p>
+   * 这里按窗口 resize 防抖更新:小幅瞬时变化被吞掉;幅度较大的真实调整立即跟随,避免可见滞后。</p>
    */
   const shellHeight = ref(typeof window === 'undefined' ? 0 : window.innerHeight);
+  /**
+   * 壳高更新完成事件:聊天页据此重新计算自身高度。
+   *
+   * <p>不能只依赖窗口 resize:壳高是防抖更新的,resize 事件到达时壳还是旧高度;
+   * 也不能只依赖 ResizeObserver(部分内嵌浏览器/自动化环境不回调)。壳高真正写入后显式广播一次,
+   * 保证聊天区在放大/缩小后立即跟随,不出现底部空白过渡。</p>
+   */
+  const WORKBENCH_SHELL_RESIZE_EVENT = 'workbench:shell-resize';
   let resizeTimer: number | undefined;
+  const applyShellHeight = (height: number) => {
+    shellHeight.value = height;
+    // 等 Vue 把内联 height 刷到 DOM 后再通知,监听方读到的是新壳高
+    void nextTick(() => {
+      window.dispatchEvent(new Event(WORKBENCH_SHELL_RESIZE_EVENT));
+    });
+  };
   const handleWindowResize = () => {
     if (resizeTimer !== undefined) {
       window.clearTimeout(resizeTimer);
+      resizeTimer = undefined;
+    }
+    // 真实调整窗口(拖拽 / 最大化)幅度较大:立即跟随,避免聊天区底部可见空白;
+    // 内嵌浏览器在路由切换 / 请求瞬间的视口扰动约 32px,低于阈值仍走防抖吞掉,避免整页抖动
+    if (Math.abs(window.innerHeight - shellHeight.value) > 64) {
+      applyShellHeight(window.innerHeight);
+      return;
     }
     resizeTimer = window.setTimeout(() => {
       resizeTimer = undefined;
-      shellHeight.value = window.innerHeight;
+      applyShellHeight(window.innerHeight);
     }, 160);
   };
   onMounted(() => {

+ 16 - 8
ai-electron/frontend/src/workbench/views/agent/session/index.vue

@@ -274,14 +274,22 @@
   const multiple = ref(true);
 
   const columns: any[] = [
-    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', width: 260, ellipsis: true, slot: 'sessionTitle' },
-    { title: '来源', key: 'source', width: 110, align: 'center', slot: 'source' },
-    { title: '智能体', dataIndex: 'agentName', key: 'agentName', width: 150, ellipsis: true },
-    { title: '归属用户', key: 'user', width: 120, slot: 'user' },
-    { title: '消息数', dataIndex: 'messageCount', key: 'messageCount', width: 90, align: 'center' },
-    { title: '状态', key: 'status', width: 150, align: 'center', slot: 'status' },
-    { title: '最后活跃时间', dataIndex: 'lastActiveTime', key: 'lastActiveTime', width: 170, align: 'center' },
-    { title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 170, align: 'center' },
+    {
+      title: '任务标题',
+      dataIndex: 'sessionTitle',
+      key: 'sessionTitle',
+      width: 240,
+      ellipsis: true,
+      slot: 'sessionTitle',
+    },
+    // 状态列前置:表格在 1280 视口必然横向溢出,右侧固定操作列会覆盖末尾列,状态(含「生成中」)必须首屏可见
+    { title: '状态', key: 'status', width: 120, align: 'center', slot: 'status' },
+    { title: '来源', key: 'source', width: 100, align: 'center', slot: 'source' },
+    { title: '智能体', dataIndex: 'agentName', key: 'agentName', width: 140, ellipsis: true },
+    { title: '归属用户', key: 'user', width: 110, slot: 'user' },
+    { title: '消息数', dataIndex: 'messageCount', key: 'messageCount', width: 80, align: 'center' },
+    { title: '最后活跃时间', dataIndex: 'lastActiveTime', key: 'lastActiveTime', width: 160, align: 'center' },
+    { title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 160, align: 'center' },
     { title: '操作', key: 'action', width: 200, align: 'center', fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 

+ 6 - 0
ai-electron/frontend/src/workbench/views/chat/index.vue

@@ -1218,6 +1218,9 @@
   /** 工作台高度下限(可用高度不足时兜底,避免窄屏 / 小窗口下主区被压没) */
   const MIN_WORKBENCH_HEIGHT = 360;
 
+  /** 工作台壳高度更新事件(由 WorkbenchLayout 在防抖写入新壳高后广播) */
+  const WORKBENCH_SHELL_RESIZE_EVENT = 'workbench:shell-resize';
+
   /** 工作台容器(用于实测高度) */
   const workbenchRef = ref<HTMLElement>();
 
@@ -1515,6 +1518,8 @@
     syncWorkbenchHeight();
     workbenchTimers = [0, 120, 360].map((delay) => window.setTimeout(syncWorkbenchHeight, delay));
     window.addEventListener('resize', syncWorkbenchHeight);
+    // 壳高防抖更新后由布局显式通知:resize 事件到达时壳还是旧高度,不能只靠它
+    window.addEventListener(WORKBENCH_SHELL_RESIZE_EVENT, syncWorkbenchHeight);
     // 观察真实宿主尺寸:工作台壳对 window resize 做了防抖(瞬时视口变化不跟),
     // 窗口放大/缩小时 window resize 先到、壳高后变;只监听 window 会用旧壳高计算,
     // 表现为放大后聊天区不填满(底部留白)、缩小时输入区被裁切。
@@ -1562,6 +1567,7 @@
     }
     closeArtifactPreview();
     window.removeEventListener('resize', syncWorkbenchHeight);
+    window.removeEventListener(WORKBENCH_SHELL_RESIZE_EVENT, syncWorkbenchHeight);
     workbenchResizeObserver?.disconnect();
     workbenchResizeObserver = undefined;
     if (scrollRaf) {