Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(session-titles): restore the first-prompt title fallback
vastsa41a8461c893a
diff --git a/apps/desktop/electron/main/ipc/session-ipc.ts b/apps/desktop/electron/main/ipc/session-ipc.tsindex 5fb41a095..deb4b9cff 100644--- a/apps/desktop/electron/main/ipc/session-ipc.ts+++ b/apps/desktop/electron/main/ipc/session-ipc.ts@@ -356,6 +356,15 @@ export function registerSessionIpc({if (!host) throw new Error("host unavailable");return host.call("session.rename", { id, title });});+ handle(IPC.invoke.sessionDeriveTitle, async (id: string, title: string) => {+ if (id.startsWith("native-pi:")) {+ throw Object.assign(new Error("Native Pi session title derivation is not supported"), {+ errorCode: ErrorCodes.INVALID_ARGUMENT,+ });+ }+ if (!host) throw new Error("host unavailable");+ return host.call("session.deriveTitle", { id, title });+ });handle(IPC.invoke.sessionMoveProject,async (input: { sessionId?: string; projectPath?: string } = {}) => {diff --git a/apps/desktop/electron/main/remote/remote-backend.ts b/apps/desktop/electron/main/remote/remote-backend.tsindex 434be13e5..9654683e6 100644--- a/apps/desktop/electron/main/remote/remote-backend.ts+++ b/apps/desktop/electron/main/remote/remote-backend.ts@@ -76,6 +76,7 @@ const HANDLED_CHANNELS: ReadonlySet<string> = new Set([IPC.invoke.sessionConfigure,IPC.invoke.sessionFork,IPC.invoke.sessionRename,+ IPC.invoke.sessionDeriveTitle,IPC.invoke.sessionDelete,IPC.invoke.toolResolvePermission,IPC.invoke.askToolResolve,@@ -288,6 +289,14 @@ export function createRemoteBackend(options: RemoteBackendOptions): RemoteBackenawait client.request("session/rename", { sessionId: hostIdFor(args), title });return { ok: true };}+ case IPC.invoke.sessionDeriveTitle: {+ const title = args[1] as string;+ const result = await client.request<{ updated?: boolean }>("session/deriveTitle", {+ sessionId: hostIdFor(args),+ title,+ });+ return { updated: result.updated === true };+ }case IPC.invoke.sessionDelete: {await client.request("session/delete", { sessionId: hostIdFor(args) });return { ok: true };diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.tsindex 4b2c420f9..b2814171e 100644--- a/apps/desktop/src/lib/api.ts+++ b/apps/desktop/src/lib/api.ts@@ -621,6 +621,9 @@ export const api = {invoke<{ ok: boolean; path: string }>(IPC.invoke.projectOpenFolder, path),renameSession: (id: string, title: string) =>invoke<{ ok: boolean }>(IPC.invoke.sessionRename, id, title),+ /** Ask the host for a first-prompt title; it refuses a renamed session. */+ deriveSessionTitle: (id: string, title: string) =>+ invoke<{ updated: boolean }>(IPC.invoke.sessionDeriveTitle, id, title),moveSessionProject: (sessionId: string, projectPath: string) =>invoke<{ session: SessionSummary }>(IPC.invoke.sessionMoveProject, {sessionId,diff --git a/apps/desktop/src/lib/session-title-utils.ts b/apps/desktop/src/lib/session-title-utils.tsindex 0cad126df..ce856512f 100644--- a/apps/desktop/src/lib/session-title-utils.ts+++ b/apps/desktop/src/lib/session-title-utils.ts@@ -1,8 +1,35 @@import i18n from "i18next";-const LEGACY_DEFAULT_TITLES = new Set(["new task", "new chat", "新建任务", "新对话"]);+/**+ * Every shipped `chat.untitledTask` / `nav.newChat` label plus their historical+ * forms, so a placeholder is recognized regardless of the active locale. Kept in+ * sync with `PLACEHOLDER_TITLES` in `crates/host-core/src/sessions.rs`.+ */+const LEGACY_DEFAULT_TITLES = new Set([+ "new task",+ "new chat",+ "新建任务",+ "新对话",+ "新建任務",+ "新對話",+ "새 작업",+ "새 채팅",+ "tarefa sem título",+ "nova conversa",+ "yeni görev",+ "yeni sohbet",+]);+/** Sidebar/topbar title budget for the local first-prompt fallback. */+const PROMPT_FALLBACK_TITLE_LENGTH = 48;export function untitledTaskTitle(): string {- return i18n.t("chat.untitledTask");+ return translatedTitle("chat.untitledTask");+}++/// A missing or not-yet-initialized catalog must never break the composer+/// path that checks whether a session still carries a placeholder title.+function translatedTitle(key: string): string {+ const value = i18n.t(key);+ return typeof value === "string" ? value.trim().toLowerCase() : "";}export function isDefaultSessionTitle(title?: string | null): boolean {@@ -10,7 +37,22 @@ export function isDefaultSessionTitle(title?: string | null): boolean {return (!trimmed ||LEGACY_DEFAULT_TITLES.has(trimmed) ||- trimmed === untitledTaskTitle().toLowerCase() ||- trimmed === i18n.t("nav.newChat").toLowerCase()+ trimmed === untitledTaskTitle() ||+ trimmed === translatedTitle("nav.newChat")+ );+}++/**+ * Deterministic title for the first prompt of a still-untitled session.+ * The host keeps the session eligible for an automatic plugin title, so this+ * text is only the immediate, offline-readable fallback.+ */+export function promptFallbackSessionTitle(+ userPrompt: string,+ emptyTitle: string,+): string {+ return (+ userPrompt.trim().replace(/\s+/g, " ").slice(0, PROMPT_FALLBACK_TITLE_LENGTH) ||+ emptyTitle);}diff --git a/apps/desktop/src/stores/slices/queue-slice.ts b/apps/desktop/src/stores/slices/queue-slice.tsindex e75de35b5..be005476d 100644--- a/apps/desktop/src/stores/slices/queue-slice.ts+++ b/apps/desktop/src/stores/slices/queue-slice.ts@@ -23,6 +23,11 @@ import type {ComposerPrefill,} from "../../lib/composer-smart-stop";import { optimisticUserMessage } from "../../lib/session-transcript";+import {+ isDefaultSessionTitle,+ promptFallbackSessionTitle,+ untitledTaskTitle,+} from "../../lib/session-title-utils";import type { AppState } from "../app-state";import {type SessionRuntime,@@ -434,6 +439,26 @@ export function createQueueSlice({);runtime.insertOptimisticUserMessage(startedIn, optimisticMessage);const current = get().sessions.find((session) => session.id === sessionId);+ // Keeps the session readable without any plugin: the owning host derives+ // a short title from this prompt but leaves it replaceable, so an+ // installed title plugin can still upgrade it after the first turn. A+ // remote session derives on its own host, and the host refuses the write+ // once the session was renamed. A native Pi session owns its title+ // outside this host, so it keeps whatever that surface shows.+ if (+ isDefaultSessionTitle(current?.title) &&+ current?.source !== "pi-native"+ ) {+ const nextTitle = promptFallbackSessionTitle(content, untitledTaskTitle());+ if (!isDefaultSessionTitle(nextTitle)) {+ api+ .deriveSessionTitle(sessionId, nextTitle)+ .then(() => get().refreshSessions())+ .catch(() => {+ // Non-fatal title fallback.+ });+ }+ }try {if (get().pendingPlans[sessionId]?.status === "pending") {runtime.submittedComposerDrafts.delete(startedIn);diff --git a/apps/desktop/test/queue-pending-actions.test.mjs b/apps/desktop/test/queue-pending-actions.test.mjsindex 14c6faa87..30d501ff1 100644--- a/apps/desktop/test/queue-pending-actions.test.mjs+++ b/apps/desktop/test/queue-pending-actions.test.mjs@@ -6,7 +6,7 @@ import { renderToStaticMarkup } from "react-dom/server";import { createServer } from "vite";import { IPC } from "@pi-desktop/shared";-test("sending the first prompt keeps the default session title for the title plugin", async (t) => {+test("sending the first prompt derives a replaceable title instead of renaming", async (t) => {const server = await createServer({root: fileURLToPath(new URL("..", import.meta.url)),configFile: false,@@ -18,10 +18,12 @@ test("sending the first prompt keeps the default session title for the title plutry {const { createQueueSlice } = await server.ssrLoadModule("/src/stores/slices/queue-slice.ts");const invoked = [];- globalThis.window = { piDesktop: { invoke: async (channel, payload) => {- invoked.push([channel, payload]);- if (channel !== IPC.invoke.agentPrompt) throw new Error(`Unexpected IPC: ${channel}`);- return { ok: true, data: { turnId: "turn-1" } };+ let refreshed = 0;+ globalThis.window = { piDesktop: { invoke: async (channel, ...args) => {+ invoked.push([channel, ...args]);+ if (channel === IPC.invoke.agentPrompt) return { ok: true, data: { turnId: "turn-1" } };+ if (channel === IPC.invoke.sessionDeriveTitle) return { ok: true, data: { updated: true } };+ throw new Error(`Unexpected IPC: ${channel}`);} } };let state = {activeSessionId: "session-a",@@ -33,6 +35,9 @@ test("sending the first prompt keeps the default session title for the title plusessionOutcomes: {},showToast: assert.fail,rememberModel() {},+ refreshSessions: async () => {+ refreshed += 1;+ },};const runtime = {submittedComposerDrafts: new Map(),@@ -60,8 +65,17 @@ test("sending the first prompt keeps the default session title for the title plu});assert.equal(await slice.sendPrompt("Summarize the first turn", undefined, "session-a"), true);+ // The host, not the renderer, owns the title: the sidebar keeps the+ // placeholder until the derived title comes back, and the rename path stays+ // unused so an installed title plugin can still replace the derived text.assert.equal(state.sessions[0].title, "New task");- assert.deepEqual(invoked.map(([channel]) => channel), [IPC.invoke.agentPrompt]);+ assert.deepEqual(+ invoked.filter(([channel]) => channel === IPC.invoke.sessionDeriveTitle),+ [[IPC.invoke.sessionDeriveTitle, "session-a", "Summarize the first turn"]],+ );+ assert.equal(invoked.some(([channel]) => channel === IPC.invoke.sessionRename), false);+ await new Promise((resolve) => setImmediate(resolve));+ assert.equal(refreshed, 1);} finally {globalThis.window = previousWindow;await server.close();diff --git a/apps/desktop/test/remote-backend.test.mjs b/apps/desktop/test/remote-backend.test.mjsindex 8e2b3ea89..6c09952b1 100644--- a/apps/desktop/test/remote-backend.test.mjs+++ b/apps/desktop/test/remote-backend.test.mjs@@ -142,6 +142,7 @@ test("handles() covers exactly the channels the remote profile serves", () => {IPC.invoke.sessionConfigure,IPC.invoke.sessionFork,IPC.invoke.sessionRename,+ IPC.invoke.sessionDeriveTitle,IPC.invoke.sessionDelete,IPC.invoke.toolResolvePermission,IPC.invoke.askToolResolve,@@ -352,6 +353,27 @@ test("sessionRename / sessionDelete forward positional args", async () => {assert.deepEqual(client.calls[1].params, { sessionId: HOST_SESSION_ID });});+test("sessionDeriveTitle asks the host and reports whether it applied the title", async () => {+ const applied = makeBackend({ "session/deriveTitle": () => ({ updated: true }) });+ const result = await applied.backend.invoke(IPC.invoke.sessionDeriveTitle, [+ REMOTE_SESSION_ID,+ "First prompt label",+ ]);+ assert.deepEqual(applied.client.calls[0].params, {+ sessionId: HOST_SESSION_ID,+ title: "First prompt label",+ });+ assert.deepEqual(result, { updated: true });++ // The host refuses a renamed session; the renderer must see the refusal.+ const refused = makeBackend({ "session/deriveTitle": () => ({}) });+ const refusedResult = await refused.backend.invoke(IPC.invoke.sessionDeriveTitle, [+ REMOTE_SESSION_ID,+ "First prompt label",+ ]);+ assert.deepEqual(refusedResult, { updated: false });+});+test("toolResolvePermission decodes the encoded requestId back to the host approval id", async () => {const requestId = makeRemoteApprovalRequestId(REMOTE_SESSION_ID, "approval-77");const { backend, client } = makeBackend({diff --git a/apps/desktop/test/session-title-prompt-fallback.test.mjs b/apps/desktop/test/session-title-prompt-fallback.test.mjsnew file mode 100644index 000000000..d884bf77a--- /dev/null+++ b/apps/desktop/test/session-title-prompt-fallback.test.mjs@@ -0,0 +1,95 @@+/**+ * Automatic session titles have two layers: host-core derives a deterministic+ * title from the first prompt so a new session is readable offline, and an+ * optional title plugin may later upgrade it with a model-composed title.+ * These tests lock both halves and the boundary between them.+ */+import { readMainSource, readStoreSource } from "./helpers/source-contracts.mjs";+import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import test from "node:test";+import i18n from "i18next";+import { catalogs } from "@pi-desktop/i18n";+import {+ isDefaultSessionTitle,+ promptFallbackSessionTitle,+ untitledTaskTitle,+} from "../src/lib/session-title-utils.ts";++// The helper reads the app's i18n singleton, so initialize it with the real+// English catalog instead of leaving `t()` returning keys.+await i18n.init({+ lng: "en",+ resources: { en: { translation: catalogs.en } },+});+const read = (path) => readFile(new URL(path, import.meta.url), "utf8");+const [api, protocol, host, rpc, queueSlice, main, store] = await Promise.all([+ read("../src/lib/api.ts"),+ read("../../../packages/shared/src/protocol.ts"),+ read("../../../crates/host-core/src/sessions.rs"),+ read("../../../crates/host-core/src/rpc/mod.rs"),+ read("../src/stores/slices/queue-slice.ts"),+ readMainSource(),+ readStoreSource(),+]);++test("the first prompt becomes an immediate title, collapsed and capped", () => {+ assert.equal(promptFallbackSessionTitle(" Fix\n the\tlogin ", "New task"), "Fix the login");+ assert.equal(promptFallbackSessionTitle("p".repeat(60), "New task"), "p".repeat(48));+ assert.equal(promptFallbackSessionTitle(" ", "New task"), "New task");+ assert.equal(promptFallbackSessionTitle("界".repeat(60), "New task"), "界".repeat(48));+});++test("the fallback only fires for a still-untitled local session", () => {+ assert.equal(isDefaultSessionTitle(promptFallbackSessionTitle("Fix login", "New task")), false);+ assert.equal(isDefaultSessionTitle(untitledTaskTitle()), true);+ // A placeholder is recognized in every shipped locale, not just the active one.+ for (const placeholder of [+ "새 작업",+ "新建任務",+ "Tarefa sem título",+ "Yeni görev",+ "New chat",+ ]) {+ assert.equal(isDefaultSessionTitle(placeholder), true, placeholder);+ }+ assert.match(queueSlice, /isDefaultSessionTitle\(current\?\.title\)/);+ assert.match(queueSlice, /current\?\.source !== "pi-native"/);+ // A remote session derives on its own host, so the gate does not exclude it.+ assert.doesNotMatch(+ queueSlice,+ /isDefaultSessionTitle\(current\?\.title\)[\s\S]{0,140}source !== "remote"/,+ );+ assert.match(queueSlice, /api\s+\.deriveSessionTitle\(sessionId, nextTitle\)/);+ assert.match(queueSlice, /if \(!isDefaultSessionTitle\(nextTitle\)\)/);+});++test("the fallback travels the existing ipc bridge into host-core", () => {+ assert.match(protocol, /sessionDeriveTitle: "pi-desktop\/session\/deriveTitle"/);+ assert.match(api, /invoke<\{ updated: boolean \}>\(IPC\.invoke\.sessionDeriveTitle, id, title\)/);+ assert.match(main, /handle\(IPC\.invoke\.sessionDeriveTitle/);+ assert.match(main, /host\.call\("session\.deriveTitle", \{ id, title \}\)/);+ assert.match(rpc, /"session\.deriveTitle" => \{/);+ assert.match(rpc, /sessions::derive_session_title\(&st\.db, id, &title\)/);+});++test("host-core keeps a derived title replaceable and never touches a named one", () => {+ const deriveStart = host.indexOf("pub fn derive_session_title");+ const deriveBody = host.slice(deriveStart, host.indexOf("pub fn auto_title_context"));+ assert.ok(deriveStart > 0, "derive_session_title must exist");+ // The derived text must stay an automatic title: a plugin may still replace+ // it, so only the title moves and the source stays `default`.+ assert.match(deriveBody, /UPDATE sessions SET title = \?1/);+ assert.doesNotMatch(deriveBody, /title_source = \?1/);+ assert.doesNotMatch(deriveBody, /TITLE_SOURCE_MANUAL/);+ assert.match(deriveBody, /AND title = \?3 AND title_source = \?4 AND deleted_at IS NULL/);+ assert.match(deriveBody, /title_source != TITLE_SOURCE_DEFAULT \|\| !is_default_title\(¤t_title\)/);+ assert.match(host, /fn derived_prompt_title_stays_eligible_for_the_title_plugin/);+ assert.match(host, /fn derived_prompt_title_never_overrides_named_sessions/);+});++test("automatic AI titles stay plugin-owned", () => {+ assert.doesNotMatch(api, /summarizeSessionTitle/);+ assert.doesNotMatch(store, /triggerAutoTitleSummarization/);+ assert.doesNotMatch(main, /IPC\.invoke\.sessionSummarizeTitle/);+});diff --git a/apps/pi-host/src/host-operations.ts b/apps/pi-host/src/host-operations.tsindex b8b1ae965..b92965cdc 100644--- a/apps/pi-host/src/host-operations.ts+++ b/apps/pi-host/src/host-operations.ts@@ -143,6 +143,12 @@ export function createSessionCatalog(deps: HostOperationsDeps): RacpSessionCatalasync rename(sessionId, title) {await requireHost(getHost).call("session.rename", { id: sessionId, title }).catch(hostError);},+ async deriveTitle(sessionId, title) {+ const result = await requireHost(getHost)+ .call<{ updated?: boolean }>("session.deriveTitle", { id: sessionId, title })+ .catch(hostError);+ return result.updated === true;+ },async delete(sessionId) {if (deps.runtime.isBusy(sessionId)) throw new RacpError("CONFLICT", "the session has an active turn");await requireHost(getHost).call("session.delete", { id: sessionId }).catch(hostError);diff --git a/crates/host-core/src/db/session_title_source_migration.rs b/crates/host-core/src/db/session_title_source_migration.rsindex d301aa9a1..8c853a6a8 100644--- a/crates/host-core/src/db/session_title_source_migration.rs+++ b/crates/host-core/src/db/session_title_source_migration.rs@@ -14,11 +14,16 @@ fn migrate_v22_to_v23_tx(tx: &Transaction<'_>) -> Result<()> {)?;// Older releases stored default and manually-entered titles in the// same column. Preserve the distinction where it is observable: only- // known placeholders remain eligible for the standalone title plugin;- // every other pre-existing title is treated as manual.+ // known placeholders remain eligible for automatic replacement; every+ // other pre-existing title is treated as manual. The list mirrors+ // `sessions::PLACEHOLDER_TITLES` and covers the localized+ // `chat.untitledTask` / `nav.newChat` labels the renderer writes.tx.execute("UPDATE sessions SET title_source = CASE- WHEN title IN ('', 'New task', 'New chat', '新建任务', '新对话') THEN 'default'+ WHEN title IN ('', 'New task', 'New chat', '新建任务', '新对话',+ '新建任務', '新對話', '새 작업', '새 채팅',+ 'Tarefa sem título', 'Nova conversa',+ 'Yeni görev', 'Yeni sohbet') THEN 'default'ELSE 'manual'END",[],diff --git a/crates/host-core/src/db/tests.rs b/crates/host-core/src/db/tests.rsindex ce6e508df..c4468c867 100644--- a/crates/host-core/src/db/tests.rs+++ b/crates/host-core/src/db/tests.rs@@ -126,10 +126,14 @@ fn v18_database_migrates_session_thinking_omit() {fn v22_database_migrates_session_title_sources_without_losing_titles() {let dir = tempfile::tempdir().unwrap();let path = dir.path().join("pi.sqlite");- let (default_id, manual_id) = {+ let (default_id, localized_id, manual_id) = {let db = Database::open(&path).unwrap();let default_session =crate::sessions::create_session(&db, None, None, None, None, None).unwrap();+ // A v22 install wrote the active locale's placeholder into the title.+ let localized_session =+ crate::sessions::create_session(&db, Some("새 작업".into()), None, None, None, None)+ .unwrap();let manual_session = crate::sessions::create_session(&db,Some("A title chosen by the user".into()),@@ -143,23 +147,27 @@ fn v22_database_migrates_session_title_sources_without_losing_titles() {.execute_batch("ALTER TABLE sessions DROP COLUMN title_source;").unwrap();db.conn().pragma_update(None, "user_version", 22).unwrap();- (default_session.id, manual_session.id)+ (default_session.id, localized_session.id, manual_session.id)};let db = Database::open(&path).unwrap();assert_eq!(schema_version(db.conn()), SCHEMA_VERSION);assert!(migration_backup_path(&path, 22).exists());- let sources: (String, String) = db+ let sources: (String, String, String) = db.conn().query_row("SELECT(SELECT title_source FROM sessions WHERE id = ?1),- (SELECT title_source FROM sessions WHERE id = ?2)",- params![default_id, manual_id],- |row| Ok((row.get(0)?, row.get(1)?)),+ (SELECT title_source FROM sessions WHERE id = ?2),+ (SELECT title_source FROM sessions WHERE id = ?3)",+ params![default_id, localized_id, manual_id],+ |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?)),).unwrap();- assert_eq!(sources, ("default".into(), "manual".into()));+ assert_eq!(+ sources,+ ("default".into(), "default".into(), "manual".into())+ );assert_eq!(crate::sessions::get_session(&db, &manual_id).unwrap()diff --git a/crates/host-core/src/rpc/mod.rs b/crates/host-core/src/rpc/mod.rsindex be54d7f86..1bb4e289a 100644--- a/crates/host-core/src/rpc/mod.rs+++ b/crates/host-core/src/rpc/mod.rs@@ -2640,6 +2640,22 @@ async fn handle_request(.map_err(|e| rpc_err(1000, e.to_string(), "INTERNAL"))?;Ok(json!({ "ok": ok }))}+ "session.deriveTitle" => {+ let id = params+ .get("id")+ .and_then(|v| v.as_str())+ .ok_or_else(|| rpc_err(1002, "id required", "INVALID_PARAMS"))?;+ let title = params+ .get("title")+ .and_then(|v| v.as_str())+ .ok_or_else(|| rpc_err(1002, "title required", "INVALID_PARAMS"))?;+ let title = sessions::normalize_session_title(title)+ .map_err(|e| rpc_err(1002, e.to_string(), "INVALID_PARAMS"))?;+ let st = state.lock().await;+ let updated = sessions::derive_session_title(&st.db, id, &title)+ .map_err(|e| rpc_err(1000, e.to_string(), "INTERNAL"))?;+ Ok(json!({ "updated": updated }))+ }"session.appendMessage" => {let session_id = params.get("sessionId")diff --git a/crates/host-core/src/sessions.rs b/crates/host-core/src/sessions.rsindex 6dd1fa1f5..5d028bb86 100644--- a/crates/host-core/src/sessions.rs+++ b/crates/host-core/src/sessions.rs@@ -334,11 +334,33 @@ pub struct SearchHit {pub created_at: String,}+/// Titles the app writes for a session the user has not named yet.+///+/// The renderer creates a session with its localized `chat.untitledTask` label+/// and also recognizes `nav.newChat`, so host-core has to recognize the same+/// values: it owns title eligibility and cannot read the renderer catalog when+/// it decides whether a title may still be replaced. German, Spanish, and+/// French fall back to the English label. Keep this in sync with the migration+/// list in `db/session_title_source_migration.rs` and `LEGACY_DEFAULT_TITLES`+/// in the renderer.+const PLACEHOLDER_TITLES: [&str; 13] = [+ "",+ "New task",+ "New chat",+ "新建任务",+ "新对话",+ "新建任務",+ "新對話",+ "새 작업",+ "새 채팅",+ "Tarefa sem título",+ "Nova conversa",+ "Yeni görev",+ "Yeni sohbet",+];+fn is_default_title(title: &str) -> bool {- matches!(- title.trim(),- "" | "New task" | "New chat" | "新建任务" | "新对话"- )+ PLACEHOLDER_TITLES.contains(&title.trim())}// ---- UiMessage ⇄ transcript record mapping -----------------------------------@@ -1930,6 +1952,42 @@ pub fn rename_session(db: &Database, id: &str, title: &str) -> Result<bool> {Ok(n > 0)}+/// Replace a still-untitled session's placeholder with text derived from its+/// first prompt.+///+/// This is the deterministic local fallback that keeps a new session readable+/// without any plugin. It deliberately keeps the `default` title source: the+/// derived text was not chosen by the user, so an installed title plugin may+/// still upgrade it through `set_automatic_session_title`. The write only+/// applies while host-core still sees a recognized placeholder, so a manual+/// rename, a plugin-generated title, or an earlier derivation all win.+pub fn derive_session_title(db: &Database, id: &str, title: &str) -> Result<bool> {+ let title = normalize_session_title(title)?;+ let current: Option<(String, String)> = db+ .conn()+ .query_row(+ "SELECT title, title_source FROM sessions+ WHERE id = ?1 AND deleted_at IS NULL",+ params![id],+ |row| Ok((row.get(0)?, row.get(1)?)),+ )+ .optional()?;+ let Some((current_title, title_source)) = current else {+ return Ok(false);+ };+ if title_source != TITLE_SOURCE_DEFAULT || !is_default_title(¤t_title) {+ return Ok(false);+ }+ let n = db+ .conn()+ .prepare_cached(+ "UPDATE sessions SET title = ?1+ WHERE id = ?2 AND title = ?3 AND title_source = ?4 AND deleted_at IS NULL",+ )?+ .execute(params![title, id, current_title, TITLE_SOURCE_DEFAULT])?;+ Ok(n > 0)+}+/// Return only the first-turn text needed to name an untouched session./// The dedicated plugin API must not become a transcript-reading shortcut.pub fn auto_title_context(db: &Database, id: &str) -> Result<Option<AutoTitleContext>> {@@ -4696,6 +4754,120 @@ mod tests {assert!(!rename_session(&db, "missing", "Valid").unwrap());}+ #[test]+ fn derived_prompt_title_stays_eligible_for_the_title_plugin() {+ let db = test_db();+ let session = create_session(&db, None, None, None, None, None).unwrap();+ append_message(+ &db,+ &session.id,+ &user_msg("user-1", "Fix the login button", "2026-01-01T00:00:01Z"),+ None,+ )+ .unwrap();+ let before: i64 = db+ .conn()+ .query_row(+ "SELECT updated_at FROM sessions WHERE id = ?1",+ params![session.id],+ |row| row.get(0),+ )+ .unwrap();++ assert!(derive_session_title(&db, &session.id, "Fix login bug").unwrap());+ let derived = get_session(&db, &session.id).unwrap().unwrap();+ assert_eq!(derived.summary.title, "Fix login bug");+ let after: i64 = db+ .conn()+ .query_row(+ "SELECT updated_at FROM sessions WHERE id = ?1",+ params![session.id],+ |row| row.get(0),+ )+ .unwrap();+ assert_eq!(after, before);++ // The derived text is still an automatic title: the plugin reads it as+ // the expected title and may replace it.+ let context = auto_title_context(&db, &session.id).unwrap().unwrap();+ assert_eq!(context.expected_title, "Fix login bug");+ assert_eq!(context.user_prompt, "Fix the login button");+ assert!(+ set_automatic_session_title(&db, &session.id, "Fix login bug", "Login fix").unwrap()+ );+ assert_eq!(+ get_session(&db, &session.id)+ .unwrap()+ .unwrap()+ .summary+ .title,+ "Login fix"+ );+ assert!(auto_title_context(&db, &session.id).unwrap().is_none());+ }++ #[test]+ fn derived_prompt_title_never_overrides_named_sessions() {+ let db = test_db();+ let manual = create_session(&db, None, None, None, None, None).unwrap();+ assert!(rename_session(&db, &manual.id, "Picked by user").unwrap());+ assert!(!derive_session_title(&db, &manual.id, "First prompt").unwrap());+ assert_eq!(+ get_session(&db, &manual.id).unwrap().unwrap().summary.title,+ "Picked by user"+ );++ let generated = create_session(&db, None, None, None, None, None).unwrap();+ assert!(set_automatic_session_title(&db, &generated.id, "New task", "Generated").unwrap());+ assert!(!derive_session_title(&db, &generated.id, "First prompt").unwrap());++ let named =+ create_session(&db, Some("Named up front".into()), None, None, None, None).unwrap();+ assert!(!derive_session_title(&db, &named.id, "First prompt").unwrap());++ let returned = create_session(&db, None, None, None, None, None).unwrap();+ assert!(derive_session_title(&db, &returned.id, "First prompt").unwrap());+ assert!(!derive_session_title(&db, &returned.id, "Second prompt").unwrap());+ assert_eq!(+ get_session(&db, &returned.id)+ .unwrap()+ .unwrap()+ .summary+ .title,+ "First prompt"+ );++ assert!(!derive_session_title(&db, "missing", "First prompt").unwrap());+ assert!(derive_session_title(&db, &returned.id, " ").is_err());+ }++ #[test]+ fn localized_placeholder_titles_accept_the_first_prompt_fallback() {+ let db = test_db();+ for placeholder in [+ "새 작업",+ "新建任務",+ "Tarefa sem título",+ "Yeni görev",+ "New chat",+ ] {+ let session =+ create_session(&db, Some(placeholder.into()), None, None, None, None).unwrap();+ assert!(+ derive_session_title(&db, &session.id, "Derived label").unwrap(),+ "{placeholder} must accept the first-prompt fallback"+ );+ assert_eq!(+ get_session(&db, &session.id)+ .unwrap()+ .unwrap()+ .summary+ .title,+ "Derived label"+ );+ }+ }+#[test]fn auto_title_context_is_limited_to_the_first_turn_and_bounded() {let db = test_db();diff --git a/docs/adr/0143-user-renamable-session-titles.md b/docs/adr/0143-user-renamable-session-titles.mdindex e5e83a578..49fff03cf 100644--- a/docs/adr/0143-user-renamable-session-titles.md+++ b/docs/adr/0143-user-renamable-session-titles.md@@ -22,8 +22,10 @@ same rules so direct IPC callers cannot persist invalid titles.Renaming updates `sessions.title` and marks its host-owned `title_source` as`manual`. It does not modify the transcript, message count, project binding,empty-session predicate, or `updated_at` activity timestamp. Plugin-generated-titles use a compare-and-set against the default title, so a manual rename wins-a race without renderer-local title state.+titles use a compare-and-set against the automatic title, so a manual rename+wins a race without renderer-local title state. The core's own first-prompt+fallback keeps that source `default` and stays replaceable, which is why only a+`manual` title opts out of automatic replacement.Historical notification title snapshots remain unchanged. Newly renderedsurfaces read the current session summary, so the renamed title is shown in thediff --git a/docs/adr/0186-session-auto-title-summary.md b/docs/adr/0186-session-auto-title-summary.mdindex dedd106bb..15a6c5be8 100644--- a/docs/adr/0186-session-auto-title-summary.md+++ b/docs/adr/0186-session-auto-title-summary.md@@ -13,7 +13,9 @@ renderer or changing host-owned session storage.## Decision (historical)Keep the normalized first-prompt fallback synchronous from the renderer's point-of view. After the initial turn emits `agent_end`, the renderer calls the+of view. (D654 later restored that fallback as a host-owned write; only the+one-shot completion below stays removed.) After the initial turn emits+`agent_end`, the renderer calls theallowlisted `session/summarizeTitle` IPC. Electron validates the session andprompt, resolves the session's effective provider/model, and invokes theagent-runtime `summarizeSessionTitle` one-shot with thinking disabled. Thediff --git a/docs/adr/0323-plugin-owned-session-titles.md b/docs/adr/0323-plugin-owned-session-titles.mdindex 7ad0a966b..7ceece130 100644--- a/docs/adr/0323-plugin-owned-session-titles.md+++ b/docs/adr/0323-plugin-owned-session-titles.md@@ -3,6 +3,7 @@- Status: Accepted- Date: 2026-10-08- Supersedes: ADR 0186+- Amended: 2026-10-08 (D654 restores the deterministic first-prompt fallback)## Context@@ -16,19 +17,31 @@ The plugin still needs a safe way to name a normal Desktop session. Existingplugin session reads are limited to sessions imported by that plugin, while thegeneral transcript API is intentionally too broad for this task.+Removing every automatic write, however, also removed the deterministic label a+new session got from its first prompt. That label costs no model call and makes+an untouched session readable offline, so it stays in the core; only the+model-composed title moves to the plugin.+## Decision-- Remove core prompt-derived fallback titles and the built-in title one-shot.- New sessions keep their localized default title until the user renames them- or an installed plugin updates them.+- Keep one deterministic core title path: sending the first prompt into a+ session whose stored title is still a recognized placeholder writes a+ whitespace-collapsed, 48-character fallback through the host's+ `session.deriveTitle`. The host applies it only while the title is still a+ placeholder with the `default` source, so a manual rename or an earlier+ automatic title always wins, and the write never changes `updated_at`.+- The derived text keeps the `default` source. It is not a user choice, so the+ session stays eligible for automatic replacement by an installed plugin.+- Remove the built-in title completion. No title is composed from a model inside+ the core, and no core flow waits on one.- Provide `session.autoTitle`, a dedicated high-risk permission for a narrowfirst-turn context and a compare-and-set title update. Context contains onlythe first user message and first assistant reply, each bounded, and isavailable only while the title source is `default`.- Store `title_source` in host-core schema v23. Manual renames set `manual`;- plugin updates set `generated`; default placeholders remain `default`. The- title update compares the exact expected title and source so manual changes- win races and survive renderer restarts.+ plugin updates set `generated`; a placeholder or a first-prompt fallback+ remains `default`. The title update compares the exact expected title and+ source so manual changes win races and survive renderer restarts.- Ship title generation as the standalone `pi-desktop-session-title-plugin`repository. The plugin listens for completed turns and uses the existing`agent.complete` and `models.list` APIs. Its settings panel exposes an@@ -36,8 +49,9 @@ general transcript API is intentionally too broad for this task.## Consequences-- Without the plugin, a new session keeps the default title. Installing and- granting the plugin is required for generated titles.+- Without the plugin, a new session shows its localized default title until the+ first prompt derives a label from it, and keeps that label afterwards.+ Installing and granting the plugin is required for model-composed titles.- The plugin can customize title policy without adding a second title engineinside Electron or the renderer.- The new permission allows the plugin to see bounded excerpts from any@@ -45,11 +59,16 @@ general transcript API is intentionally too broad for this task.later messages, or a general transcript-read method.- Schema v23 classifies existing default placeholders as `default` and otherexisting titles as `manual`, preserving user-chosen titles during migration.+- Existing sessions that still hold a known placeholder title receive the+ first-prompt fallback on their next prompt, exactly like a new session.## Alternatives considered-- Keep the first-prompt fallback in the core: rejected because it would still- automatically mutate titles when the optional plugin is absent.+- Remove the first-prompt fallback together with the completion: rejected after+ review because readability would then depend on installing an optional plugin,+ and an untouched session would show a placeholder forever.+- Keep the completion in the core: rejected because it would still automatically+ spend model tokens and mutate titles when the optional plugin is absent.- Give the plugin `session.read` or `session.read.own`: rejected because thosepermissions either expose a general transcript projection or only importedsessions and do not match the required boundary.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 3b22fdd5b..d44d0875a 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -364,5 +364,5 @@ Each ADR includes:| 0320 | [Host-owned OAuth lifecycle for plugin providers](0320-plugin-oauth-provider-callbacks.md) | Accepted for implementation (D647; amends ADR 0259) || 0321 | [Pin an acceptable address for mixed direct DNS answers](0321-skill-market-direct-dns-pinning.md) | Accepted (D648; amends ADR 0272) || 0322 | [Plugin providers appear in Add Service](0322-plugin-providers-in-add-service.md) | Accepted for implementation (D650; amends ADR 0259) |-| 0323 | [Make Session Title Generation a Standalone Plugin](0323-plugin-owned-session-titles.md) | Accepted (D652; supersedes ADR 0186) |+| 0323 | [Make Session Title Generation a Standalone Plugin](0323-plugin-owned-session-titles.md) | Accepted (D652, amended by D654; supersedes ADR 0186) || 0324 | [Make Composer Prompt Enhancement an Optional Plugin](0324-plugin-owned-composer-prompt-enhancement.md) | Accepted (D653; supersedes ADR 0121) |diff --git a/docs/spec/03-runtime/01-ipc-protocol.md b/docs/spec/03-runtime/01-ipc-protocol.mdindex 493433976..36cb4376e 100644--- a/docs/spec/03-runtime/01-ipc-protocol.md+++ b/docs/spec/03-runtime/01-ipc-protocol.md@@ -1067,6 +1067,13 @@ Minimal interface:`INVALID_PARAMS`; a successful rename changes only session metadata and doesnot alter transcript content, message count, or activity timestamps. It marksthe title source as manual so an installed title plugin cannot replace it.+- `session/deriveTitle({ id, title }) -> { updated: boolean }` applies the+ deterministic first-prompt fallback. Host-core accepts it only while the+ stored title is still a recognized placeholder with the `default` title+ source, and it is applied only to metadata: `updated_at`, transcript content,+ and message count are unchanged. The derived title keeps that source, so an+ installed title plugin may still replace it; `session/rename` remains the+ user-owned path.- `session/getScratchPath({ sessionId }) -> { path }` returns the sessionscratch directory `<data_dir>/scratch/<sessionId>/` without creating it.- `session/openScratchPath({ sessionId }) -> { ok, path }` resolves that samediff --git a/docs/spec/03-runtime/02-agent-runtime.md b/docs/spec/03-runtime/02-agent-runtime.mdindex 179204c47..632c2f388 100644--- a/docs/spec/03-runtime/02-agent-runtime.md+++ b/docs/spec/03-runtime/02-agent-runtime.md@@ -92,18 +92,26 @@ finalization. A steering failure must not terminate the active run.### 4.1 Session title generation-The core keeps new sessions at their localized default title. It does not-derive a title from the first prompt or run a title completion. An optional-standalone plugin may subscribe to `session:turnEnded`; with the dedicated+The core keeps new sessions readable without any model call. Sending the first+prompt into a session whose stored title is still a recognized placeholder asks+the host for a deterministic fallback title through `session/deriveTitle`. The+renderer collapses whitespace and caps its request at 48 characters; host-core+accepts it only while the stored title is still a placeholder with the `default`+source, so the fallback never replaces a manual rename or an earlier automatic+title, and the write does not change `updated_at`.++That fallback keeps the source `default`: the derived text is not a user choice,+so the session stays eligible for automatic replacement. An optional standalone+plugin may subscribe to `session:turnEnded`; with the dedicated`session.autoTitle` permission it can read only the first user prompt and firstassistant reply for a session whose title is still default, then use`agent.complete` with its configured prompt, model, and thinking level.The plugin writes through a host compare-and-set that succeeds only while the-exact default title is still current. Manual renames and another generated+exact title it read is still current. Manual renames and another generatedtitle therefore win concurrent updates. Host-core owns the title source inschema v23; this state survives renderer restart and does not expose a general-transcript-read API.+transcript-read API. The core runs no title completion of its own.## 5. Prompt flowdiff --git a/docs/spec/03-runtime/04-data-storage.md b/docs/spec/03-runtime/04-data-storage.mdindex f5b878b83..d2bf6cefc 100644--- a/docs/spec/03-runtime/04-data-storage.md+++ b/docs/spec/03-runtime/04-data-storage.md@@ -576,9 +576,13 @@ CREATE INDEX idx_session_import_origins_plugin- `title_source` records `legacy`, `default`, `manual`, or `generated`. Schemav23 classifies pre-existing known placeholder titles as `default` and allother titles as `manual`; new session creation and manual rename write the- corresponding source. The standalone title plugin can read first-turn text- only for `default` sessions and can write only with an exact-title- compare-and-set, so a manual rename wins a race.+ corresponding source. `default` means "not chosen by the user and still+ replaceable": it covers a new session's placeholder and the deterministic+ first-prompt fallback, which host-core writes only while the stored title is+ still a recognized placeholder. A placeholder is recognized in every shipped+ locale, because the renderer writes its localized `chat.untitledTask` label+ when it creates a session. The standalone title plugin can read+ exact-title compare-and-set, so a manual rename wins a race.- Import binds every non-empty normalized `projectPath` to `project_id`;path-less imports remain `NULL`. Re-importing a deterministic session idcreates neither another session nor another project row.diff --git a/docs/spec/03-runtime/06-host-rpc-protocol.md b/docs/spec/03-runtime/06-host-rpc-protocol.mdindex 6de3c0409..94e9b3ed7 100644--- a/docs/spec/03-runtime/06-host-rpc-protocol.md+++ b/docs/spec/03-runtime/06-host-rpc-protocol.md@@ -336,6 +336,12 @@ to later refresh and inference; the vendor picker does not collect them.title metadata and marks the title source `manual`; it does not update`updated_at`, transcript content, message count, or historical notificationtitle snapshots.+- `session.deriveTitle({ id, title })` applies the deterministic first-prompt+ fallback and returns `{ updated: boolean }`. It validates the title with the+ same 1–80 code-point rule, then writes only when the stored title is still a+ recognized placeholder whose title source is `default`. The write keeps that+ source so a title plugin can still replace the derived text, and it does not+ update `updated_at`, transcript content, or message count.- `session.configure` — atomically persists `mode`, `providerId`, `modelId`,and optional `thinkingLevel` (`off|minimal|low|medium|high|xhigh|max|omit`)for the next pi turn; omitting/nulldiff --git a/docs/spec/03-runtime/19-remote-agent-control-protocol.md b/docs/spec/03-runtime/19-remote-agent-control-protocol.mdindex 48b267a54..a29fcad04 100644--- a/docs/spec/03-runtime/19-remote-agent-control-protocol.md+++ b/docs/spec/03-runtime/19-remote-agent-control-protocol.md@@ -586,6 +586,7 @@ session root as working directory and stream through `terminal.output`.| `session/configure` | controller | Change mode, provider/model, thinking level, or permission mode while idle; same rules as `pi-desktop/session/configure` || `session/fork` | controller | Fork an idle session, optionally through a message id, into a new idle session || `session/rename` | controller | Rename a session |+| `session/deriveTitle` | controller | Apply the Host's deterministic first-prompt title to a still-untitled session; returns `{ updated }` and never overrides a rename || `session/delete` | owner | Delete a session and its transcript on the Host || `session/compact` | controller | Run a manual context checkpoint on the active session || `workspace/list` | viewer | List entries under the session root, bounded, honoring the Host ignore rules |diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 65ec0bb95..83077786e 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -442,9 +442,10 @@ visually distinct from list content.| Archived row | Hidden by default; visible in the explicit archived view || No retained project | Compact Open project entry; standalone Sessions rows remain available || Empty group | Muted one-line empty state; group create action remains available |-| Default session title | New task/New chat (localized where applicable) until the user or an installed title plugin sets one |-| Plugin-generated session title | A title plugin may replace the default after the first completed turn when its permission is granted |-| Manual session title | User-defined title remains stable across refresh and renderer restart; plugin updates use a host compare-and-set and never overwrite it |+| Default session title | New task/New chat (localized where applicable) until the first prompt, the user, or an installed title plugin sets one |+| First prompt title | A normalized 48-character prompt fallback appears immediately and is stored as a still-replaceable automatic title |+| Plugin-generated session title | A title plugin may replace that automatic title after the first completed turn when its permission is granted |+| Manual session title | User-defined title remains stable across refresh and renderer restart; automatic titles (local fallback or plugin) never overwrite it || Footer idle | Transparent 58px band; build and action controls remain visually quiet || Footer hover/focus | Only the targeted control receives the semantic hover/focus treatment || Profile menu open | Profile trigger is active; 280px menu opens 8px above the footer |diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 41345470d..6c3bea880 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -2842,18 +2842,21 @@ identify the platform validation still needed.an over-80-Unicode-code-point title. 6) Open **Session Titles: Configure**,set the prompt to return a fixed test title, choose the deterministic testmodel, and save. 7) Send the first prompt in the default-title session. 8)- Confirm the title stays at its localized default while the turn runs, then- wait for `session:turnEnded` and the plugin completion. 9) Manually rename- that session and complete another turn.+ Confirm the Sidebar and topbar immediately show the normalized+ 48-character prompt fallback, then wait for `session:turnEnded` and the+ plugin completion, which replaces that fallback with the deterministic test+ title. 9) Manually rename that session and complete another turn. 10) Send+ the first prompt in another default-title session with the plugin disabled.- **Expected**: The saved title is trimmed, displayed across every currentsession-summary surface, and persists after restart. The session stays inthe same project or Temporary group, its transcript/message count andrecent-activity ordering do not change, and historical notification title- snapshots are unchanged. Empty and overlong values are rejected. Sending a- prompt does not change the core title. The enabled plugin replaces a- still-default title with the deterministic test title after the completed- turn; after a manual rename, a later plugin completion cannot replace it. A- session without the plugin remains at its localized default title.+ snapshots are unchanged. Empty and overlong values are rejected. Sending the+ first prompt immediately persists the normalized 48-character prompt fallback+ as a still-replaceable automatic title. With the plugin enabled, that fallback+ is replaced by the deterministic test title after the completed turn; after a+ manual rename, a later plugin completion cannot replace it. A session without+ the plugin keeps its prompt fallback, and a second prompt never changes it.- **Specs linked**: `03-runtime/01-ipc-protocol.md`,`03-runtime/04-data-storage.md`, `03-runtime/06-host-rpc-protocol.md`,`03-runtime/02-agent-runtime.md`, `07-plugins/03-plugin-api.md`,diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.mdindex 8ee20b3f8..976175178 100644--- a/docs/spec/07-plugins/03-plugin-api.md+++ b/docs/spec/07-plugins/03-plugin-api.md@@ -531,7 +531,10 @@ pi.session.setAutoTitle(input: {```Context is returned only for an active session whose title source is still-`default`. The host does not return attachments, tool calls, later turns, or+`default`. That source covers both a new session's placeholder and the+deterministic first-prompt fallback the core writes itself, so a plugin must+expect `expectedTitle` to be the current derived text rather than a localized+placeholder. The host does not return attachments, tool calls, later turns, orthe rest of the transcript. Title updates accept 1–80 Unicode code points anduse the exact `expectedTitle` as a compare-and-set; a manual rename or anotherupdate makes the result `{ updated: false }`. Both methods requirediff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex 9b9e276b4..36815fbeb 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -45,8 +45,9 @@ This log freezes previously open questions into concrete decisions.| D649 | Cloud backup stays closed to users | **Amend D642 / D643: the Settings `sync` destination carries `developmentOnly: true` again, so a packaged build omits its rail row, page, and settings-search hits and falls back to General, while development builds keep it. Developer mode stays irrelevant to the destination and it still carries no Experimental badge. Sync behavior, protocol, host schema, and persisted data are unchanged; dropping the flag reopens it for packaged builds. See `04-ux/06-settings-ia.md` and E2E-CONFIG-SYNC-webdav-portable-configuration.** | The encrypted WebDAV backup is not ready to be offered to packaged-build users yet, so it stays implemented but out of the way until it opens. || D650 | Plugin providers appear in Add Service | **Amend ADR 0259: optional `category` groups manifest-owned provider rows; optional localized `description` supplies one-sentence hover/focus copy. Loaded plugins with `provider.register` contribute unconfigured API-key providers with endpoints. Tiles display provider names only; the Host saves keys through the existing provider secret path. There is no per-plugin provider-count cap. An empty model list is allowed only for an API-key provider with a base URL; after explicit key save, Host discovery populates its cached model choices. Configured rows remain in the provider list and leave the chooser. OAuth / no-auth rows are omitted; no new permission, runtime plugin API, provider row, or credential migration is added. See ADR 0322, `07-plugins/02-plugin-manifest-schema.md`, and E2E-PLUGIN-provider-catalog-add-service.** | Users could not discover manifest-owned community providers in the normal Add Service flow, and each plugin needed to group its own sites without owning credential UI. || D651 | Transcript tool rows never auto-open | **Amend the leaf auto-open provision of the turn-process / thinking-display decisions and ADR `turn-process-and-thinking-display`: a tool-call, hosted-search or plan row keeps its payload collapsed in both display modes and only an explicit user action opens it, including the literal final item of the last activity group. Whole-process and ordinary-group defaults, failed/denied behavior, retained per-item choices, and the thinking row's own leaf default are unchanged. Renderer-only; no host protocol, persistence, permission or plugin contract change. See `04-ux/08-component-spec.md` §9.1/§9.2/§9.5/§9.6, `04-ux/09-interaction-patterns.md` §4.2, and E2E-040.** | A payload that opened itself under the newest call pulled attention away from the answer the user was waiting for and made one turn look different depending on how it ended; leaving every payload to the user keeps one predictable row. |-| D652 | Make session title generation a standalone plugin | **Supersede ADR 0186: remove core prompt-derived fallback and built-in title completion; new sessions keep their localized default title until a user or plugin changes it. Add the high-risk `session.autoTitle` capability for bounded first-turn context and compare-and-set title updates, backed by schema v23 `sessions.title_source`; manual rename marks `manual`, plugin output marks `generated`. The standalone plugin configures its prompt template, model, and thinking level through its panel and uses `session:turnEnded`, `models.list`, and `agent.complete`. See ADR 0323, E2E-021a, and the plugin API/permission specs.** | Title generation is optional product policy with model and prompt settings, and the host needs a narrow durable boundary that makes manual titles win races. |+| D652 | Make session title generation a standalone plugin *(amended by D654)* | **Supersede ADR 0186: remove the built-in title completion and keep only the deterministic local fallback restored by D654; new sessions otherwise keep their localized default title until a user or plugin changes it. Add the high-risk `session.autoTitle` capability for bounded first-turn context and compare-and-set title updates, backed by schema v23 `sessions.title_source`; manual rename marks `manual`, plugin output marks `generated`. The standalone plugin configures its prompt template, model, and thinking level through its panel and uses `session:turnEnded`, `models.list`, and `agent.complete`. See ADR 0323, E2E-021a, and the plugin API/permission specs.** | Title generation is optional product policy with model and prompt settings, and the host needs a narrow durable boundary that makes manual titles win races. || D653 | Make Composer prompt enhancement an optional plugin | **Supersede ADR 0121: remove host-owned prompt-enhancement UI, settings, direct completion IPC, and MCP action. Add the permission-gated `composer.transform` contribution and plugin callback, passing only the current draft plus an optional model key, with bounded input/output, audit, file-reference restoration, one-step undo, and stale session/draft guards. Keep `vastsa/pi-prompt-enhancement` in its own repository and require explicit user installation; do not bundle or enable it by default. On first plugin load, copy valid legacy preferences into unset plugin settings and write a private migration marker; preserve old host values for rollback. See ADR 0324, E2E-218 / E2E-259, and the plugin API/permission specs.** | Prompt enhancement is optional behavior that belongs to a separately installed plugin, while the host needs a narrow safe transform contract and a one-time path for existing settings. |+| D654 | Keep the deterministic first-prompt session title in the core | **Amend D652 / ADR 0323: a session whose stored title is still a recognized placeholder derives a whitespace-collapsed 48-character fallback from the first prompt, written through the host RPC and IPC `session/deriveTitle`. Host-core applies it only while the title is still a placeholder with the `default` source, and the derived text keeps that source, so an installed title plugin may still replace it and only a manual rename opts out. No model call, no new permission, no schema or protocol version change; `updated_at`, transcript content, and message count stay unchanged. See `03-runtime/01-ipc-protocol.md`, `03-runtime/02-agent-runtime.md`, `03-runtime/06-host-rpc-protocol.md`, `03-runtime/04-data-storage.md`, `04-ux/08-component-spec.md`, and E2E-021a.** | Removing every automatic write left an untouched session showing a placeholder until a plugin ran, so offline readability depended on installing optional software. |## B. Secondary implementation defaults@@ -7551,9 +7552,9 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.`07-plugins/02-plugin-manifest-schema.md` §5.4.## 2026-10-08 — Make session title generation a standalone plugin (D652)-- The core no longer derives a title from the first prompt or runs a title- completion. New sessions remain at their localized default until the user or- an installed plugin changes the title.+- The core keeps one automatic title path: the deterministic first-prompt+ fallback (D654). It runs no title completion, and a session without the plugin+ keeps the derived fallback instead of a placeholder.- The `session.autoTitle` permission exposes only bounded first-turn text for adefault-titled session and a host compare-and-set title update. Schema v23tracks default, manual, and generated title ownership.@@ -7577,3 +7578,25 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.leaf-ownership helper is retired. See `04-ux/08-component-spec.md`§9.1/§9.2/§9.5, `04-ux/09-interaction-patterns.md` §4.2, ADR`turn-process-and-thinking-display`, and E2E-040.++## 2026-10-08 — Keep the deterministic first-prompt session title (D654)++- `session.deriveTitle` restores the immediate label a new session used to get+ from its first prompt: the renderer collapses whitespace and caps the request+ at 48 characters, and host-core writes it only while the stored title is still+ a recognized placeholder with the `default` source.+- The write keeps that source, so the derived title stays replaceable: the+ `session.autoTitle` plugin can still upgrade it through its compare-and-set,+ while manual renames, earlier plugin titles, and second prompts never change+ it. No model call, permission, schema, or protocol version changes.+- Placeholder recognition now covers every shipped locale: the renderer creates a+ session with its localized `chat.untitledTask` label, so host-core (and the+ v23 migration) had classified Korean, Traditional-Chinese, Brazilian+ Portuguese, and Turkish placeholders as `manual` and blocked both the fallback+ and the plugin there. The recognized list mirrors the renderer catalog.+- Remote sessions derive on their own Host: the remote-host RACP profile gains+ `session/deriveTitle` (controller), so a paired desktop no longer gates the+ fallback off for a `remote` session. A native Pi session keeps its own title.+- Covered by `apps/desktop/test/session-title-prompt-fallback.test.mjs`,+ `apps/desktop/test/queue-pending-actions.test.mjs`, the host-core+ `derive_session_title` tests, and E2E-021a. See ADR 0323.diff --git a/docs/zh-CN/adr/index.md b/docs/zh-CN/adr/index.mdindex 4b1beae6d..dc1b190ac 100644--- a/docs/zh-CN/adr/index.md+++ b/docs/zh-CN/adr/index.md@@ -50,7 +50,7 @@ ADR 记录那些不应被静默改变的架构选择。中文入口与英文索| [ADR 0191:明确标注两个 macOS 发布架构](/adr/0191-label-both-macos-release-architectures) | macOS DMG/ZIP 统一使用 `-arm64` / `-x64` 后缀,更新源 URL 与校验和保持一致 || [ADR 0192:为已配置模型设置别名并允许复制模型 id](/adr/0192-model-alias) | 别名只用于展示;配置页模型 id 可选择复制,请求仍使用真实 id || [ADR 0193:上下文检查器按最后一次请求计算占用](/adr/0193-last-request-context-occupancy) | 占用、本轮合计和缓存读写取最新一条助手消息,不再把工具循环里的每次请求加总 |-| [ADR 0323:会话标题由独立插件拥有](/adr/0323-plugin-owned-session-titles) | 核心保留默认标题;独立插件可配置提示词、模型与思考级别,并通过主机 CAS 更新标题 |+| [ADR 0323:会话标题由独立插件拥有](/adr/0323-plugin-owned-session-titles) | 核心保留确定性首条提示兜底标题;独立插件可配置提示词、模型与思考级别,并通过主机 CAS 升级该标题 || [ADR 0324:提示词增强由可选插件拥有](/adr/0324-plugin-owned-composer-prompt-enhancement) | 输入框只提供受权限约束的通用文本转换扩展点;提示词增强需用户单独安装,旧设置在首次加载时迁移 || [ADR 0194:可选的子智能体思考覆盖](/adr/0194-subagent-thinking-parameter-omission) | 子智能体可继承、显式关闭或不发送思考参数 || [ADR 0195:视口固定的工作面板开关](/adr/0195-viewport-fixed-work-panel-toggle) | 非设置页右上角提供与 Cmd/Ctrl+J 等价的指针开关 |@@ -262,7 +262,7 @@ ADR 记录那些不应被静默改变的架构选择。中文入口与英文索| 0191 | [明确标注两个 macOS 发布架构](/adr/0191-label-both-macos-release-architectures) | 已接受(修订 ADR 0145 / D353) || 0192 | [为已配置模型设置别名并允许复制模型 id](/adr/0192-model-alias) | 已接受(修订 D266) || 0193 | [上下文检查器按最后一次请求计算占用](/adr/0193-last-request-context-occupancy) | 已接受(修订 ADR 0047 / ADR 0103 / ADR 0184) |-| 0323 | [会话标题由独立插件拥有](/adr/0323-plugin-owned-session-titles) | 已接受 |+| 0323 | [会话标题由独立插件拥有](/adr/0323-plugin-owned-session-titles) | 已接受(修订 ADR 0186;D654 保留首条提示兜底) || 0324 | [提示词增强由可选插件拥有](/adr/0324-plugin-owned-composer-prompt-enhancement) | 已接受(修订 ADR 0121) || 0194 | [可选的子智能体思考覆盖](/adr/0194-subagent-thinking-parameter-omission) | 已接受待实现 || 0195 | [视口固定的工作面板开关](/adr/0195-viewport-fixed-work-panel-toggle) | 已接受(修订 ADR 0068 / ADR 0085) |diff --git a/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md b/docs/zh-CN/spec/03-runtime/01-ipc-protocol.mdindex 061587e88..6706af89f 100644--- a/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md+++ b/docs/zh-CN/spec/03-runtime/01-ipc-protocol.md@@ -868,6 +868,10 @@ ID、或会话无法解析出默认目标时,得到 `supportsReasoning: false`- `session/get`- `session/delete`- `session/rename`+- `session/deriveTitle({ id, title }) -> { updated: boolean }` 应用确定性的首条提示兜底标题。+ 只有当存储标题仍是可识别的占位标题且标题来源为 `default` 时,host-core 才接受它;该写入+ 只改元数据,`updated_at`、转录内容与消息数都不变。派生标题会保留该来源,因此已安装的+ 标题插件仍可替换它;`session/rename` 仍是用户拥有的路径。- `session/importScan`- `session/importRun(candidates) -> { imported, skipped, failed }`diff --git a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md b/docs/zh-CN/spec/03-runtime/02-agent-runtime.mdindex d22f15b1c..b9c54d506 100644--- a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md+++ b/docs/zh-CN/spec/03-runtime/02-agent-runtime.md@@ -84,14 +84,19 @@ pi 消费排队输入时保留渲染器提供的消息 id;即使补充输入### 4.1 会话标题生成-核心会让新会话保持本地化默认标题,不会从第一条提示派生标题,也不会运行标题补全。-可选的独立插件可以订阅 `session:turnEnded`;获得专用的 `session.autoTitle` 权限后,-它只能读取标题仍为默认值的会话中的首条用户提示和首条助手回复,再使用配置的提示词、-模型及思考级别调用 `agent.complete`。--插件通过主机比较并设置更新标题,只有在当前标题仍与读取时完全一致且来源仍为 `default`-时才会成功。因此并发手动重命名或另一项标题更新会胜出。host-core 在架构 v23 中拥有-标题来源状态;该状态可跨渲染器重启保留,也不会开放通用转录读取 API。+核心让新会话无需任何模型调用即可读:当会话存储的标题仍是可识别的占位标题时,发送第一条+提示会通过 `session/deriveTitle` 向主机请求一个确定性兜底标题。渲染器会折叠空白并将请求+限制在 48 个字符;host-core 只有在存储标题仍是占位标题且来源为 `default` 时才接受,因此+该兜底永远不会覆盖手动重命名或更早的自动标题,也不会改动 `updated_at`。++该兜底会保持 `default` 来源:派生文本不是用户的选择,所以该会话仍可被自动替换。可选的+独立插件可以订阅 `session:turnEnded`;获得专用的 `session.autoTitle` 权限后,它只能读取+标题仍为默认值的会话中的首条用户提示和首条助手回复,再使用配置的提示词、模型及思考级别+调用 `agent.complete`。++插件通过主机比较并设置更新标题,只有在当前标题仍与读取时完全一致时才会成功。因此并发+手动重命名或另一项标题更新会胜出。host-core 在架构 v23 中拥有标题来源状态;该状态可跨+渲染器重启保留,也不会开放通用转录读取 API。核心自身不运行任何标题补全。## 5. 提示流程diff --git a/docs/zh-CN/spec/03-runtime/04-data-storage.md b/docs/zh-CN/spec/03-runtime/04-data-storage.mdindex 33b67cd8c..62157952b 100644--- a/docs/zh-CN/spec/03-runtime/04-data-storage.md+++ b/docs/zh-CN/spec/03-runtime/04-data-storage.md@@ -376,8 +376,12 @@ CREATE INDEX idx_sessions_deleted ON sessions(deleted_at) WHERE deleted_at IS NO`title_source` 记录 `legacy`、`default`、`manual` 或 `generated`。架构 v23 会将已有的已知占位标题归类为 `default`,其余标题归类为 `manual`,不改写标题。新建会话和手动重命名-会写入相应来源。独立标题插件只能读取 `default` 会话的首轮文本,并且只能用精确标题-比较并设置,因此并发手动重命名会胜出。+会写入相应来源。`default` 表示“非用户选择、仍可替换”:它既覆盖新会话的占位标题,也覆盖+确定性的首条提示兜底标题(host-core 只在存储标题仍是可识别占位标题时才写入)。占位标题在+所有已发布的语言下都会被识别,因为渲染器创建会话时会写入本地化的 `chat.untitledTask` 文案。+独立标题插件只能读取 `default` 会话的首轮文本,并且只能用精确标题比较并设置,因此并发手动+重命名会胜出。+会胜出。插件导入增加一个由主机拥有的来源 sidecar。它与核心会话身份分离,每次插件读写都必须匹配创建该行的 `plugin_id`:diff --git a/docs/zh-CN/spec/03-runtime/06-host-rpc-protocol.md b/docs/zh-CN/spec/03-runtime/06-host-rpc-protocol.mdindex 5e45ce811..f2527bec1 100644--- a/docs/zh-CN/spec/03-runtime/06-host-rpc-protocol.md+++ b/docs/zh-CN/spec/03-runtime/06-host-rpc-protocol.md@@ -245,6 +245,10 @@ type ToolBudgetHealth = {- `session.getScratchPath` — 会话的 scratch 目录(D114),按需创建- `session.rename` — 在主机边界裁剪并校验标题,接受 1–80 个 Unicode 码点;成功后将标题来源标记为 `manual`,但不更新 `updated_at`、转录内容、消息数或历史通知标题快照。+- `session.deriveTitle` — `{ id, title }`:应用确定性的首条提示兜底标题,返回+ `{ updated: boolean }`。标题按同样的 1–80 码点规则校验,且只在存储标题仍是可识别占位+ 标题、标题来源为 `default` 时写入;写入后仍保留该来源,因此标题插件还能替换派生文本,+ 并且不更新 `updated_at`、转录内容或消息数。- `session.configure` — 以原子方式持久保存 `mode`、`providerId`、`modelId`,以及可选的 `thinkingLevel` 用于下一个 pi 回合; omitting/null`thinkingLevel` 保留当前值;返回无效模式或级别diff --git a/docs/zh-CN/spec/03-runtime/19-remote-agent-control-protocol.md b/docs/zh-CN/spec/03-runtime/19-remote-agent-control-protocol.mdindex aba1fa19b..ba367563a 100644--- a/docs/zh-CN/spec/03-runtime/19-remote-agent-control-protocol.md+++ b/docs/zh-CN/spec/03-runtime/19-remote-agent-control-protocol.md@@ -204,6 +204,7 @@ owner,工作区读取都按会话持久根、Host 忽略规则和 `PATH_OUTSID| `session/configure` | controller | 空闲时修改模式、provider/模型、思考等级或权限模式,规则同 `pi-desktop/session/configure` || `session/fork` | controller | 将空闲会话(可指定消息 id)fork 为新的空闲会话 || `session/rename` | controller | 重命名会话 |+| `session/deriveTitle` | controller | 对仍未命名的会话应用 Host 确定性的首条提示标题;返回 `{ updated }`,永不覆盖重命名 || `session/delete` | owner | 删除会话及其在 Host 上的 transcript || `session/compact` | controller | 对活动会话执行手动上下文检查点 || `workspace/list` | viewer | 有界列出会话根下的条目,遵守 Host 忽略规则 |diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.mdindex d24c44910..56f4ddbfa 100644--- a/docs/zh-CN/spec/04-ux/08-component-spec.md+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md@@ -361,9 +361,10 @@ Collapsed (48px):| 存档行 | 默认隐藏;在显式存档视图中可见 || 无保留项目 | 紧凑的开放式项目入口;独立会话行仍然可用 || 空组 | 静音单线空状态;组创建操作仍然可用 |-| 默认会话标题 | 保留本地化的 New task/New chat,直到用户或已安装的标题插件设置标题 |-| 插件生成的会话标题 | 获得权限的标题插件可在首轮完成后替换默认标题 |-| 手动会话标题 | 用户标题在刷新和渲染器重启后保持稳定;插件使用主机比较并设置,不会覆盖手动标题 |+| 默认会话标题 | 保留本地化的 New task/New chat,直到首条提示、用户或已安装的标题插件设置标题 |+| 首条提示标题 | 立即出现规范的 48 字符提示兜底标题,并以“仍可替换的自动标题”保存 |+| 插件生成的会话标题 | 获得权限的标题插件可在首轮完成后替换该自动标题 |+| 手动会话标题 | 用户标题在刷新和渲染器重启后保持稳定;自动标题(本地兜底或插件生成)都不会覆盖它 || 页脚闲置 | 透明58px带;构建和动作控制在视觉上保持安静 || 页脚 hover/focus | 仅目标控件接受语义 hover/focus 处理 || 个人资料菜单打开 | 配置文件触发器已激活; 280px 菜单在页脚上方 8px 处打开 |diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex 0650fd415..c5f4dba19 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -5795,11 +5795,12 @@ eleven-tool-round desktop paths are verified by- Composer 省略本地工作区标签并显示 Agent/Plan/Goal 以及活动模型 ID;这两个区域设置都会公开 Plan 和 Goal 批准副本。-### US-UI-06 会话标题插件+### US-UI-06 会话标题:首条提示兜底 + 插件标题- 创建一个新任务并发送第一个提示,例如“同步代码”。-- 提示发送期间及完成后,核心都保留本地化默认标题。启用并授权- Session Titles 插件后,完成首轮可由插件按配置的提示词、模型和思考级别- 生成标题;没有插件时标题继续保持默认值。+- 发送后侧栏与顶栏立即显示折叠空白、截断为 48 字符的提示兜底标题,且该标题+ 仍是可被替换的自动标题。启用并授权 Session Titles 插件后,完成首轮可由插件+ 按配置的提示词、模型和思考级别生成标题并替换该兜底标题。+- 未安装插件时,会话保持提示兜底标题;再发送第二条提示也不会改写它。- 手动重命名后再完成一轮,插件不得覆盖用户设置的标题。### US-UI-08 仅快捷方式目的地历史记录@@ -5808,9 +5809,9 @@ eleven-tool-round desktop paths are verified by- 按 `Cmd/Ctrl+[` 和 `Cmd/Ctrl+]`;期望他们能够穿越那段历史。### US-UI-09 默认会话标题持久化-- 打开先前显示“新任务”/“新聊天”且有第一条用户消息的旧会话。-- 未启用标题插件时,范围侧边栏行仍显示原默认标题;启用插件时,只有- 首轮完成且插件获准后才更新标题。+- 打开先前显示“新任务”/“新聊天”且有第一条用户消息的旧会话,发送一条提示。+- 期望其范围侧边栏行显示截断后的首条用户消息标题;随后启用插件并完成首轮时,+ 插件可以替换该标题,而手动重命名过的会话始终不被替换。### US-UI-11 空草稿重用- 单击“新任务”两次。diff --git a/docs/zh-CN/spec/07-plugins/03-plugin-api.md b/docs/zh-CN/spec/07-plugins/03-plugin-api.mdindex 61b200305..a0b490292 100644--- a/docs/zh-CN/spec/07-plugins/03-plugin-api.md+++ b/docs/zh-CN/spec/07-plugins/03-plugin-api.md@@ -419,7 +419,9 @@ pi.session.setAutoTitle(input: {}): Promise<{ updated: boolean }>```-只有活动会话且标题来源仍为 `default` 时才返回上下文。宿主不会返回附件、工具调用、后续回合+只有活动会话且标题来源仍为 `default` 时才返回上下文。该来源既覆盖新会话的占位标题,也覆盖+核心自己写入的确定性首条提示兜底标题,因此插件应预期 `expectedTitle` 是当前已派生的文本,+而不是本地化占位标题。宿主不会返回附件、工具调用、后续回合或其他转录内容。标题长度为 1–80 个 Unicode 码点,并通过精确的 `expectedTitle` 比较并设置;手动重命名或另一项更新发生后返回 `{ updated: false }`。两个方法都需要高风险权限`session.autoTitle`,因为持有 `agent.complete` 的插件可能将首轮文本发送给模型。diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex 77ddb2f67..4ee165a3a 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -47,8 +47,9 @@| D649 | 云备份暂不对外开放 | **修订 D642 / D643:设置中的 `sync` 目的地重新带上 `developmentOnly: true`,因此打包构建会省略其导轨行、页面和设置搜索命中并回落到常规,开发构建则保留该目的地。开发者模式与它无关,它仍不带实验性徽章。同步行为、协议、Host schema 与持久化数据均不变;移除该标记即可对打包构建重新开放。见 `04-ux/06-settings-ia.md` 与 E2E-CONFIG-SYNC-webdav-portable-configuration。** | 加密 WebDAV 备份尚未准备好提供给打包构建用户,因此先保持已实现但不出现在界面上,直到正式开放。 || D650 | 插件提供商出现在添加服务中 | **修订 ADR 0259:`contributes.providers[].category` 是可选分类;`description` 可提供一句简介。已加载且拥有现有 `provider.register` 权限的插件,可向 Host 渲染的添加服务选择器贡献带端点、尚未配置的 API Key 提供商。卡片只显示站名,悬停或键盘聚焦显示一句简介;分类可自定义。每个插件不设服务数量上限。空模型列表仅适用于带端点的 API Key 提供商,用户保存密钥后由 Host 发现并缓存模型。密钥仍通过现有提供商密钥路径保存,已配置的行从选择器隐藏。不提供 OAuth / 无认证行;不新增权限、运行时 API、提供商行或凭据迁移。见 ADR 0322、`07-plugins/02-plugin-manifest-schema.md` 与 E2E-PLUGIN-provider-catalog-add-service。** | 用户无法在常规添加服务流程中发现由清单声明的社区提供商;每个插件也需要自己分组站点,却不应拥有密钥界面。 || D651 | 对话区工具调用行不再自动展开 | **修订 turn-process / thinking-display 决策中的叶子自动展开条款与 ADR `turn-process-and-thinking-display`:工具调用、托管搜索与计划卡片行在两种显示模式下都保持载荷收起,只有用户显式操作才会打开,包括最后一个活动组的字面最后一项。整体过程与普通活动组的默认展开、失败与被拒行为、逐项保留的用户选择,以及思考行自身的叶子默认都保持不变。仅渲染层改动;无 Host 协议、持久化、权限或插件契约变更。见 `04-ux/08-component-spec.md` §9.1/§9.2/§9.5/§9.6、`04-ux/09-interaction-patterns.md` §4.2 与 E2E-040。** | 自动展开最新调用的载荷会把阅读注意力从用户等待的回答上拽走,也让同一轮对话因结束方式不同而呈现不同样子;把载荷交给用户打开可保持行行为可预测。 |-| D652 | 会话标题生成改为独立插件 | **取代 ADR 0186:移除核心的提示词回退标题和内置标题补全;新会话在用户或插件修改前保留本地化默认标题。新增高风险 `session.autoTitle` 能力,用于读取有界首轮上下文并通过比较并设置写入标题,数据由架构 v23 的 `sessions.title_source` 支撑。独立插件可在面板配置提示词模板、模型和思考级别,并使用 `session:turnEnded`、`models.list` 和 `agent.complete`。见 ADR 0323、E2E-021a 及插件 API/权限规格。** | 标题生成是可选产品策略,且支持模型与提示词配置;宿主需要狭窄、持久的边界来保证手动标题在竞态中胜出。 |+| D652 | 会话标题生成改为独立插件 *(由 D654 修订)* | **取代 ADR 0186:移除内置标题补全,只保留 D654 恢复的确定性本地兜底标题;否则新会话在用户或插件修改前保留本地化默认标题。新增高风险 `session.autoTitle` 能力,用于读取有界首轮上下文并通过比较并设置写入标题,数据由架构 v23 的 `sessions.title_source` 支撑。独立插件可在面板配置提示词模板、模型和思考级别,并使用 `session:turnEnded`、`models.list` 和 `agent.complete`。见 ADR 0323、E2E-021a 及插件 API/权限规格。** | 标题生成是可选产品策略,且支持模型与提示词配置;宿主需要狭窄、持久的边界来保证手动标题在竞态中胜出。 || D653 | 输入框提示词增强改为可选插件 | **取代 ADR 0121:移除宿主内置提示词增强界面、设置、直接补全 IPC 与 MCP 操作。新增受 `composer.transform` 权限约束的输入框操作贡献项和插件回调;仅传当前草稿与可选模型标识,并提供输入/输出上限、审计、文件引用恢复、单步撤销及草稿/会话过期保护。`vastsa/pi-prompt-enhancement` 保持独立仓库,必须由用户主动安装;宿主不随附或默认启用。插件首次加载时,将有效旧偏好迁移到尚未设置的插件设置并写入私有标记;旧宿主值继续保留以支持回退。见 ADR 0324、E2E-218 / E2E-259 与插件 API/权限规格。** | 提示词增强是可选行为,应由单独安装的插件拥有;宿主提供狭窄、安全的转换契约及一次性旧设置迁移路径。 |+| D654 | 核心保留确定性的首条提示标题 | **修订 D652 / ADR 0323:当会话存储标题仍是可识别占位标题时,用首条提示派生一个折叠空白、截断为 48 字符的兜底标题,通过主机 RPC 与 IPC `session/deriveTitle` 写入。host-core 只在标题仍是占位标题且来源为 `default` 时接受,派生文本也保留该来源,因此已安装的标题插件仍可替换它,只有手动重命名会退出自动替换。不调用模型、不新增权限、不改架构或协议版本;`updated_at`、转录内容与消息数都不变。见 `03-runtime/01-ipc-protocol.md`、`03-runtime/02-agent-runtime.md`、`03-runtime/06-host-rpc-protocol.md`、`03-runtime/04-data-storage.md`、`04-ux/08-component-spec.md` 与 E2E-021a。** | 移除全部自动写入会让未触碰的会话一直显示占位标题,直到插件运行,从而让离线可读性依赖安装可选软件。 |## B. 辅助实现默认值@@ -3511,7 +3512,7 @@ D193 和 D194。## 2026-10-08 —— 会话标题生成改为独立插件(D652)-- 核心不再根据首条提示生成标题,也不再运行标题补全。新会话会保留本地化默认标题,直到用户或插件修改。+- 核心保留一条自动标题路径:确定性首条提示兜底标题(D654)。它不运行标题补全;未安装插件的会话保留派生兜底标题,而不是占位标题。- 获得 `session.autoTitle` 权限的插件只能读取默认标题会话的有界首轮提示与回复,并且只能通过主机 CAS 更新标题。架构 v23 持久记录 `default`、`manual`、`generated` 来源;手动重命名会让插件竞态写入失败。- 独立 Session Titles 插件从 `session:turnEnded` 触发,可配置提示词模板、模型和思考级别;模型调用使用 `agent.complete`。- 见 ADR 0323、`03-runtime/02-agent-runtime.md`、`03-runtime/04-data-storage.md`、`07-plugins/03-plugin-api.md`、`07-plugins/13-plugin-permissions-matrix.md` 和 E2E-021a。@@ -5340,3 +5341,19 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编- `vastsa/pi-prompt-enhancement` 继续位于独立仓库,必须由用户安装,宿主不默认随附。首次加载时,有效的旧设置会迁移到插件私有设置;旧宿主值保留供回退使用。- 转换调用只接收草稿文本和可选模型标识;宿主检查权限与声明、限制输入输出、审计调用,并保护文件引用和过期草稿。- 见 ADR 0324、E2E-218 / E2E-259 与插件 API/权限规格。++## 2026-10-08 —— 核心保留确定性的首条提示标题(D654)++- `session/deriveTitle` 恢复新会话过去从首条提示获得即时标签的行为:渲染器折叠空白并把+ 请求截断为 48 字符,host-core 只在存储标题仍是可识别占位标题且来源为 `default` 时写入。+- 写入会保留该来源,因此派生标题仍可替换:`session.autoTitle` 插件仍可通过其比较并设置+ 升级它,而手动重命名、更早的插件标题以及第二条提示都不会改写它。不调用模型,也不新增+ 权限、架构或协议版本。+- 占位标题识别现在覆盖所有已发布语言:渲染器创建会话时会写入本地化的 `chat.untitledTask`+ 文案,此前 host-core(以及 v23 迁移)会把韩语、繁体中文、巴西葡语和土耳其语的占位标题判为+ `manual`,导致这些语言下兜底与插件都失效。识别列表与渲染器目录保持一致。+- 远程会话在各自的 Host 上派生:remote-host RACP profile 新增 `session/deriveTitle`+ (controller),因此配对桌面不再对 `remote` 会话关闭兜底;原生 Pi 会话保留其自身标题。+- 由 `apps/desktop/test/session-title-prompt-fallback.test.mjs`、+ `apps/desktop/test/queue-pending-actions.test.mjs`、host-core 的 `derive_session_title`+ 单测与 E2E-021a 覆盖。见 ADR 0323。diff --git a/packages/racp/src/host-operations.ts b/packages/racp/src/host-operations.tsindex 4a0691557..613f196f8 100644--- a/packages/racp/src/host-operations.ts+++ b/packages/racp/src/host-operations.ts@@ -37,6 +37,8 @@ export interface RacpSessionCatalog {configure(sessionId: string, input: SessionConfigureInput): Promise<SessionSummary>;fork(sessionId: string, input: { title?: string; throughMessageId?: string }): Promise<SessionSummary>;rename(sessionId: string, title: string): Promise<void>;+ /** Apply the Host's first-prompt fallback title; false when it was refused. */+ deriveTitle(sessionId: string, title: string): Promise<boolean>;delete(sessionId: string): Promise<void>;compact(sessionId: string): Promise<{ accepted: boolean }>;}diff --git a/packages/racp/src/operations.ts b/packages/racp/src/operations.tsindex c7f3473ed..d6eba1a91 100644--- a/packages/racp/src/operations.ts+++ b/packages/racp/src/operations.ts@@ -303,6 +303,17 @@ export function createOperations(): Map<RacpOperation, OperationHandler> {if (summary) context.agentHost.publishSessionChange("session.changed", summary);return { ok: true };});+ handlers.set("session/deriveTitle", async (context, params) => {+ const input = check(Type.Object({ sessionId: Type.String({ minLength: 1 }), title: Type.String({ minLength: 1 }) }), params);+ // The Host owns title eligibility: it refuses a session the user renamed,+ // and the derived text stays replaceable by the title plugin.+ const updated = await context.operations.sessions.deriveTitle(input.sessionId, input.title);+ if (updated) {+ const summary = (await context.operations.sessions.list()).find((candidate) => candidate.id === input.sessionId);+ if (summary) context.agentHost.publishSessionChange("session.changed", summary);+ }+ return { updated };+ });handlers.set("session/delete", async (context, params) => {const input = check(SessionIdParams, params);await context.operations.sessions.delete(input.sessionId);diff --git a/packages/racp/src/racp.test.ts b/packages/racp/src/racp.test.tsindex c40f55b2e..09439ac49 100644--- a/packages/racp/src/racp.test.ts+++ b/packages/racp/src/racp.test.ts@@ -308,6 +308,37 @@ describe("RACP-WS remote-host profile", () => {await expect(client.request("session/get", { sessionId: "nope" })).rejects.toMatchObject({ code: "NOT_FOUND" });});+ it("derives the Host-owned first-prompt title and reports a refusal", async () => {+ const h = await harness();+ const { client, events } = await h.connect(OWNER_TOKEN);+ await client.request("events/subscribe", { scope: "host" });+ const created = await client.request<{ session: { id: string; title: string } }>("session/create", {});+ expect(created.session.title).toBe("New session");++ const derived = await client.request<{ updated: boolean }>("session/deriveTitle", {+ sessionId: created.session.id,+ title: "First prompt label",+ });+ expect(derived.updated).toBe(true);+ const after = await client.request<{ session: { title: string } }>("session/get", { sessionId: created.session.id });+ expect(after.session.title).toBe("First prompt label");+ await flush();+ expect(events.filter((event) => event.scope === "host").map((event) => event.kind)).toEqual([+ "session.created",+ "session.changed",+ ]);++ // A session that left the placeholder state refuses the fallback.+ const stale = await client.request<{ updated: boolean }>("session/deriveTitle", {+ sessionId: created.session.id,+ title: "Second label",+ });+ expect(stale.updated).toBe(false);+ await expect(client.request("session/deriveTitle", { sessionId: created.session.id })).rejects.toMatchObject({+ code: "INVALID_ARGUMENT",+ });+ });+it("serves projects and bounded workspace reads and maps Host path errors to stable codes", async () => {const h = await harness();const { client } = await h.connect(OWNER_TOKEN);diff --git a/packages/racp/src/test-harness.ts b/packages/racp/src/test-harness.tsindex 2d69ff9fc..7bbcacc08 100644--- a/packages/racp/src/test-harness.ts+++ b/packages/racp/src/test-harness.ts@@ -156,6 +156,14 @@ export function fakeOperations(sessions: Map<string, SessionSummary>): RacpHostOconst current = sessions.get(sessionId);if (current) sessions.set(sessionId, { ...current, title });},+ async deriveTitle(sessionId, title) {+ const current = sessions.get(sessionId);+ // The fake mirrors the Host rule: a session renamed to something else+ // already left the placeholder state and refuses the fallback.+ if (!current || current.title !== "New session" || title === current.title) return false;+ sessions.set(sessionId, { ...current, title });+ return true;+ },async delete(sessionId) {sessions.delete(sessionId);},diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.tsindex c5085b2f3..5369ac7ff 100644--- a/packages/shared/src/protocol.ts+++ b/packages/shared/src/protocol.ts@@ -136,6 +136,8 @@ export const IPC = {sessionOpen: "pi-desktop/session/open",sessionDelete: "pi-desktop/session/delete",sessionRename: "pi-desktop/session/rename",+ /** Deterministic first-prompt title for a session that is still untitled. */+ sessionDeriveTitle: "pi-desktop/session/deriveTitle",sessionConfigure: "pi-desktop/session/configure",sessionImportScan: "pi-desktop/session/importScan",sessionImportRun: "pi-desktop/session/importRun",diff --git a/packages/shared/src/racp.ts b/packages/shared/src/racp.tsindex a62a67990..8bd8e7386 100644--- a/packages/shared/src/racp.ts+++ b/packages/shared/src/racp.ts@@ -552,6 +552,8 @@ export const RACP_OPERATIONS = {"session/configure": { role: "controller", profile: "remote-host", mutation: true },"session/fork": { role: "controller", profile: "remote-host", mutation: true },"session/rename": { role: "controller", profile: "remote-host", mutation: true },+ /** The Host's own deterministic first-prompt title; never a controller choice. */+ "session/deriveTitle": { role: "controller", profile: "remote-host", mutation: true },"session/delete": { role: "owner", profile: "remote-host", mutation: true },"session/compact": { role: "controller", profile: "remote-host", mutation: true },"workspace/list": { role: "viewer", profile: "remote-host", mutation: false },