Feature/add auto mode settings and fix bug (#368)

* refactor: 将 convertMessagesToLangfuse 参数类型从 unknown 收窄为联合类型

将 readonly unknown[] 改为 readonly LangfuseInputMessage[],
其中 LangfuseInputMessage = UserMessage | AssistantMessage | ChatCompletionMessageParam,
让调用方获得编译期类型检查。

* fix: 修复 Config 面板第二次进入时左右键无反应的问题

将左右键枚举值切换从依赖 DOM 焦点的 onKeyDown 改为 useKeybindings 系统,
确保按键在任何焦点状态下都能正确响应。同时修复 isSearchMode 初始值和布局问题。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: 修复 PowerShellTool.isSearchOrReadCommand 在 input 为 undefined 时崩溃的问题

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* feat: 添加 RSS 内存指示器并解绑 auto 权限模式与 TRANSCRIPT_CLASSIFIER

- 在 REPL 底栏添加 RSS 内存使用显示,512MB 以下 dimColor,512MB-1GB warning 色,1GB 以上 error 色
- auto 权限模式不再依赖 TRANSCRIPT_CLASSIFIER feature flag,classifier 不可用时 fallback 到 prompting
- Config 面板 defaultPermissionMode 使用类型安全的 permissionModeFromString,显示改用 shortTitle
- bypassPermissions title 缩短为 Bypass 与 shortTitle 一致

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: 同步 permissionModeTitle 测试断言与 bypassPermissions 的新 title 值

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-26 15:43:25 +08:00
committed by GitHub
parent 4591432a1d
commit fc438bd222
11 changed files with 82 additions and 40 deletions

View File

@@ -231,6 +231,7 @@ describe('Langfuse integration', () => {
test('merges assistant tool calls from OpenAI-style array content', async () => {
const { convertMessagesToLangfuse } = await import('../convert.js')
// Content part with embedded tool_calls is non-standard; cast for defensive test
const result = convertMessagesToLangfuse([
{
role: 'assistant',
@@ -255,7 +256,7 @@ describe('Langfuse integration', () => {
},
],
},
])
] as any)
expect(result).toEqual([
{

View File

@@ -10,7 +10,8 @@
* - tool_result blocks → separate { role: 'tool' } messages
*/
import type { AssistantMessage } from 'src/types/message.js'
import type { AssistantMessage, UserMessage } from 'src/types/message.js'
import type { ChatCompletionMessageParam } from 'openai/resources/chat/completions/completions.mjs'
type LangfuseContentPart =
| { type: 'text'; text: string }
@@ -79,6 +80,12 @@ function mergeToolCalls(
return [...merged.values()]
}
/** Union of all message formats accepted by Langfuse converters. */
type LangfuseInputMessage =
| UserMessage
| AssistantMessage
| ChatCompletionMessageParam
/** Normalize a content block into a LangfuseContentPart (non-tool_use, non-tool_result) */
function toContentPart(block: Record<string, unknown>): LangfuseContentPart | null {
const type = block.type as string | undefined
@@ -178,7 +185,7 @@ function toRoleFromWrappedMessage(msg: Record<string, unknown>): 'user' | 'assis
/** Convert internal or OpenAI-style messages → Langfuse input format */
export function convertMessagesToLangfuse(
messages: readonly unknown[],
messages: readonly LangfuseInputMessage[],
systemPrompt?: readonly string[],
): LangfuseChatMessage[] {
const result: LangfuseChatMessage[] = []