From 42130d6f1d6085f8e761a0f9e4b13a3ae353408f Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Thu, 15 Jan 2026 21:37:03 +0800 Subject: [PATCH] feat: remove `pause` --- packages/page-agent/src/PageAgent.ts | 12 +------ packages/page-agent/src/utils/bus.ts | 2 -- packages/ui/src/Panel.module.css | 12 ------- packages/ui/src/Panel.ts | 51 ---------------------------- packages/ui/src/UIState.ts | 2 +- packages/ui/src/i18n/locales.ts | 8 ----- 6 files changed, 2 insertions(+), 85 deletions(-) diff --git a/packages/page-agent/src/PageAgent.ts b/packages/page-agent/src/PageAgent.ts index c22baad..5e8919b 100644 --- a/packages/page-agent/src/PageAgent.ts +++ b/packages/page-agent/src/PageAgent.ts @@ -12,7 +12,7 @@ import type { PageAgentConfig } from './config' import { MAX_STEPS } from './config/constants' import SYSTEM_PROMPT from './prompts/system_prompt.md?raw' import { tools } from './tools' -import { normalizeResponse, trimLines, uid, waitUntil } from './utils' +import { normalizeResponse, trimLines, uid } from './utils' import { assert } from './utils/assert' /** @@ -104,7 +104,6 @@ export class PageAgent extends EventTarget { id = uid() panel: Panel tools: typeof tools - paused = false disposed = false task = '' taskId = '' @@ -138,11 +137,6 @@ export class PageAgent extends EventTarget { language: this.config.language, onExecuteTask: (task) => this.execute(task), onStop: () => this.dispose(), - onPauseToggle: () => { - this.paused = !this.paused - return this.paused - }, - getPaused: () => this.paused, }) this.tools = new Map(tools) @@ -237,8 +231,6 @@ export class PageAgent extends EventTarget { // abort if (this.#abortController.signal.aborted) throw new Error('AbortError') - // pause - await waitUntil(() => !this.paused) // Update status to thinking console.log(chalk.blue('Thinking...')) @@ -362,8 +354,6 @@ export class PageAgent extends EventTarget { execute: async (input: MacroToolInput): Promise => { // abort if (this.#abortController.signal.aborted) throw new Error('AbortError') - // pause - await waitUntil(() => !this.paused) console.log(chalk.blue.bold('MacroTool execute'), input) const action = input.action diff --git a/packages/page-agent/src/utils/bus.ts b/packages/page-agent/src/utils/bus.ts index d7e89e4..581d2b4 100644 --- a/packages/page-agent/src/utils/bus.ts +++ b/packages/page-agent/src/utils/bus.ts @@ -6,8 +6,6 @@ export interface PageAgentEventMap { // PageAgent status events // 'agent:execute': { params: { task: string } } // 'agent:done': { params: { text: string; success: boolean } } - // 'agent:paused': { params: undefined } - // 'agent:resumed': { params: undefined } // 'agent:disposed': { params: undefined } // 'agent:error': { params: { error: string | Error } } diff --git a/packages/ui/src/Panel.module.css b/packages/ui/src/Panel.module.css index 4a7592b..840643c 100644 --- a/packages/ui/src/Panel.module.css +++ b/packages/ui/src/Panel.module.css @@ -209,18 +209,6 @@ } } - .pauseButton { - font-weight: 600; - &.paused { - background: rgba(34, 197, 94, 0.2); /* 绿色背景表示可以继续 */ - color: rgb(34, 197, 94); - - &:hover { - background: rgba(34, 197, 94, 0.3); - } - } - } - .stopButton { background: rgba(239, 68, 68, 0.2); color: rgb(255, 41, 41); diff --git a/packages/ui/src/Panel.ts b/packages/ui/src/Panel.ts index efd4e9a..1c6a201 100644 --- a/packages/ui/src/Panel.ts +++ b/packages/ui/src/Panel.ts @@ -11,8 +11,6 @@ export interface PanelConfig { language?: SupportedLanguage onExecuteTask: (task: string) => void onStop: () => void - onPauseToggle: () => boolean // returns new paused state - getPaused: () => boolean } /** @@ -39,7 +37,6 @@ export class Panel { #statusText: HTMLElement #historySection: HTMLElement #expandButton: HTMLElement - #pauseButton: HTMLElement #stopButton: HTMLElement #inputSection: HTMLElement #taskInput: HTMLInputElement @@ -66,7 +63,6 @@ export class Panel { this.#statusText = this.#wrapper.querySelector(`.${styles.statusText}`)! this.#historySection = this.#wrapper.querySelector(`.${styles.historySection}`)! this.#expandButton = this.#wrapper.querySelector(`.${styles.expandButton}`)! - this.#pauseButton = this.#wrapper.querySelector(`.${styles.pauseButton}`)! this.#stopButton = this.#wrapper.querySelector(`.${styles.stopButton}`)! this.#inputSection = this.#wrapper.querySelector(`.${styles.inputSectionWrapper}`)! this.#taskInput = this.#wrapper.querySelector(`.${styles.taskInput}`)! @@ -120,11 +116,6 @@ export class Panel { this.#updateStatusIndicator('thinking') this.#updateHistory() this.#collapse() - // Reset pause state via callback - if (this.#config.getPaused()) { - this.#config.onPauseToggle() - } - this.#updatePauseButton() // Reset user input state this.#isWaitingForUserAnswer = false this.#userAnswerResolver = null @@ -277,39 +268,6 @@ export class Panel { } } - /** - * Toggle pause state - */ - #togglePause(): void { - const paused = this.#config.onPauseToggle() - this.#updatePauseButton() - - // Update status display - if (paused) { - this.#statusText.textContent = this.#i18n.t('ui.panel.paused') - this.#updateStatusIndicator('thinking') - } else { - this.#statusText.textContent = this.#i18n.t('ui.panel.continueExecution') - this.#updateStatusIndicator('tool_executing') - } - } - - /** - * Update pause button state - */ - #updatePauseButton(): void { - const paused = this.#config.getPaused() - if (paused) { - this.#pauseButton.textContent = '▶' - this.#pauseButton.title = this.#i18n.t('ui.panel.continue') - this.#pauseButton.classList.add(styles.paused) - } else { - this.#pauseButton.textContent = '⏸︎' - this.#pauseButton.title = this.#i18n.t('ui.panel.pause') - this.#pauseButton.classList.remove(styles.paused) - } - } - /** * Stop Agent */ @@ -426,9 +384,6 @@ export class Panel { - @@ -466,12 +421,6 @@ export class Panel { this.#toggle() }) - // Pause/continue button - this.#pauseButton.addEventListener('click', (e) => { - e.stopPropagation() - this.#togglePause() - }) - // Stop button this.#stopButton.addEventListener('click', (e) => { e.stopPropagation() diff --git a/packages/ui/src/UIState.ts b/packages/ui/src/UIState.ts index dcf74cb..59b2db9 100644 --- a/packages/ui/src/UIState.ts +++ b/packages/ui/src/UIState.ts @@ -18,7 +18,7 @@ export interface Step { duration?: number } -export type AgentStatus = 'idle' | 'running' | 'paused' | 'completed' | 'error' +export type AgentStatus = 'idle' | 'running' | 'completed' | 'error' export class UIState { private steps: Step[] = [] diff --git a/packages/ui/src/i18n/locales.ts b/packages/ui/src/i18n/locales.ts index b94ae95..b8cf62e 100644 --- a/packages/ui/src/i18n/locales.ts +++ b/packages/ui/src/i18n/locales.ts @@ -4,17 +4,13 @@ const enUS = { panel: { ready: 'Ready', thinking: 'Thinking...', - paused: 'Paused', taskInput: 'Enter new task, describe steps in detail, press Enter to submit', userAnswerPrompt: 'Please answer the question above, press Enter to submit', taskTerminated: 'Task terminated', taskCompleted: 'Task completed', - continueExecution: 'Continue execution', userAnswer: 'User answer: {{input}}', question: 'Question: {{question}}', waitingPlaceholder: 'Waiting for task to start...', - pause: 'Pause', - continue: 'Continue', stop: 'Stop', expand: 'Expand history', collapse: 'Collapse history', @@ -54,17 +50,13 @@ const zhCN = { panel: { ready: '准备就绪', thinking: '正在思考...', - paused: '暂停中,稍后', taskInput: '输入新任务,详细描述步骤,回车提交', userAnswerPrompt: '请回答上面问题,回车提交', taskTerminated: '任务已终止', taskCompleted: '任务结束', - continueExecution: '继续执行', userAnswer: '用户回答: {{input}}', question: '询问: {{question}}', waitingPlaceholder: '等待任务开始...', - pause: '暂停', - continue: '继续', stop: '终止', expand: '展开历史', collapse: '收起历史',