feat: add bounded history previews across nine channels

Add shared /history parsing, read-only session access, message filtering, and bounded replies. Default to three messages, cap at five, and exclude saved history commands.

Include channel integration tests, translations, command help, and the Issue #62 implementation plan.
This commit is contained in:
xmanrui 2026-08-28 03:01:53 +08:00
parent bf0e157cd4
commit 8c6c31a1b6
23 changed files with 1965 additions and 221 deletions

View file

@ -1,6 +1,7 @@
import { t } from './i18n.mjs';
import { runWorkspaceCommand } from './workspace-command.mjs';
import { runCompactCommand } from './compact-command.mjs';
import { isHistoryCommand, runHistoryCommand } from './history-command.mjs';
import {
isControlCommand,
runControlCommand,
@ -260,7 +261,8 @@ export class TextHarnessBridge {
}
const collectingBatch = normalized.kind === 'direct'
&& this.#batches.status(key).phase === 'collecting';
const commandRunner = collectingBatch || hasInboundFiles(normalized) ? null : isControlCommand(text)
const commandRunner = collectingBatch ? null : isHistoryCommand(text) ? runHistoryCommand
: hasInboundFiles(normalized) ? null : isControlCommand(text)
? runControlCommand
: (isModelCommand(text)
? runModelCommand
@ -417,6 +419,7 @@ export class TextHarnessBridge {
key,
{
signal: this.#signal,
isDirect: message.kind === 'direct',
hasImages: hasInboundImages(message),
hasFiles: hasInboundFiles(message),
pendingInteraction: this.#pendingInteractions.has(key)
@ -529,6 +532,7 @@ export class TextHarnessBridge {
t('直接发送文字、图片或文件即可继续当前会话。'),
t('/new 开启一个全新会话'),
t('/compact 压缩当前会话的较早上下文'),
t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
t('/workspace 工作区绝对路径 切换工作区'),
t('/workspacelist 列出工作区绝对路径'),
t('/sessionlist [工作区序号或绝对路径] 列出会话 ID 和标题'),