-
Notifications
You must be signed in to change notification settings - Fork 1
fix: sync tasks-index format and 3.3.0 protocol for ZCode App session visibility #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -355,10 +355,18 @@ export async function prompt( | |
| server.titleEligibleSessions.has(params.sessionId) && | ||
| !server.sessionTitles.has(params.sessionId) | ||
| ) { | ||
| const title = text.slice(0, 80); | ||
| // Title = first non-empty line of the prompt, truncated to 80 chars. | ||
| // Multi-line prompts must not leak newlines into the session title. | ||
| // Split on any line break (\r\n, \n, \r) so all platforms are covered. | ||
| const title = | ||
| text | ||
| .split(/\r\n|\r|\n/) | ||
| .map((l) => l.trim()) | ||
| .find((l) => l.length > 0) | ||
| ?.slice(0, 80) ?? text.slice(0, 80); | ||
|
Comment on lines
+361
to
+366
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Splitting and mapping the entire prompt text by newlines to find the first non-empty line is highly inefficient and can cause performance bottlenecks or out-of-memory issues when handling very large prompts (e.g., pasted code or logs). Using a regular expression to match the first non-empty line is much more efficient as it avoids scanning or allocating arrays for the entire string. const firstLine = text.match(/^[ \t]*(\S[^\r\n]*)/m)?.[1];
const title = (firstLine ?? text).trim().slice(0, 80); |
||
| server.sessionTitles.set(params.sessionId, title); | ||
| const { updateSessionTitle } = await import("../tasks-index.js"); | ||
| void updateSessionTitle(zcodeSid, title); | ||
| void updateSessionTitle(zcodeSid, title, text); | ||
| await sendSessionUpdate(cx, params.sessionId, { | ||
| sessionUpdate: "session_info_update", | ||
| title, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,8 +85,10 @@ export async function handleSlashCommand( | |
| return ok(`✓ goal set: ${arg}`); | ||
| } | ||
| case "fork": { | ||
| const result = (await fork(server, { sessionId: acpSid })) as { sessionId?: string }; | ||
| return ok(`✓ forked new session: ${result.sessionId ?? "?"}`); | ||
| const result = (await fork(server, { sessionId: acpSid })) as { | ||
| forkedSessionId?: string; | ||
| }; | ||
| return ok(`✓ forked new session: ${result.forkedSessionId ?? "?"}`); | ||
|
Comment on lines
+88
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align the slash command handler to use the mapped const result = (await fork(server, { sessionId: acpSid })) as {
forkedSessionId?: string;
sessionId?: string;
};
return ok(`✓ forked new session: ${result.sessionId ?? result.forkedSessionId ?? "?"}`); |
||
| } | ||
| case "rewind": { | ||
| await rewind(server, { sessionId: acpSid }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ACP specification for
session/forkexpects the response to containsessionIdfor the newly created session. Returning onlyforkedSessionIdfrom ZCode 3.3.0 will break compatibility with standard ACP clients (such as the Zed editor) that look forsessionId. We should mapforkedSessionIdtosessionIdin the returned object to ensure compatibility with both the ACP client and the ZCode backend.