Skip to content

refactor(core): consolidate chat session commands under /session#386

Open
huangdijia wants to merge 2 commits intochenhg5:mainfrom
huangdijia:codex/session
Open

refactor(core): consolidate chat session commands under /session#386
huangdijia wants to merge 2 commits intochenhg5:mainfrom
huangdijia:codex/session

Conversation

@huangdijia
Copy link
Copy Markdown
Contributor

Summary

  • add /session as the canonical chat command namespace for session management
  • route help cards and session list card actions through /session ... while keeping old top-level commands compatible
  • update i18n strings and user docs to document session management in second-level form

Background

  • session management commands were split across multiple top-level chat commands (/new, /list, /switch, etc.)
  • this change consolidates the primary UX under /session [sub-cmd] without breaking existing flows

Changes

  • add cmdSession and /session command registration in the engine
  • support /session new|list|search|switch|rename|current|history|delete plus alias handling for name, del, and rm
  • update card navigation and switch actions to use /session ... semantics
  • refresh session-related help, hints, and docs in English and Chinese
  • add regression tests for /session dispatch, aliases, help rendering, and card actions

Test Plan

  • go test ./core -run 'TestCmdSession|TestCmdSwitch|TestRenderHelpCard|TestHandleCardNav_HelpSwitchesTabs|TestRenderListCard_MakesEveryVisibleSessionClickable|TestDeleteMode_CancelReturnsListCard|TestExecuteCardAction_(NewCleansUpAndCreatesSession|SessionNewDelegatesToNew)'
  • go test ./... (currently fails on unrelated existing tests in agent/acp, core, and platform/wecom)

Risks

  • slash-command prefix matching now includes /session, so very short prefixes like /ses are more ambiguous than before
  • card callbacks now depend on /session routing, so session card regressions would show up in help/list/delete flows first

@huangdijia huangdijia marked this pull request as ready for review March 31, 2026 05:52
Copilot AI review requested due to automatic review settings March 31, 2026 05:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates chat session management commands under a canonical /session <subcommand> namespace (while keeping existing top-level commands working), and updates help/cards/docs accordingly.

Changes:

  • Add /session command routing in the core engine, dispatching to existing session commands and handling subcommand aliases (namerename, rm/deldelete).
  • Update help cards, list/delete card actions, and i18n strings to prefer /session ... flows.
  • Update English/Chinese docs plus add regression tests for /session dispatch, aliases, disabled-command policy behavior, and card actions.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Updates documented session commands to /session ....
README.zh-CN.md Same documentation update in Chinese.
docs/usage.md Updates usage guide session command table to /session ....
docs/usage.zh-CN.md Same usage guide update in Chinese.
core/i18n.go Updates help/hints/usage text to reference /session ... paths.
core/engine.go Adds /session command handling + routes card navigation/actions through /session ....
core/engine_test.go Adds tests covering /session dispatch, aliases, policy blocking, and card action updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if len(parts) > 1 {
descKey = parts[1]
}
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

renderHelpGroupCard derives the i18n description key from the second token of /session ... commands (e.g. rename). There is no rename entry in core/i18n.go (builtin descriptions use name), so the help card will render the description as the raw string rename instead of a localized description. Consider mapping renamename here (or adding a dedicated rename message key) so /session rename shows the same localized description as the existing /name command.

Suggested change
}
}
// Normalize subcommand keys that share descriptions with existing commands.
// For example, `/session rename` should use the same description as `/name`.
if descKey == "rename" {
descKey = "name"
}

Copilot uses AI. Check for mistakes.
}{
{[]string{"session"}, "session"},
{[]string{"new"}, "new"},
{[]string{"list", "sessions"}, "list"},
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

Adding the new /session builtin command makes prefix matching ambiguous with the existing /sessions alias for list (and any other se... aliases), because matchPrefix treats aliases and canonical names equally and returns "" on ambiguity. This means prefixes that previously worked (e.g. /ses, /sess/sessions → list) will now fail to resolve. If prefix matching compatibility matters, consider removing/renaming the sessions alias, or changing matchPrefix to prefer canonical names over aliases when resolving prefixes.

Suggested change
{[]string{"list", "sessions"}, "list"},
{[]string{"list"}, "list"},

Copilot uses AI. Check for mistakes.
Comment on lines 3008 to +3013
MsgSearchHint: {
LangEnglish: "Use /switch <id> to switch to a session.",
LangChinese: "使用 /switch <id> 切换到对应会话。",
LangTraditionalChinese: "使用 /switch <id> 切換到對應會話。",
LangJapanese: "/switch <id> でセッションを切り替え。",
LangSpanish: "Usa /switch <id> para cambiar a una sesión.",
LangEnglish: "Use /session switch <id> to switch to a session.",
LangChinese: "使用 /session switch <id> 切换到对应会话。",
LangTraditionalChinese: "使用 /session switch <id> 切換到對應會話。",
LangJapanese: "/session switch <id> でセッションを切り替え。",
LangSpanish: "Usa /session switch <id> para cambiar a una sesión.",
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

MsgSearchHint was updated to point users to /session switch ..., but MsgSearchUsage (shown when /session search is invoked without args) still says Usage: /search <keyword>. That makes the UX inconsistent with the new “/session … is canonical” documentation. Consider updating MsgSearchUsage to mention /session search (optionally also noting /search remains a compatible alias).

Copilot uses AI. Check for mistakes.
Comment on lines +3326 to +3331
e.cmdList(p, msg, subArgs)
case "search":
e.cmdSearch(p, msg, subArgs)
case "switch":
e.cmdSwitch(p, msg, subArgs)
case "rename":
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

/session search and /session switch delegate to cmdSearch/cmdSwitch, but their usage/help strings still reference the legacy top-level commands (Usage: /search ... via MsgSearchUsage, and the hardcoded Usage: /switch ...). When users run /session search or /session switch incorrectly (e.g. missing args), the reply will contradict the new “/session … is canonical” docs. Consider updating those usage messages to mention /session search and /session switch (optionally keeping the old forms as aliases).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

@chenhg5 chenhg5 left a comment

Choose a reason for hiding this comment

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

LGTM. Good UX consolidation.

Review summary:

  • /session as canonical namespace for session management
  • ✅ Backward compatible with existing top-level commands
  • ✅ i18n strings updated
  • ✅ Card navigation updated
  • ✅ Tests added
  • ✅ CI passes

Clean organization of session-related commands.

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.

3 participants