From 0927c1e940af1649722d55217554ccd77c7881a7 Mon Sep 17 00:00:00 2001 From: liubiren Date: Mon, 12 Oct 2026 20:04:07 +0800 Subject: [PATCH] 1 --- agent/application/pages/workbench.py | 147 +++++---------------------- 1 file changed, 27 insertions(+), 120 deletions(-) diff --git a/agent/application/pages/workbench.py b/agent/application/pages/workbench.py index 9443f4c..8d54291 100644 --- a/agent/application/pages/workbench.py +++ b/agent/application/pages/workbench.py @@ -89,9 +89,7 @@ def task_history_item( rx.text( item.description, flex=1, - height="22px", - line_height="22px", - padding_right="18px", + line_height="20px", color="var(--prismui-color-2)", text_overflow="ellipsis", white_space="nowrap", @@ -100,111 +98,11 @@ def task_history_item( display="flex", align_items="center", width="100%", - margin_bottom="8px", + padding="5px 0", # 点击事件:设置激活任务 on_click=lambda: TaskState.set_task(item.id), ), - # 任务更多按钮 - rx.box( - rx.popover.root( - rx.popover.trigger( - rx.box( - rx.icon( - "ellipsis", - width="14px", - height="14px", - color="var(--prismui-color-2)", - ), - cursor="pointer", - ) - ), - rx.popover.content( - rx.vstack( - rx.box( - position="absolute", - top="-6px", - left="50%", - transform="translateX(-50%) rotate(45deg)", - width="8px", - height="8px", - background_color="var(--prismui-background-color-1)", - ), - rx.popover.close( - rx.box( - "删除", - # 点击事件:删除任务 - on_click=lambda: TaskState.delete_task(item.id), - display="flex", - align_items="center", - justify_content="center", - width="100%", - height="24px", - border_radius="var(--prismui-border-radius-1)", - line_height="16px", - font_family="var(--prismui-font-family)", - font_size="var(--prismui-font-size-1)", - color="var(--prismui-color-1)", - style={ - "_hover": { - "background_color": "var(--prismui-background-color-6)", - }, # 鼠标悬停显示背景颜色 - }, - cursor="pointer", - ), - ), - position="relative", - width="100%", - ), - side="bottom", - side_offset=8, - position="relative", - align="center", - padding="4px 8px", - border_radius="var(--prismui-border-radius-1)", - box_shadow="var(--prismui-box-shadow-6)", - overflow="visible", - ), - # 悬停气泡显示 / 隐藏变化事件:设置任务历史项悬停气泡显示 / 隐藏 - on_open_change=lambda is_shown: TaskState.set_task_history_item_popover_shown( - item.id, is_shown - ), - open_delay=0, - ), - position="absolute", - top="27px", - right="16px", - transform="translateY(-50%)", - z_index="99", - min_width="14px", - cursor="pointer", - opacity=rx.cond(is_highlight, "1", "0"), - transition="opacity 0.18s ease-in-out", - pointer_events=rx.cond(is_highlight, "auto", "none"), - ), - display="flex", - position="relative", - align_items="flex-start", width="100%", - padding="16px", - margin_bottom="8px", - background=rx.cond( - is_highlight, - "var(--prismui-background-3)", - "var(--prismui-background-color-1)", - ), - border_radius="var(--prismui-border-radius-3)", - box_shadow=rx.cond(is_highlight, "var(--prismui-box-shadow-7)", "none"), - cursor="pointer", - style={ - "&:hover": { - "background": "var(--prismui-background-3)", - "box_shadow": "var(--prismui-box-shadow-7)", - }, # 鼠标悬停背景颜色和阴影 - "&:hover > div:last-child": { - "opacity": "1", - "pointer_events": "auto", - }, # 鼠标悬停显示更多按钮 - }, ) @@ -214,20 +112,23 @@ def task_history() -> rx.Component: :return: rx.Component """ return rx.auto_scroll( - rx.foreach( - TaskState.task_history, - task_history_item, - ), - flex="1", - align_items="stretch", - width="100%", - margin_top="8px", - style={ - "&::-webkit-scrollbar": { - "display": "none", + rx.list( + rx.foreach( + TaskState.task_history, + task_history_item, + ), + display="flex", + flex_direction="column", + gap="2px", + width="100%", + style={ + "&::-webkit-scrollbar": { + "display": "none", + }, }, - }, - overflow="auto", + overflow="auto", + ), + width="100%", ) @@ -343,25 +244,31 @@ def sidebar() -> rx.Component: ), align_items="center", gap="4px", + width="100%", height="56px", - padding="0 0 12px 12px", + padding="0 12px 12px", ), # 渲染导航按钮 rx.vstack( # 渲染导航按钮:创建任务 nav_button("create_task"), gap="2px", - padding="0 0 16px 0", + width="100%", + padding_bottom="16px", ), # 渲染最近任务 rx.vstack( + # 标题 rx.text( "最近", line_height="20px", font_size="var(--prismui-font-size-2)", - padding="0 0 0 10px", + padding="5px 10px 5px 22px", ), + # 历史任务 task_history(), + gap="2px", + width="100%", padding="0 12px", ), align_items="flex-start",