mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
feat(remote-control): 优化 Web 展示、状态同步与桥接控制流程 (#288)
Co-authored-by: chengzifeng <chengzifeng@meituan.com>
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
*/
|
||||
import { feature } from 'bun:bundle'
|
||||
import { randomUUID, type UUID } from 'crypto'
|
||||
import { getReplBridgeHandle } from '../../bridge/replBridgeHandle.js'
|
||||
import {
|
||||
getLastMainRequestId,
|
||||
getOriginalCwd,
|
||||
getSessionId,
|
||||
regenerateSessionId,
|
||||
} from '../../bootstrap/state.js'
|
||||
import type { SDKStatusMessage } from '../../entrypoints/sdk/coreTypes.js'
|
||||
import {
|
||||
type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
||||
logEvent,
|
||||
@@ -46,6 +48,21 @@ import {
|
||||
import { getCurrentWorktreeSession } from '../../utils/worktree.js'
|
||||
import { clearSessionCaches } from './caches.js'
|
||||
|
||||
function notifyRemoteConversationCleared(): void {
|
||||
const handle = getReplBridgeHandle()
|
||||
if (!handle) return
|
||||
handle.markTranscriptReset?.()
|
||||
|
||||
const message: SDKStatusMessage = {
|
||||
type: 'status',
|
||||
subtype: 'status',
|
||||
status: 'conversation_cleared',
|
||||
message: 'conversation_cleared',
|
||||
uuid: randomUUID(),
|
||||
}
|
||||
handle.writeSdkMessages([message])
|
||||
}
|
||||
|
||||
export async function clearConversation({
|
||||
setMessages,
|
||||
readFileState,
|
||||
@@ -107,6 +124,7 @@ export async function clearConversation({
|
||||
}
|
||||
|
||||
setMessages(() => [])
|
||||
notifyRemoteConversationCleared()
|
||||
|
||||
// Clear context-blocked flag so proactive ticks resume after /clear
|
||||
if (feature('PROACTIVE') || feature('KAIROS')) {
|
||||
|
||||
16
src/commands/plan/index.test.ts
Normal file
16
src/commands/plan/index.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
|
||||
import plan from './index.js'
|
||||
|
||||
describe('plan bridge invocation safety', () => {
|
||||
test('allows headless plan mode operations over Remote Control', () => {
|
||||
expect(plan.getBridgeInvocationError?.('')).toBeUndefined()
|
||||
expect(plan.getBridgeInvocationError?.('write a migration plan')).toBeUndefined()
|
||||
})
|
||||
|
||||
test('blocks /plan open over Remote Control', () => {
|
||||
expect(plan.getBridgeInvocationError?.('open')).toBe(
|
||||
"Opening the local editor via /plan open isn't available over Remote Control.",
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,14 @@
|
||||
import type { Command } from '../../commands.js'
|
||||
|
||||
const plan = {
|
||||
bridgeSafe: true,
|
||||
getBridgeInvocationError(args: string) {
|
||||
const subcommand = args.trim().split(/\s+/)[0]
|
||||
if (subcommand === 'open') {
|
||||
return "Opening the local editor via /plan open isn't available over Remote Control."
|
||||
}
|
||||
return undefined
|
||||
},
|
||||
type: 'local-jsx',
|
||||
name: 'plan',
|
||||
description: 'Enable plan mode or view the current session plan',
|
||||
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
} from '../types/command.js'
|
||||
|
||||
const proactive = {
|
||||
bridgeSafe: true,
|
||||
type: 'local-jsx',
|
||||
name: 'proactive',
|
||||
description: 'Toggle proactive (autonomous) mode',
|
||||
|
||||
Reference in New Issue
Block a user