Skip to content

fix(core): improve conversation delete selectors#966

Merged
dingyi222666 merged 2 commits into
v1-devfrom
fix/delete-conversation
Jul 12, 2026
Merged

fix(core): improve conversation delete selectors#966
dingyi222666 merged 2 commits into
v1-devfrom
fix/delete-conversation

Conversation

@dingyi222666

Copy link
Copy Markdown
Member

This pr improves conversation delete selectors and related resolve handling.

Bug Fixes

  • Parse multi-separator and range selectors for batch conversation delete.
  • Keep title-like inputs from being treated as batch selectors.
  • Support Gemini camel/snake includeServerSideToolInvocations key.

Other Changes

  • Ignore local .opencode workspace files.
  • Move delete selector parsing into shared conversation utils with tests.

Validation

  • yarn lint-fix

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 33e60d74-7dfe-45c3-a914-9b2ed6cd5e78

📥 Commits

Reviewing files that changed from the base of the PR and between 16ffaae and 125e70d.

⛔ Files ignored due to path filters (2)
  • packages/core/src/locales/en-US.yml is excluded by !**/*.yml
  • packages/core/src/locales/zh-CN.yml is excluded by !**/*.yml
📒 Files selected for processing (2)
  • packages/core/src/middlewares/system/conversation_manage.ts
  • packages/core/tests/conversation-resolve.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/core/src/middlewares/system/conversation_manage.ts
  • packages/core/tests/conversation-resolve.spec.ts

Walkthrough

本次变更新增批量删除选择器解析并接入会话删除流程,扩展删除命令文本参数及测试覆盖;同时统一聊天中间件的目标会话解析,并调整 Gemini 工具调用字段名和 Git 忽略规则。

Changes

会话删除流程

Layer / File(s) Summary
批量删除选择器解析
packages/core/src/utils/conversation.ts, packages/core/tests/conversation-utils.spec.ts
新增 parseDeleteSeqs,支持数字、范围、多种分隔符、去重及输入上限校验,并补充测试。
删除命令与删除编排
packages/core/src/commands/conversation.ts, packages/core/src/middlewares/system/conversation_manage.ts, packages/core/src/middlewares/conversation/resolve_conversation.ts, packages/core/tests/conversation-resolve.spec.ts
删除命令参数改为文本类型,删除流程复用选择器解析,并扩展批量删除、部分失败和全失败测试。
聊天目标会话解析
packages/core/src/middlewares/chat/rollback_chat.ts, packages/core/src/middlewares/chat/stop_chat.ts
中间件直接计算目标会话,并将其传入会话解析流程。

Gemini 工具配置

Layer / File(s) Summary
工具调用字段名选择
packages/adapter-gemini/src/utils.ts
Gemini 3 内置工具配置根据驼峰命名设置选择对应的工具调用字段名。

仓库元数据

Layer / File(s) Summary
新增忽略规则
.gitignore
新增 .opencode 忽略条目。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant chatluna_delete
  participant resolve_conversation
  participant parseDeleteSeqs
  participant conversation_manage
  participant deleteConversation
  User->>chatluna_delete: 提交文本删除选择器
  chatluna_delete->>resolve_conversation: 解析删除目标
  resolve_conversation->>parseDeleteSeqs: 解析数字与范围
  parseDeleteSeqs-->>resolve_conversation: 返回序号集合
  resolve_conversation->>conversation_manage: 传递批量删除目标
  conversation_manage->>deleteConversation: 逐项执行删除
  deleteConversation-->>conversation_manage: 返回成功或失败
  conversation_manage-->>User: 返回删除结果
Loading

Possibly related PRs

Poem

小兔敲键盘,选择器跳呀跳,
范围逗号都解析好。
会话目标不迷路,
Gemini 字段换新装,
.opencode 也藏进草。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题简洁且准确概括了会话删除选择器相关的主要改动。
Description check ✅ Passed 描述与此次改动相关,概括了删除选择器解析和相关处理优化。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/delete-conversation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the conversation deletion logic by extracting and enhancing the sequence parsing into a shared utility function parseDeleteSeqs that supports multiple separators and ranges. It also updates the Gemini adapter to dynamically select the key for server-side tool invocations based on camelCase configuration. Feedback is provided regarding a potential ReDoS vulnerability in parseDeleteSeqs where the input length check should be performed before executing the regular expression to prevent performance degradation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/core/src/utils/conversation.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/src/commands/conversation.ts (1)

237-260: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

text 参数会吞掉后置选项。 chatluna.delete 这里把 conversation 改成 text 后,用户如果写成 chatluna.delete 3 -a-a 会被并入参数值,includeArchived 不会生效。需要在帮助里明确要求“先写选项,后写目标”,或提醒用户把文本用引号包起来。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/commands/conversation.ts` around lines 237 - 260,
chatluna.delete 的 text 类型 conversation 参数会吞掉其后的选项,导致 `includeArchived`
等选项失效。更新该命令的帮助文本或使用提示,明确要求用户先写选项再写目标
conversation,或将包含选项的目标文本用引号包裹;保留现有选项解析和删除逻辑不变。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/middlewares/system/conversation_manage.ts`:
- Around line 309-329: Update the batch-delete loop around deleteConversation to
catch errors per target, collecting successful conversation labels and failed
target labels separately instead of letting one exception abort the whole
operation. Build the final context.message using the existing
delete_success_multi/delete_failed messages for all-success/all-failure cases
and the new delete_partial i18n message when both collections are non-empty,
then return the same STOP status.

---

Outside diff comments:
In `@packages/core/src/commands/conversation.ts`:
- Around line 237-260: chatluna.delete 的 text 类型 conversation 参数会吞掉其后的选项,导致
`includeArchived` 等选项失效。更新该命令的帮助文本或使用提示,明确要求用户先写选项再写目标
conversation,或将包含选项的目标文本用引号包裹;保留现有选项解析和删除逻辑不变。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0a45c96a-5ab8-4028-8243-3093088e19f5

📥 Commits

Reviewing files that changed from the base of the PR and between 7d98c20 and 16ffaae.

📒 Files selected for processing (10)
  • .gitignore
  • packages/adapter-gemini/src/utils.ts
  • packages/core/src/commands/conversation.ts
  • packages/core/src/middlewares/chat/rollback_chat.ts
  • packages/core/src/middlewares/chat/stop_chat.ts
  • packages/core/src/middlewares/conversation/resolve_conversation.ts
  • packages/core/src/middlewares/system/conversation_manage.ts
  • packages/core/src/utils/conversation.ts
  • packages/core/tests/conversation-resolve.spec.ts
  • packages/core/tests/conversation-utils.spec.ts

Comment thread packages/core/src/middlewares/system/conversation_manage.ts
@dingyi222666
dingyi222666 merged commit b28b57a into v1-dev Jul 12, 2026
5 checks passed
@dingyi222666
dingyi222666 deleted the fix/delete-conversation branch July 12, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant