Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

♻️ refactor(chat): remove reject-only button, unify to rejected_continue (#13865)

Arvin Xuf6c70210f2b7
diff --git a/packages/builtin-tool-local-system/src/manifest.ts b/packages/builtin-tool-local-system/src/manifest.ts
index b0c02cf3043..93bc062b68f 100644
--- a/packages/builtin-tool-local-system/src/manifest.ts
+++ b/packages/builtin-tool-local-system/src/manifest.ts
@@ -4,6 +4,7 @@ import { systemPrompt } from './systemRole';
import { LocalSystemApiName, LocalSystemIdentifier } from './types';
export const LocalSystemManifest: BuiltinToolManifest = {
+ executors: ['client', 'server'],
api: [
{
description:
diff --git a/packages/builtin-tool-page-agent/src/manifest.ts b/packages/builtin-tool-page-agent/src/manifest.ts
index 6b903ea1162..0f19b77b6b3 100644
--- a/packages/builtin-tool-page-agent/src/manifest.ts
+++ b/packages/builtin-tool-page-agent/src/manifest.ts
@@ -4,6 +4,7 @@ import { systemPrompt } from './systemRole';
import { DocumentApiName, PageAgentIdentifier } from './types';
export const PageAgentManifest: BuiltinToolManifest = {
+ executors: ['client'],
api: [
// ============ Initialize ============
{
diff --git a/packages/types/src/tool/builtin.ts b/packages/types/src/tool/builtin.ts
index 9d035f71cf3..71a33f85f2e 100644
--- a/packages/types/src/tool/builtin.ts
+++ b/packages/types/src/tool/builtin.ts
@@ -177,6 +177,19 @@ export const LobeChatPluginApiSchema = z.object({
export interface BuiltinToolManifest {
api: LobeChatPluginApi[];
+ /**
+ * Supported execution environments for this tool.
+ * - `'client'`: dispatched to the client via Agent Gateway WebSocket
+ * (requires Electron / desktop runtime). For tools that depend on
+ * local resources (filesystem, EditorRuntime, stdio MCP, etc.).
+ * - `'server'`: executed server-side by ToolExecutionService.
+ *
+ * When both are present, the server picks based on `clientRuntime`:
+ * desktop callers get `'client'` dispatch; web callers get `'server'`.
+ * When omitted, defaults to server-only execution.
+ */
+ executors?: ('client' | 'server')[];
+
/**
* Tool-level default human intervention policy
* This policy applies to all APIs that don't specify their own policy
@@ -204,6 +217,7 @@ export interface BuiltinToolManifest {
export const BuiltinToolManifestSchema = z.object({
api: z.array(LobeChatPluginApiSchema),
+ executors: z.array(z.enum(['client', 'server'])).optional(),
humanIntervention: ExtendedHumanInterventionConfigSchema.optional(),
identifier: z.string(),
meta: MetaSchema,
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx
index b1f4901a797..dfb4733d4c9 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx
@@ -34,23 +34,21 @@ const ApprovalActions = memo<ApprovalActionsProps>(
// Disable actions while message is still being created (temp ID)
const isMessageCreating = messageId.startsWith('tmp_');
- const [approveToolCall, rejectToolCall, rejectAndContinueToolCall] = useConversationStore(
- (s) => [s.approveToolCall, s.rejectToolCall, s.rejectAndContinueToolCall],
- );
+ const [approveToolCall, rejectAndContinueToolCall] = useConversationStore((s) => [
+ s.approveToolCall,
+ s.rejectAndContinueToolCall,
+ ]);
const addToolToAllowList = useUserStore((s) => s.addToolToAllowList);
const handleApprove = async (remember?: boolean) => {
setApproveLoading(true);
try {
- // 0. Flush pending saves from intervention components (e.g., debounced saves)
if (onBeforeApprove) {
await onBeforeApprove();
}
- // 1. Update intervention status
await approveToolCall(messageId, assistantGroupId ?? '');
- // 2. If remembered, add to allowList
if (remember) {
const toolKey = `${identifier}/${apiName}`;
await addToolToAllowList(toolKey);
@@ -61,14 +59,6 @@ const ApprovalActions = memo<ApprovalActionsProps>(
};
const handleReject = async (reason?: string) => {
- setRejectLoading(true);
- await rejectToolCall(messageId, reason);
- setRejectLoading(false);
- setRejectPopoverOpen(false);
- setRejectReason('');
- };
-
- const handleRejectAndContinue = async (reason?: string) => {
setRejectLoading(true);
await rejectAndContinueToolCall(messageId, reason);
setRejectLoading(false);
@@ -87,25 +77,14 @@ const ApprovalActions = memo<ApprovalActionsProps>(
<Flexbox horizontal align={'center'} justify={'space-between'}>
<div>{t('tool.intervention.rejectTitle')}</div>
- <Space>
- <Button
- color={'default'}
- loading={rejectLoading}
- size="small"
- variant={'filled'}
- onClick={() => handleReject(rejectReason)}
- >
- {t('tool.intervention.rejectOnly')}
- </Button>
- <Button
- loading={rejectLoading}
- size="small"
- type="primary"
- onClick={() => handleRejectAndContinue(rejectReason)}
- >
- {t('tool.intervention.rejectAndContinue')}
- </Button>
- </Space>
+ <Button
+ loading={rejectLoading}
+ size="small"
+ type="primary"
+ onClick={() => handleReject(rejectReason)}
+ >
+ {t('tool.intervention.rejectAndContinue')}
+ </Button>
</Flexbox>
<Input.TextArea
autoFocus
diff --git a/src/server/services/aiAgent/index.ts b/src/server/services/aiAgent/index.ts
index e25a4254935..ec92a663f23 100644
--- a/src/server/services/aiAgent/index.ts
+++ b/src/server/services/aiAgent/index.ts
@@ -755,9 +755,16 @@ export class AiAgentService {
// leave executor unset so tools route via RemoteDevice proxy.
const shouldDispatchToClient = clientRuntime === 'desktop' || !gatewayConfigured;
if (shouldDispatchToClient) {
- if (manifestMap.has(LocalSystemManifest.identifier)) {
- toolExecutorMap[LocalSystemManifest.identifier] = 'client';
+ // Tools that declare `executors` including `'client'` in their
+ // manifest are dispatched to the client when a desktop caller is
+ // connected. `toolManifestMap` is a superset of `manifestMap`
+ // (includes both enabled plugins and discoverable builtins).
+ for (const id of Object.keys(toolManifestMap)) {
+ if (toolManifestMap[id]?.executors?.includes('client')) {
+ toolExecutorMap[id] = 'client';
+ }
}
+ // Stdio MCP plugins: subprocess lives on the user's machine
for (const plugin of installedPlugins) {
if (plugin.customParams?.mcp?.type === 'stdio' && manifestMap.has(plugin.identifier)) {
toolExecutorMap[plugin.identifier] = 'client';
diff --git a/src/store/chat/slices/aiChat/actions/__tests__/conversationControl.test.ts b/src/store/chat/slices/aiChat/actions/__tests__/conversationControl.test.ts
index b5394383553..45a3b456ba2 100644
--- a/src/store/chat/slices/aiChat/actions/__tests__/conversationControl.test.ts
+++ b/src/store/chat/slices/aiChat/actions/__tests__/conversationControl.test.ts
@@ -935,7 +935,7 @@ describe('ConversationControl actions', () => {
});
describe('rejectToolCalling server-mode branch', () => {
- it('starts a new Gateway op with resumeApproval.decision=rejected', async () => {
+ it('starts a new Gateway op with resumeApproval.decision=rejected_continue (unified)', async () => {
const { result } = renderHook(() => useChatStore());
const agentId = 'server-agent';
@@ -979,7 +979,7 @@ describe('ConversationControl actions', () => {
message: '',
parentMessageId: 'tool-msg-1',
resumeApproval: {
- decision: 'rejected',
+ decision: 'rejected_continue',
parentMessageId: 'tool-msg-1',
rejectionReason: 'not appropriate',
toolCallId: 'call_xyz',
diff --git a/src/store/chat/slices/aiChat/actions/conversationControl.ts b/src/store/chat/slices/aiChat/actions/conversationControl.ts
index 6917d2bfb80..e7ed0c45475 100644
--- a/src/store/chat/slices/aiChat/actions/conversationControl.ts
+++ b/src/store/chat/slices/aiChat/actions/conversationControl.ts
@@ -609,13 +609,11 @@ export class ConversationControlActionImpl {
optimisticContext,
);
- // Server-mode: start a **new** Gateway op carrying `decision='rejected'`.
- // Server persists the rejection on the target tool message and halts the
- // conversation. The new op's `agent_runtime_end` clears the loading
- // state on the client; the snapshot-then-retire dance below is a
- // fallback guard in case the server-side human_approve agent_runtime_end
- // was missed, while preserving the paused-op marker on failure so a
- // retry still hits the Gateway branch.
+ // Server-mode: start a **new** Gateway op carrying the rejection.
+ // We use `rejected_continue` uniformly — server-side `rejected` and
+ // `rejected_continue` share the same code path (both surface the
+ // rejection to the LLM as user feedback), so a separate `rejected`
+ // decision adds complexity without behavioural difference.
if (this.#shouldUseGatewayResume()) {
const toolCallId = toolMessage.tool_call_id;
if (!toolCallId) {
@@ -632,7 +630,7 @@ export class ConversationControlActionImpl {
message: '',
parentMessageId: messageId,
resumeApproval: {
- decision: 'rejected',
+ decision: 'rejected_continue',
parentMessageId: messageId,
rejectionReason: reason,
toolCallId,