Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

chore(composer): refresh line references against current main

Linuxdazhao92d039aa4575
diff --cc apps/desktop/src/lib/api.ts
index 0f8ee5b2e,79ac5abc8..0513b06d2
--- a/apps/desktop/src/lib/api.ts
+++ b/apps/desktop/src/lib/api.ts
@@@ -1940,31 -1970,8 +1970,18 @@@ export const api =
});
});
},
+ /**
+ * A plugin offered one line for the composer, or the main process ordered
+ * whatever is on screen dropped (`pi.composer.suggest`, ADR 0333).
+ *
+ * The shell answers every offer over `pluginComposerSuggestionResult`, because
+ * only the renderer knows whether the draft can take it. A malformed message
+ * is ignored — nothing here decides whether a plugin's suggestion is valid.
+ */
+ onComposerFileLines: (listener: (payload: { sessionId: string; reference: import("@pi-desktop/shared").FileLineReference }) => void) =>
+ window.piDesktop?.on?.(IPC.event.composerFileLines, (payload) => listener(payload as Parameters<typeof listener>[0])) ?? (() => {}),
- onPluginComposerSuggestion: (
- listener: (
- event:
- | {
- kind: "offer";
- requestId: string;
- pluginId: string;
- sessionId: string;
- turnId?: string;
- text: string;
- expiresAt: number;
- }
- | { kind: "clear"; pluginId?: string; sessionId?: string },
- ) => void,
- ) => {
+ /** Shell-only composer target, offer and clear messages. */
+ onPluginComposerSuggestion: (listener: (event: ComposerSuggestionMessage) => void) => {
if (!window.piDesktop?.on) return () => undefined;
return window.piDesktop.on(IPC.event.pluginComposerSuggestion, (payload) => {
const event = payload as {
diff --cc apps/desktop/test/plugin-provider-catalog-ipc.test.mjs
index 11bb04522,9faa48e94..e631f7087
--- a/apps/desktop/test/plugin-provider-catalog-ipc.test.mjs
+++ b/apps/desktop/test/plugin-provider-catalog-ipc.test.mjs
@@@ -50,43 -49,6 +51,43 @@@ function loadPluginUiIpc({ gateFactory
return module.exports.registerPluginUiIpc;
}
+test("File Manager view capabilities survive Host unavailability without a registry query on open", async () => {
+ const handlers = new Map();
+ const views = [];
+ const loaded = {
+ development: false,
+ disposing: false,
+ permissions: new Set(["ui.view", "fs.read"]),
+ path: "/plugins/file-manager",
+ manifest: { version: "0.9.0", contributes: { views: [{ id: "manager", entry: "index.html" }] } },
+ };
+ let hostQueries = 0;
+ const host = { call: async () => { hostQueries++; throw new Error("Host restarting"); } };
+ loadPluginUiIpc()({
- registrar: { handle: (channel, handler) => handlers.set(channel, handler) },
++ registrar: { handle: (channel, handler) => handlers.set(channel, handler), handleWithEvent() {} },
+ plugins: { getLoaded: () => loaded },
+ getHost: () => host,
+ pluginViews: { open: (view) => views.push(view) },
+ pluginActiveInProject: () => true,
+ currentWorkspacePath: () => "/project",
+ getUpdaterLocale: () => "en",
+ getPluginPanelTheme: () => "dark",
+ });
+ const open = async (pluginId = "pi.file-manager") => {
+ await handlers.get(IPC.invoke.pluginViewOpen)({ pluginId, viewId: "manager" });
+ return views.at(-1).composerFileLines;
+ };
+ assert.equal(await open(), true);
+ assert.equal(await open("other.plugin"), false);
+ loaded.development = true;
+ assert.equal(await open(), false);
+ loaded.development = false;
+ assert.equal(await open(), true);
+ loaded.permissions.delete("fs.read");
+ assert.equal(await open(), false);
+ assert.equal(hostQueries, 0);
+});
+
test("the plugin Add Service IPC returns declared categories through the Host handler", async () => {
const handlers = new Map();
const plugin = (id, name, permissions, category) => ({
diff --cc packages/agent-runtime/src/runtime.test.ts
index db929ab3f,6b5a94437..194f46eae
--- a/packages/agent-runtime/src/runtime.test.ts
+++ b/packages/agent-runtime/src/runtime.test.ts
@@@ -28,8 -31,7 +31,8 @@@ import
type RuntimeMatchConfig,
type RuntimeProviderConfig,
} from "./runtime.js";
- import { estimateOutputCapInputTokens } from "./output-cap.js";
+ import { estimateOutputCapInputTokens, requestTranscript } from "./output-cap.js";
+import { builtinModeDefinition } from "./mode-definitions.js";
import { COMPACTION_SUMMARY_MAX_RETRIES } from "./compaction-summary-input.js";
import { loadInstructionChain, type ProjectInstructions } from "./project-instructions.js";
diff --cc packages/agent-runtime/src/runtime.ts
index 00d5d0dd2,e6fbd2a06..aa174d98c
--- a/packages/agent-runtime/src/runtime.ts
+++ b/packages/agent-runtime/src/runtime.ts
@@@ -9550,9 -9632,8 +9715,11 @@@ Do not invent objections or turn specul
if (selectedTools.length) this.activateDeferredTools(selectedTools);
this.setAgentTools(this.activeTools());
if (modePromptChanged) this.setAgentSystemPrompt(this.composeSystemPrompt());
+ const completion = typeof input === "string" ? undefined : input.backgroundCompletion;
+ const completionEntries = completion ? this.historyToEntries([completion]) : [];
+ if (typeof modelInput !== "string" && modelInput.attachments?.some(attachment => attachment.lineRange !== undefined)) {
+ modelInput = await this.resolveFileLineReferences(modelInput);
+ }
const content = promptContent(modelInput);
const incomingUserMessage: AgentMessage = {
role: "user",
diff --cc packages/i18n/src/locales/en/index.ts
index 4a1f1b0bb,47481b60c..c8d1b6b0d
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@@ -376,9 -385,11 +385,12 @@@ deleteRunningSessionBlocked: "Stop the
placeholderHomeHint: "Type / for commands · @ for files",
placeholderShortcut: "Shift+Enter for newline · Use Send to submit",
suggestionHint: "Tab to accept · Esc to ignore",
+ suggestionPosition: "{{current}} of {{total}}",
+ suggestionPrevious: "Previous suggestion",
+ suggestionNext: "Next suggestion",
addFiles: "Add files",
filesAttached: "Added {{count}} item(s) to the draft",
+ fileLineReferenceLimit: "Add up to {{count}} file line references per message.",
filesPasted: "Saved {{count}} pasted file(s) to the session scratch folder",
largeTextPasted: "Saved large pasted text as @{{name}}",
slashMenu: "Commands",
diff --cc packages/i18n/src/locales/ko/index.ts
index 7b6664ed2,2c504b872..edab6be71
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@@ -378,9 -387,11 +387,12 @@@ export const ko =
placeholderHomeHint: "명령은 / · 파일은 @ 입력",
placeholderShortcut: "줄바꿈은 Shift+Enter · 보내기를 눌러 제출",
suggestionHint: "Tab 수락 · Esc 무시",
+ suggestionPosition: "{{total}}개 중 {{current}}번째",
+ suggestionPrevious: "이전 제안",
+ suggestionNext: "다음 제안",
addFiles: "파일 추가",
filesAttached: "초안에 항목 {{count}}개 추가됨",
+ fileLineReferenceLimit: "메시지 하나에 파일 줄 참조를 최대 {{count}}개 추가할 수 있습니다.",
filesPasted: "붙여넣은 파일 {{count}}개를 세션 임시 폴더에 저장함",
largeTextPasted: "큰 붙여넣기 텍스트를 @{{name}}으로 저장함",
slashMenu: "명령",
diff --cc packages/i18n/src/locales/pt-BR/index.ts
index 346a74477,1b16179ef..b731a0209
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@@ -368,9 -377,11 +377,12 @@@ export const ptBR =
placeholderHomeHint: "Digite / para comandos · @ para arquivos",
placeholderShortcut: "Shift+Enter para inserir uma quebra de linha · Use Enviar para enviar",
suggestionHint: "Tab aceitar · Esc descartar",
+ suggestionPosition: "{{current}} de {{total}}",
+ suggestionPrevious: "Sugestão anterior",
+ suggestionNext: "Próxima sugestão",
addFiles: "Adicionar arquivos",
filesAttached: "{{count}} item(ns) adicionado(s) ao rascunho",
+ fileLineReferenceLimit: "Adicione até {{count}} referências a linhas de arquivo por mensagem.",
filesPasted: "{{count}} arquivo(s) colado(s) salvo(s) na pasta temporária da sessão",
largeTextPasted: "Texto longo colado salvo como @{{name}}",
slashMenu: "Comandos",
diff --cc packages/i18n/src/locales/tr/index.ts
index 283a9fb11,8e460d989..fd23ecb4d
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@@ -378,9 -387,11 +387,12 @@@ export const tr =
placeholderHomeHint: "Komutlar için / · dosyalar için @ yazın",
placeholderShortcut: "Yeni satır için Shift+Enter · göndermek için Gönder",
suggestionHint: "Tab kabul · Esc yoksay",
+ suggestionPosition: "{{current}} / {{total}}",
+ suggestionPrevious: "Önceki öneri",
+ suggestionNext: "Sonraki öneri",
addFiles: "Dosya ekle",
filesAttached: "Taslağa {{count}} öğe eklendi",
+ fileLineReferenceLimit: "Her mesaja en fazla {{count}} dosya satırı başvurusu ekleyebilirsiniz.",
filesPasted: "Yapıştırılan {{count}} dosya oturum klasörüne kaydedildi",
largeTextPasted: "Uzun yapıştırılan metin @{{name}} olarak kaydedildi",
slashMenu: "Komutlar",
diff --cc packages/i18n/src/locales/zh-CN/index.ts
index 9957b51f2,d54437011..3f65cad5d
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@@ -371,9 -380,11 +380,12 @@@ deleteRunningSessionBlocked: "请先停
placeholderHomeHint: "输入 / 使用命令 · @ 引用文件",
placeholderShortcut: "Shift+Enter 换行 · 点击发送提交",
suggestionHint: "Tab 接受 · Esc 忽略",
+ suggestionPosition: "第 {{current}} 条,共 {{total}} 条",
+ suggestionPrevious: "上一条建议",
+ suggestionNext: "下一条建议",
addFiles: "添加文件",
filesAttached: "已将 {{count}} 项加入草稿",
+ fileLineReferenceLimit: "每条消息最多可添加 {{count}} 处文件行引用。",
filesPasted: "已将 {{count}} 个粘贴文件保存到会话临时目录",
largeTextPasted: "已将大段粘贴文本保存为 @{{name}}",
slashMenu: "指令",
diff --cc packages/i18n/src/locales/zh-TW/index.ts
index da1418be8,82b697218..3aa08d381
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@@ -371,9 -380,11 +380,12 @@@ deleteRunningSessionBlocked: "請先停
placeholderHomeHint: "輸入 / 使用命令 · @ 引用檔案",
placeholderShortcut: "Shift+Enter 換行 · 點擊發送提交",
suggestionHint: "Tab 接受 · Esc 忽略",
+ suggestionPosition: "第 {{current}} 則,共 {{total}} 則",
+ suggestionPrevious: "上一則建議",
+ suggestionNext: "下一則建議",
addFiles: "新增檔案等內容",
filesAttached: "已將 {{count}} 項加入草稿",
+ fileLineReferenceLimit: "每則訊息最多可新增 {{count}} 處檔案行引用。",
filesPasted: "已將 {{count}} 個貼上檔案儲存到會話臨時目錄",
largeTextPasted: "已將大段貼上文本儲存為 @{{name}}",
slashMenu: "指令",