diff --git a/agent/application/pages/task.py b/agent/application/pages/task.py index eb32168..b7665e2 100644 --- a/agent/application/pages/task.py +++ b/agent/application/pages/task.py @@ -45,169 +45,58 @@ def task_history_item( align_items="center", width="100%", margin_bottom="8px", - cursor="pointer", - # 点击事件:将指定任务唯一标识设置为当前任务唯一标识 - on_click=lambda: TaskState.set_task_id(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", - }, # 鼠标悬停显示更多按钮 - }, + # 点击事件:将指定任务唯一标识设置为当前任务唯一标识 + on_click=lambda: TaskState.set_task_id(item.id), ) -def task_history( - is_conversation_history_shown: bool, -) -> rx.Component: +def task_history() -> rx.Component: """ 任务历史 - :param is_conversation_history_shown: 展示 / 隐藏 - :return: Component + :return: rx.Component """ - return rx.box( - rx.vstack( - # 会话历史的标题 - rx.hstack( - rx.text( - "会话历史", - margin_bottom="8px", - font_weight="var(--prismui-font-weight-3)", - white_space="nowrap", - ), - align_items="center", - justify_content="space-between", + return rx.vstack( + # 任务历史的标题 + rx.hstack( + rx.text( + "任务历史", + margin_bottom="8px", + font_weight="var(--prismui-font-weight-3)", + white_space="nowrap", ), - 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", - }, - }, - overflow="auto", - ), - display="flex", - flex_direction="column", - height="100%", - padding="12px", - background_color="#f9f9f9cc", - backdrop_filter="blur(50px)", - gap="12px", + align_items="center", + justify_content="space-between", ), - width=rx.cond(is_conversation_history_shown, "25%", "0px"), - min_width=rx.cond(is_conversation_history_shown, "240px", "0px"), - max_width=rx.cond(is_conversation_history_shown, "380px", "0px"), + 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", + }, + }, + overflow="auto", + ), + display="flex", + flex_direction="column", height="100%", - transition="all 0.18s ease-in-out", - overflow="hidden", + padding="12px", + background_color="#f9f9f9cc", + backdrop_filter="blur(50px)", + gap="12px", ) - def workflow_button(workflow_type: WorkflowType): """ 工作流按钮