Skip to content

Commit 8a3f1ff

Browse files
authored
fix(kap-server): derive session title from first skill slash command (#1741)
1 parent a160915 commit 8a3f1ff

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@moonshot-ai/kimi-code": patch
3+
---
4+
5+
web: Fix the session title not being generated when the first message is a skill slash command.

packages/kap-server/src/routes/skills.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
* `skill_activation` origin. The returned `Turn` handle is
4343
* discarded; clients follow progress via the `skill.activated`
4444
* + `turn.*` events emitted by the service on the WS stream.
45+
* The edge then applies the prompt-metadata update
46+
* (`applyPromptMetadataUpdate`) so a first `/<skill>`
47+
* message titles the session, matching the native RPC path.
4548
*
4649
* **Model projection**: `SkillDefinition` (v2) → protocol `SkillDescriptor`,
4750
* byte-for-byte with v1's `toProtocolSkill`
@@ -72,9 +75,11 @@ import {
7275
IAgentSkillService,
7376
IBootstrapService,
7477
IConfigService,
78+
IEventService,
7579
IPluginService,
7680
ISessionIndex,
7781
ISessionLifecycleService,
82+
ISessionMetadata,
7883
ISessionSkillCatalog,
7984
ISkillCatalogRuntimeOptions,
8085
ISkillDiscovery,
@@ -83,8 +88,10 @@ import {
8388
isError2,
8489
MERGE_ALL_AVAILABLE_SKILLS_SECTION,
8590
SKILL_SOURCE_PRIORITY,
91+
applyPromptMetadataUpdate,
8692
configuredRoots,
8793
projectRoots,
94+
promptMetadataTextFromSkill,
8895
userRoots,
8996
type ISessionScopeHandle,
9097
type Scope,
@@ -284,6 +291,16 @@ export function registerSkillsRoutes(app: SkillsRouteHost, core: Scope): void {
284291
await agent.accessor
285292
.get(IAgentSkillService)
286293
.activate({ name: parsed.id, args: req.body.args });
294+
// Keep the easy-title behavior of the native RPC / TUI path: a first
295+
// `/<skill>` message titles the session (same as routes/prompts.ts).
296+
await applyPromptMetadataUpdate(
297+
{
298+
metadata: resolved.handle.accessor.get(ISessionMetadata),
299+
eventService: core.accessor.get(IEventService),
300+
sessionId: session_id,
301+
},
302+
promptMetadataTextFromSkill({ name: parsed.id, args: req.body.args }),
303+
);
287304
requestLog(req)?.info({ session_id, skill_name: parsed.id }, 'skill activated');
288305
reply.send(okEnvelope({ activated: true, skill_name: parsed.id }, req.id));
289306
} catch (err) {

packages/kap-server/test/skills.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ describe('server-v2 /api/v1 skills', () => {
217217
});
218218
});
219219

220+
it('derives the session title from the first skill activation', async () => {
221+
const id = await createSession();
222+
await createMainAgent(id);
223+
224+
const activated = await postJson<{ activated: boolean; skill_name: string }>(
225+
`/api/v1/sessions/${id}/skills/update-config:activate`,
226+
{ args: '--help' },
227+
);
228+
expect(activated.body.code).toBe(0);
229+
230+
const got = await getJson<{ title: string }>(`/api/v1/sessions/${id}`);
231+
expect(got.body.code).toBe(0);
232+
expect(got.body.data.title).toBe('/update-config --help');
233+
});
234+
220235
it('returns 40415 for an unknown skill', async () => {
221236
const id = await createSession();
222237
await createMainAgent(id);

0 commit comments

Comments
 (0)