Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/commands/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ export function handleClear(ctx: CommandContext): CommandResult {
return { reply: '✅ 会话已清除,下次消息将开始新会话。', handled: true };
}

/**
* /stop 空闲时的反馈。
* 处理中的 /stop 由 main.ts 的 handlePriorityCommand 提前拦截(abort + 清空队列),
* 不会走到这里;走到这里说明当前没有正在跑的任务。
*/
export function handleStop(ctx: CommandContext): CommandResult {
if (ctx.session.state === 'processing') {
// 理论上不可达:留作防御,避免出现"未找到 skill"的误导提示
return { reply: '⏹ 正在停止当前任务…', handled: true };
}
return { reply: 'ℹ️ 当前没有正在进行的任务。', handled: true };
}

export function handleCwd(ctx: CommandContext, args: string): CommandResult {
if (!args) {
return { reply: `当前工作目录: ${ctx.session.workingDirectory}\n用法: /cwd <路径>`, handled: true };
Expand Down
4 changes: 3 additions & 1 deletion src/commands/router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Session } from '../session.js';
import { findSkill } from '../claude/skill-scanner.js';
import { logger } from '../logger.js';
import { handleHelp, handleClear, handleCwd, handleModel, handleStatus, handleSkills, handleHistory, handleReset, handleCompact, handleUndo, handleVersion, handlePrompt, handleSend, handleUnknown } from './handlers.js';
import { handleHelp, handleClear, handleStop, handleCwd, handleModel, handleStatus, handleSkills, handleHistory, handleReset, handleCompact, handleUndo, handleVersion, handlePrompt, handleSend, handleUnknown } from './handlers.js';

export interface CommandContext {
accountId: string;
Expand Down Expand Up @@ -48,6 +48,8 @@ export function routeCommand(ctx: CommandContext): CommandResult {
return handleHelp(args);
case 'clear':
return handleClear(ctx);
case 'stop':
return handleStop(ctx);
case 'reset':
return handleReset(ctx);
case 'cwd':
Expand Down