Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(tui): Change skill refresh to trigger after user submission instead of command execution

dreamofapsychiccat7ad7c3e1f3f1
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/CommandService.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/CommandService.ts
index a3f4469a64..e473ad14b0 100644
--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/CommandService.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/CommandService.ts
@@ -130,9 +130,6 @@ export class CommandService {
}
async execute(raw: string, ctx: CommandContext): Promise<void> {
- // Refresh the installed-skills cache on every execution for /<skill-name> autocompletion
- await this.refreshSkills(ctx);
-
const parsed = parseSlashCommand(raw.trim(), this.getAll());
const command = parsed.command;
if (!command) {
@@ -148,6 +145,11 @@ export class CommandService {
const query = parsed.args
.replace(new RegExp(`^${skillName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*`, "i"), "")
.trim();
+ if (!query) {
+ const message = "Usage: /<skill-name> <query>"
+ ctx.addItem(makeItem(ctx.sessionId, "error", message));
+ return;
+ }
try {
await useSubCommand.action(ctx, `${skillName}, ${query}`);
} catch (error) {
diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
index fe3eeeb44e..995743d1ab 100644
--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
@@ -535,8 +535,9 @@ export class AppScreen implements Component, Focusable {
this.editor.onChange = () => {
this.tui.requestRender();
};
- this.editor.onSubmit = (value) => {
- void this.handleSubmit(value);
+ this.editor.onSubmit = async (value) => {
+ void await this.handleSubmit(value);
+ void await this.commands.refreshSkills(this.state.getCommandContext());
};
this.unsubscribe = this.state.onChange(() => {
this.handleStateChange();