mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 13:55:50 +00:00
更新大量 tsx 原始文件; 已经迁移 login panel; 部分 (#121)
* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-2): 格式化 commands (79 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-5): 格式化 components其余 + hooks + tools (232 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md - README.md: 大幅重写,更详细版本历史和配置示例 - Run.ps1: 新增 Windows 启动脚本 - TODO.md: 新增包完成清单 - V6.md: 删除(架构重构规划已不适用) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复以前的问题 * fix: 修复 login 面板的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,14 +9,19 @@
|
||||
* 4. Can be idle (waiting for work) or active (processing)
|
||||
*/
|
||||
|
||||
import { isTerminalTaskStatus, type SetAppState, type Task, type TaskStateBase } from '../../Task.js';
|
||||
import type { Message } from '../../types/message.js';
|
||||
import { logForDebugging } from '../../utils/debug.js';
|
||||
import { createUserMessage } from '../../utils/messages.js';
|
||||
import { killInProcessTeammate } from '../../utils/swarm/spawnInProcess.js';
|
||||
import { updateTaskState } from '../../utils/task/framework.js';
|
||||
import type { InProcessTeammateTaskState } from './types.js';
|
||||
import { appendCappedMessage, isInProcessTeammateTask } from './types.js';
|
||||
import {
|
||||
isTerminalTaskStatus,
|
||||
type SetAppState,
|
||||
type Task,
|
||||
type TaskStateBase,
|
||||
} from '../../Task.js'
|
||||
import type { Message } from '../../types/message.js'
|
||||
import { logForDebugging } from '../../utils/debug.js'
|
||||
import { createUserMessage } from '../../utils/messages.js'
|
||||
import { killInProcessTeammate } from '../../utils/swarm/spawnInProcess.js'
|
||||
import { updateTaskState } from '../../utils/task/framework.js'
|
||||
import type { InProcessTeammateTaskState } from './types.js'
|
||||
import { appendCappedMessage, isInProcessTeammateTask } from './types.js'
|
||||
|
||||
/**
|
||||
* InProcessTeammateTask - Handles in-process teammate execution.
|
||||
@@ -25,39 +30,48 @@ export const InProcessTeammateTask: Task = {
|
||||
name: 'InProcessTeammateTask',
|
||||
type: 'in_process_teammate',
|
||||
async kill(taskId, setAppState) {
|
||||
killInProcessTeammate(taskId, setAppState);
|
||||
}
|
||||
};
|
||||
killInProcessTeammate(taskId, setAppState)
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Request shutdown for a teammate.
|
||||
*/
|
||||
export function requestTeammateShutdown(taskId: string, setAppState: SetAppState): void {
|
||||
export function requestTeammateShutdown(
|
||||
taskId: string,
|
||||
setAppState: SetAppState,
|
||||
): void {
|
||||
updateTaskState<InProcessTeammateTaskState>(taskId, setAppState, task => {
|
||||
if (task.status !== 'running' || task.shutdownRequested) {
|
||||
return task;
|
||||
return task
|
||||
}
|
||||
|
||||
return {
|
||||
...task,
|
||||
shutdownRequested: true
|
||||
};
|
||||
});
|
||||
shutdownRequested: true,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a message to a teammate's conversation history.
|
||||
* Used for zoomed view to show the teammate's conversation.
|
||||
*/
|
||||
export function appendTeammateMessage(taskId: string, message: Message, setAppState: SetAppState): void {
|
||||
export function appendTeammateMessage(
|
||||
taskId: string,
|
||||
message: Message,
|
||||
setAppState: SetAppState,
|
||||
): void {
|
||||
updateTaskState<InProcessTeammateTaskState>(taskId, setAppState, task => {
|
||||
if (task.status !== 'running') {
|
||||
return task;
|
||||
return task
|
||||
}
|
||||
|
||||
return {
|
||||
...task,
|
||||
messages: appendCappedMessage(task.messages, message)
|
||||
};
|
||||
});
|
||||
messages: appendCappedMessage(task.messages, message),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,22 +79,30 @@ export function appendTeammateMessage(taskId: string, message: Message, setAppSt
|
||||
* Used when viewing a teammate's transcript to send typed messages to them.
|
||||
* Also adds the message to task.messages so it appears immediately in the transcript.
|
||||
*/
|
||||
export function injectUserMessageToTeammate(taskId: string, message: string, setAppState: SetAppState): void {
|
||||
export function injectUserMessageToTeammate(
|
||||
taskId: string,
|
||||
message: string,
|
||||
setAppState: SetAppState,
|
||||
): void {
|
||||
updateTaskState<InProcessTeammateTaskState>(taskId, setAppState, task => {
|
||||
// Allow message injection when teammate is running or idle (waiting for input)
|
||||
// Only reject if teammate is in a terminal state
|
||||
if (isTerminalTaskStatus(task.status)) {
|
||||
logForDebugging(`Dropping message for teammate task ${taskId}: task status is "${task.status}"`);
|
||||
return task;
|
||||
logForDebugging(
|
||||
`Dropping message for teammate task ${taskId}: task status is "${task.status}"`,
|
||||
)
|
||||
return task
|
||||
}
|
||||
|
||||
return {
|
||||
...task,
|
||||
pendingUserMessages: [...task.pendingUserMessages, message],
|
||||
messages: appendCappedMessage(task.messages, createUserMessage({
|
||||
content: message
|
||||
}))
|
||||
};
|
||||
});
|
||||
messages: appendCappedMessage(
|
||||
task.messages,
|
||||
createUserMessage({ content: message }),
|
||||
),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,29 +111,34 @@ export function injectUserMessageToTeammate(taskId: string, message: string, set
|
||||
* with the same agentId exist.
|
||||
* Returns undefined if not found.
|
||||
*/
|
||||
export function findTeammateTaskByAgentId(agentId: string, tasks: Record<string, TaskStateBase>): InProcessTeammateTaskState | undefined {
|
||||
let fallback: InProcessTeammateTaskState | undefined;
|
||||
export function findTeammateTaskByAgentId(
|
||||
agentId: string,
|
||||
tasks: Record<string, TaskStateBase>,
|
||||
): InProcessTeammateTaskState | undefined {
|
||||
let fallback: InProcessTeammateTaskState | undefined
|
||||
for (const task of Object.values(tasks)) {
|
||||
if (isInProcessTeammateTask(task) && task.identity.agentId === agentId) {
|
||||
// Prefer running tasks in case old killed tasks still exist in AppState
|
||||
// alongside new running ones with the same agentId
|
||||
if (task.status === 'running') {
|
||||
return task;
|
||||
return task
|
||||
}
|
||||
// Keep first match as fallback in case no running task exists
|
||||
if (!fallback) {
|
||||
fallback = task;
|
||||
fallback = task
|
||||
}
|
||||
}
|
||||
}
|
||||
return fallback;
|
||||
return fallback
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all in-process teammate tasks from AppState.
|
||||
*/
|
||||
export function getAllInProcessTeammateTasks(tasks: Record<string, TaskStateBase>): InProcessTeammateTaskState[] {
|
||||
return Object.values(tasks).filter(isInProcessTeammateTask);
|
||||
export function getAllInProcessTeammateTasks(
|
||||
tasks: Record<string, TaskStateBase>,
|
||||
): InProcessTeammateTaskState[] {
|
||||
return Object.values(tasks).filter(isInProcessTeammateTask)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,6 +147,10 @@ export function getAllInProcessTeammateTasks(tasks: Record<string, TaskStateBase
|
||||
* and useBackgroundTaskNavigation — selectedIPAgentIndex maps into this
|
||||
* array, so all three must agree on sort order.
|
||||
*/
|
||||
export function getRunningTeammatesSorted(tasks: Record<string, TaskStateBase>): InProcessTeammateTaskState[] {
|
||||
return getAllInProcessTeammateTasks(tasks).filter(t => t.status === 'running').sort((a, b) => a.identity.agentName.localeCompare(b.identity.agentName));
|
||||
export function getRunningTeammatesSorted(
|
||||
tasks: Record<string, TaskStateBase>,
|
||||
): InProcessTeammateTaskState[] {
|
||||
return getAllInProcessTeammateTasks(tasks)
|
||||
.filter(t => t.status === 'running')
|
||||
.sort((a, b) => a.identity.agentName.localeCompare(b.identity.agentName))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user