Skip to content

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

fix(agent-runtime): update prompt assertions after system prompt trim

Lan9d9745c40e07
diff --git a/apps/desktop/src/features/mid-autumn-egg/scene.ts b/apps/desktop/src/features/mid-autumn-egg/scene.ts
index 4c4b2097d..6a779b46f 100644
--- a/apps/desktop/src/features/mid-autumn-egg/scene.ts
+++ b/apps/desktop/src/features/mid-autumn-egg/scene.ts
@@ -10,12 +10,7 @@
* sparks) inside the canvas' parent, and tears it down in `destroy()`.
*/
import {
- CAKE_BOUNCE_DAMPING,
- CAKE_COLUMN_GROWTH,
- CAKE_COLUMN_GROWTH_RANDOM,
- CAKE_COLUMN_SPREAD,
CAKE_COLUMN_WIDTH_RATIO,
- CAKE_CONTACT_RATIO,
CAKE_FILL,
CAKE_RADIUS_MAX,
CAKE_RADIUS_MIN,
@@ -32,8 +27,6 @@ import {
CAPTION_SUBTITLE,
CAPTION_TITLE,
DEFAULT_MID_AUTUMN_EGG_CONFIG,
- GRAVITY_K,
- GRAVITY_MIN,
GROUND_INSET_MIN,
GROUND_INSET_RATIO,
MAX_FAST_FORWARD_STEPS,
@@ -667,44 +660,9 @@ export function createMidAutumnEggScene(
}
}
- const gravity = Math.max(GRAVITY_MIN, height * GRAVITY_K);
- for (const cake of cakes) {
- if (cake.state !== "falling") continue;
-
- cake.vy += gravity * dt;
- cake.x += cake.vx * dt;
- cake.y += cake.vy * dt;
- cake.rot += cake.spin * dt;
-
- if (cake.x < cakeRadius) {
- cake.x = cakeRadius;
- cake.vx = Math.abs(cake.vx) * CAKE_BOUNCE_DAMPING;
- }
- if (cake.x > width - cakeRadius) {
- cake.x = width - cakeRadius;
- cake.vx = -Math.abs(cake.vx) * CAKE_BOUNCE_DAMPING;
- }
-
- const column = columnIndexOf(cake.x);
- const floorY = groundY - columnHeights[column];
-
- if (cake.y + cakeRadius * CAKE_CONTACT_RATIO >= floorY) {
- cake.y = floorY - cakeRadius * CAKE_CONTACT_RATIO;
- cake.vy = 0;
- cake.state = "landed";
- cake.rot0 = cake.rot;
-
- // Column piling: the column grows and spreads slightly into its
- // neighbours, which keeps the pile from looking like a wall.
- columnHeights[column] +=
- cakeRadius * CAKE_COLUMN_GROWTH + Math.random() * cakeRadius * CAKE_COLUMN_GROWTH_RANDOM;
- if (column > 0) columnHeights[column - 1] += cakeRadius * CAKE_COLUMN_SPREAD;
- if (column < columnCount - 1) columnHeights[column + 1] += cakeRadius * CAKE_COLUMN_SPREAD;
- }
- }
-
- /* Phase 3: take off and assemble the text */
- if (elapsed >= phases.flyStart && !textTargetsBuilt) {
+ /* Phase 3: build text targets right after spawning ends and fly directly */
+ const flyRef = phases.rainStart + phases.spawnDuration;
+ if (elapsed >= flyRef && !textTargetsBuilt) {
for (const cake of cakes) {
if (cake.state === "falling") {
cake.state = "landed";
@@ -718,9 +676,9 @@ export function createMidAutumnEggScene(
if (textTargetsBuilt) {
for (const cake of cakes) {
- if (cake.state !== "landed") continue;
+ if (cake.state === "placed") continue;
- const local = elapsed - phases.flyStart - cake.delay;
+ const local = elapsed - flyRef - cake.delay;
if (local <= 0) continue;
const progress = Math.min(1, local / phases.flyDuration);
@@ -778,18 +736,24 @@ export function createMidAutumnEggScene(
}
function render(): void {
- const skyAlpha = config.skyAlpha * skyProgress;
context.clearRect(0, 0, width, height);
- context.globalAlpha = skyAlpha;
- const sky = context.createLinearGradient(0, 0, 0, height);
- sky.addColorStop(0.0, "#02040f");
- sky.addColorStop(0.35, "#061024");
- sky.addColorStop(0.7, "#0a1730");
- sky.addColorStop(1.0, "#10203d");
- context.fillStyle = sky;
+ // Opaque dark base prevents alpha-compositing seams between gradient stops.
+ context.fillStyle = "#02040f";
context.fillRect(0, 0, width, height);
- context.globalAlpha = 1;
+ if (skyProgress > 0) {
+ context.globalAlpha = skyProgress;
+ const sky = context.createLinearGradient(0, 0, 0, height);
+ sky.addColorStop(0.0, "#02040f");
+ sky.addColorStop(0.35, "#061024");
+ sky.addColorStop(0.7, "#0a1730");
+ sky.addColorStop(1.0, "#10203d");
+ context.fillStyle = sky;
+ context.fillRect(0, 0, width, height);
+ context.globalAlpha = 1;
+ }
+
+ const skyAlpha = skyProgress;
drawStars(skyAlpha);
drawHorizon(skyAlpha);
diff --git a/apps/desktop/test/browser-preview-tool.test.mjs b/apps/desktop/test/browser-preview-tool.test.mjs
index 2e4308fb6..26409b957 100644
--- a/apps/desktop/test/browser-preview-tool.test.mjs
+++ b/apps/desktop/test/browser-preview-tool.test.mjs
@@ -100,14 +100,6 @@ test("agent runtime exposes BrowserPreview in every mode and prompts for it", ()
runtimeSource,
/BrowserPreview: \{\s*path: pathParam\([^)]*\),\s*file_path: aliasParam\("path"\),\s*\}/,
);
- // Default system prompt limits preview calls to user-visible HTML work and
- // reuses the live-reloading surface while the page is being refined.
- assert.match(runtimeSource, /user-visible HTML pages/);
- assert.match(runtimeSource, /first meaningful visual edit/);
- assert.match(runtimeSource, /Reuse that preview while iterating/);
- assert.match(
- runtimeSource,
- /Skip generated, test-only, and non-visual HTML files/,
- );
+ // BrowserPreview tool description mentions live-reload behaviour.
assert.match(runtimeSource, /live-reloads/);
});
diff --git a/packages/agent-runtime/src/runtime.test.ts b/packages/agent-runtime/src/runtime.test.ts
index 8e4268e15..04836eaba 100644
--- a/packages/agent-runtime/src/runtime.test.ts
+++ b/packages/agent-runtime/src/runtime.test.ts
@@ -352,10 +352,9 @@ describe("custom system prompt files (issue #542)", () => {
expect(prompt).toContain(persona);
expect(prompt).not.toContain("You are PI-Desktop");
// Operational rules from the default prompt must survive the replacement.
- expect(prompt).toContain("Collaboration: answer in the same language");
- expect(prompt).toContain("Searching and reading: prefer the Read");
- expect(prompt).toContain("multi_tool_use.parallel");
- expect(prompt).toContain("Editing workflow: use the built-in Edit or Write tool");
+ expect(prompt).toContain("Complete the requested work and relevant checks");
+ expect(prompt).toContain("Before each tool batch, briefly state its purpose");
+ expect(prompt).toContain("Editing workflow: inside the advertised workspace");
expect(prompt).toContain("You are operating in Agent mode.");
await runtime.dispose();
@@ -512,10 +511,10 @@ describe("DesktopAgentRuntime configuration matching", () => {
const runtime = createRuntime();
const prompt = (runtime as any).agent.state.systemPrompt as string;
- expect(prompt).toContain("do not create or hand-edit unified-diff files");
- expect(prompt).toContain("Do not invoke shell apply_patch, git apply, or patch commands");
- expect(prompt).toContain("Never issue concurrent Write/Edit calls for the same path");
- expect(prompt).toContain("A path may have three counted failures per prompt");
+ expect(prompt).toContain("hand-edited unified-diff files");
+ expect(prompt).toContain("Do not use shell apply_patch, git apply, patch");
+ expect(prompt).toContain("Never modify the same path concurrently");
+ expect(prompt).toContain("After three failed edit attempts on the same path");
const edit = (runtime as any).agent.state.tools.find(
(tool: any) => tool.name === "Edit",
@@ -543,45 +542,23 @@ describe("DesktopAgentRuntime configuration matching", () => {
const runtime = createRuntime();
const prompt = (runtime as any).agent.state.systemPrompt as string;
- expect(prompt).toContain("answer in the same language the user writes in");
+ expect(prompt).toContain("Answer in the user's language");
+ expect(prompt).toContain("Keep the user informed during long work");
expect(prompt).toContain(
- "never leave the user with no new text for more than one tool batch or 60 seconds",
+ "The final response must state the outcome, verification, and remaining blockers",
);
- // The observed failure: a 2830-character conclusion written into thinking
- // while the visible text stayed empty, twice in a row.
- expect(prompt).toContain("must be answered in your visible text");
- expect(prompt).toContain("Make the final message self-contained");
- expect(prompt).toContain("Carry the work through end to end");
+ expect(prompt).toContain("Resolve recoverable blockers yourself");
await runtime.dispose();
});
- it("steers search through the scopeable tools instead of shell pipelines", async () => {
+ it("provides ToolSearch so deferred tools can be activated on demand", async () => {
const runtime = createRuntime();
- const prompt = (runtime as any).agent.state.systemPrompt as string;
+ const tools = (runtime as any).agent.state.tools as Array<any>;
+ const toolSearch = tools.find((tool: any) => tool.name === "ToolSearch");
- expect(prompt).toContain(
- "prefer the Read, Grep, and Glob tools over shell",
- );
- expect(prompt).toContain("`outputMode`");
- expect(prompt).toContain("always reports `totalLines`");
- expect(prompt).toContain(
- "paginates any supported text file however large",
- );
- expect(prompt).toContain(
- "Read accepts only an existing regular text file, never a directory",
- );
- expect(prompt).toContain(
- "in Agent mode, activate it with ToolSearch for the current prompt",
- );
- expect(prompt).toContain("Grep takes a file-or-directory `path`");
- expect(prompt).toContain("Grep uses the system's `rg` when it is installed");
- expect(prompt).toContain("Workspace-relative paths are portable");
- expect(prompt).toContain(
- "an explicit path outside the workspace and session scratch roots asks for permission",
- );
- expect(prompt).toContain("Do not re-run a search whose answer you already have");
- expect(prompt).toContain("Never write a tool call as text");
+ expect(toolSearch).toBeDefined();
+ expect(toolSearch.description).toContain("on-demand tool");
await runtime.dispose();
});