mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-17 13:05:06 +00:00
move pi-mono into companion-cloud as apps/companion-os
- Copy all pi-mono source into apps/companion-os/ - Update Dockerfile to COPY pre-built binary instead of downloading from GitHub Releases - Update deploy-staging.yml to build pi from source (bun compile) before Docker build - Add apps/companion-os/** to path triggers - No more cross-repo dispatch needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
0250f72976
579 changed files with 206942 additions and 0 deletions
103
packages/coding-agent/test/streaming-render-debug.ts
Normal file
103
packages/coding-agent/test/streaming-render-debug.ts
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* Debug script to reproduce streaming rendering issues.
|
||||
* Uses real fixture data that caused the bug.
|
||||
* Run with: npx tsx test/streaming-render-debug.ts
|
||||
*/
|
||||
|
||||
import type { AssistantMessage } from "@mariozechner/pi-ai";
|
||||
import { ProcessTerminal, TUI } from "@mariozechner/pi-tui";
|
||||
import { readFileSync } from "fs";
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { AssistantMessageComponent } from "../src/modes/interactive/components/assistant-message.js";
|
||||
import { initTheme } from "../src/modes/interactive/theme/theme.js";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
// Initialize dark theme with full color support
|
||||
process.env.COLORTERM = "truecolor";
|
||||
initTheme("dark");
|
||||
|
||||
// Load the real fixture that caused the bug
|
||||
const fixtureMessage: AssistantMessage = JSON.parse(
|
||||
readFileSync(
|
||||
join(__dirname, "fixtures/assistant-message-with-thinking-code.json"),
|
||||
"utf-8",
|
||||
),
|
||||
);
|
||||
|
||||
// Extract thinking and text content
|
||||
const thinkingContent = fixtureMessage.content.find(
|
||||
(c) => c.type === "thinking",
|
||||
);
|
||||
const textContent = fixtureMessage.content.find((c) => c.type === "text");
|
||||
|
||||
if (!thinkingContent || thinkingContent.type !== "thinking") {
|
||||
console.error("No thinking content in fixture");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const fullThinkingText = thinkingContent.thinking;
|
||||
const fullTextContent =
|
||||
textContent && textContent.type === "text" ? textContent.text : "";
|
||||
|
||||
async function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const terminal = new ProcessTerminal();
|
||||
const tui = new TUI(terminal);
|
||||
|
||||
// Start with empty message
|
||||
const message = {
|
||||
role: "assistant",
|
||||
content: [{ type: "thinking", thinking: "" }],
|
||||
} as AssistantMessage;
|
||||
|
||||
const component = new AssistantMessageComponent(message, false);
|
||||
tui.addChild(component);
|
||||
tui.start();
|
||||
|
||||
// Simulate streaming thinking content
|
||||
let thinkingBuffer = "";
|
||||
const chunkSize = 10; // characters per "token"
|
||||
|
||||
for (let i = 0; i < fullThinkingText.length; i += chunkSize) {
|
||||
thinkingBuffer += fullThinkingText.slice(i, i + chunkSize);
|
||||
|
||||
// Update message content
|
||||
const updatedMessage = {
|
||||
role: "assistant",
|
||||
content: [{ type: "thinking", thinking: thinkingBuffer }],
|
||||
} as AssistantMessage;
|
||||
|
||||
component.updateContent(updatedMessage);
|
||||
tui.requestRender();
|
||||
|
||||
await sleep(15); // Simulate token delay
|
||||
}
|
||||
|
||||
// Now add the text content
|
||||
await sleep(500);
|
||||
|
||||
const finalMessage = {
|
||||
role: "assistant",
|
||||
content: [
|
||||
{ type: "thinking", thinking: fullThinkingText },
|
||||
{ type: "text", text: fullTextContent },
|
||||
],
|
||||
} as AssistantMessage;
|
||||
|
||||
component.updateContent(finalMessage);
|
||||
tui.requestRender();
|
||||
|
||||
// Keep alive for a moment to see the result
|
||||
await sleep(3000);
|
||||
|
||||
tui.stop();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Loading…
Add table
Add a link
Reference in a new issue