fix(cli): aliased clear to new session
Added /clear as a /new alias so exact slash completion outranks /autoresearch description matches. Fixes #5349
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `/clear` autocomplete selecting `/autoresearch`; `/clear` now starts a new session as an alias for `/new` ([#5349](https://github.com/can1357/oh-my-pi/issues/5349))
|
||||
- Fixed `/tan` and `/fork` clones cold-missing the provider prompt cache: the per-turn supersede/useless-result prune rewrote the live context without persisting it, so file-based forks and resume rebuilt a divergent (un-pruned) prefix and re-wrote the entire cache
|
||||
- Fixed `/tan` pinning the clone's prompt-cache key to the parent's session id instead of the parent's effective cache key, dropping shard affinity when the parent was itself a fork or tan
|
||||
- Fixed inconsistent history rendering when toggling the display setting for compacted items
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<system-notice cause="fork">
|
||||
The conversation above belongs to your parent session.
|
||||
The conversation above belongs to your parent session.
|
||||
You are a fork created solely to handle the user's request below.
|
||||
|
||||
Your parent agent is still working on the original task — that responsibility is
|
||||
|
||||
@@ -1384,6 +1384,7 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
|
||||
},
|
||||
{
|
||||
name: "new",
|
||||
aliases: ["clear"],
|
||||
description: "Start a new session",
|
||||
handleTui: async (_command, runtime) => {
|
||||
runtime.ctx.editor.setText("");
|
||||
|
||||
@@ -114,7 +114,7 @@ describe("AgentSession per-turn prune persistence", () => {
|
||||
const message = session.agent.state.messages.find(
|
||||
candidate => candidate.role === "toolResult" && candidate.toolCallId === BIG_CALL_ID,
|
||||
);
|
||||
if (!message || message.role !== "toolResult" || !Array.isArray(message.content)) {
|
||||
if (message?.role !== "toolResult" || !Array.isArray(message.content)) {
|
||||
throw new Error("Expected the seeded tool result in live agent state");
|
||||
}
|
||||
const text = message.content.find(block => block.type === "text");
|
||||
@@ -156,7 +156,7 @@ describe("AgentSession per-turn prune persistence", () => {
|
||||
const rebuilt = reloaded
|
||||
.buildSessionContext()
|
||||
.messages.find(candidate => candidate.role === "toolResult" && candidate.toolCallId === BIG_CALL_ID);
|
||||
if (!rebuilt || rebuilt.role !== "toolResult" || !Array.isArray(rebuilt.content)) {
|
||||
if (rebuilt?.role !== "toolResult" || !Array.isArray(rebuilt.content)) {
|
||||
throw new Error("Expected the seeded tool result in the from-disk rebuild");
|
||||
}
|
||||
const rebuiltText = rebuilt.content.find(block => block.type === "text");
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { BUILTIN_SLASH_COMMANDS } from "@oh-my-pi/pi-coding-agent/slash-commands/builtin-registry";
|
||||
import { CombinedAutocompleteProvider } from "@oh-my-pi/pi-tui/autocomplete";
|
||||
|
||||
describe("/clear slash command alias", () => {
|
||||
it("ranks the new-session action above fuzzy description matches", async () => {
|
||||
const provider = new CombinedAutocompleteProvider([...BUILTIN_SLASH_COMMANDS], process.cwd());
|
||||
|
||||
const suggestions = await provider.getSuggestions(["/clear"], 0, 6);
|
||||
|
||||
expect(suggestions?.items[0]).toMatchObject({
|
||||
value: "clear",
|
||||
description: "Start a new session",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user