Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
Merge pull request #107 from multica-ai/fix/new-user-onboarding
Bohan Jiangb7085b2bf522
diff --cc src/agent/runner.tsindex 9433d8bc01,7d63bfe545..3deef81e03--- a/src/agent/runner.ts+++ b/src/agent/runner.ts@@@ -356,49 -355,12 +359,54 @@@ export class Agent}}+ /** Emit an error event through the subscriber mechanism */+ emitError(message: string): void {+ this.emitMulticaEvent({ type: "agent_error", message });+ }+async run(prompt: string): Promise<AgentRunResult> {+ // Run-level mutex: prevents concurrent run/runInternal from mis-tagging messages+ return this.withRunMutex(() => this._run(prompt));+ }++ /**+ * Run a prompt as an internal turn.+ * Messages are persisted with `internal: true` and rolled back from+ * in-memory state after the turn completes, so they do not pollute+ * the main conversation context.+ */+ async runInternal(prompt: string): Promise<AgentRunResult> {+ return this.withRunMutex(async () => {+ const messageCountBefore = this.agent.state.messages.length;+ this._internalRun = true;+ try {+ const result = await this._run(prompt);+ return result;+ } finally {+ this._internalRun = false;+ // Roll back internal messages from in-memory state+ const current = this.agent.state.messages;+ if (current.length > messageCountBefore) {+ this.agent.replaceMessages(current.slice(0, messageCountBefore));+ }+ }+ });+ }++ private async withRunMutex<T>(fn: () => Promise<T>): Promise<T> {+ // Chain on the mutex so only one run executes at a time+ const prev = this._runMutex;+ let resolve: () => void;+ this._runMutex = new Promise<void>((r) => { resolve = r; });+ await prev;+ try {+ return await fn();+ } finally {+ resolve!();+ }+ }++ private async _run(prompt: string): Promise<AgentRunResult> {await this.ensureInitialized();this.output.state.lastAssistantText = "";