mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-27 10:45:29 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2253818f0 |
@@ -30,7 +30,7 @@ Terminal directory snapshots (`terminalsChanged`) and workspace contribution cha
|
||||
|
||||
Each `onChange` delivers both the new snapshot and the `previous` one (`{ state, changedAt }`). The transition flows unchanged up through `TerminalSession.onActivityChange` (as `{ activity, previous }`), the worker protocol's `terminalActivityChange` event, and the manager-level `subscribeTerminalActivity(listener)` stream (`{ terminalId, name, cwd, activity, previous }`).
|
||||
|
||||
The daemon consumes these transitions, not snapshots. When a transition moves from `working` to `idle`, the tracker records finished attention, so the terminal shows the same green finished dot as an idle agent that needs review. The websocket layer also fires a "Terminal finished" attention notification. A terminal that exits while still working emits no turn-end notification.
|
||||
The daemon consumes these transitions, not snapshots. When a transition moves from `working` to `idle`, the tracker records finished attention, so the terminal shows the same green finished dot as an idle agent that needs review. Focusing the terminal tab or using Mark as read on its owning workspace clears finished attention. Mark as read leaves needs-input attention alone, the same way it leaves an agent's pending permission. The websocket layer also fires a "Terminal finished" attention notification. A terminal that exits while still working emits no turn-end notification.
|
||||
|
||||
Terminal list visibility is `workspaceId`-scoped: a terminal belongs to the workspace that created it, and same-`cwd` sibling workspaces do not see it in their terminal lists. Terminal status routing starts from that owning workspace, uses the owning workspace's `cwd`, then fans the status bucket out to every active workspace with the same `cwd`.
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ import type {
|
||||
TerminalManager,
|
||||
TerminalWorkspaceContributionChangedEvent,
|
||||
} from "../terminal/terminal-manager.js";
|
||||
import type { TerminalSession } from "../terminal/terminal.js";
|
||||
import { TerminalSessionController } from "../terminal/terminal-session-controller.js";
|
||||
import type { TerminalActivity } from "@getpaseo/protocol/terminal-activity";
|
||||
import type { BinaryFrame } from "@getpaseo/protocol/binary-frames/index";
|
||||
@@ -5942,9 +5943,7 @@ export class Session {
|
||||
);
|
||||
}
|
||||
|
||||
private async listTerminalActivityContributions(): Promise<
|
||||
Array<{ cwd: string; workspaceId?: string; activity: TerminalActivity | null }>
|
||||
> {
|
||||
private async listAllTerminals(): Promise<TerminalSession[]> {
|
||||
const terminalManager = this.terminalManager;
|
||||
if (!terminalManager) {
|
||||
return [];
|
||||
@@ -5953,7 +5952,30 @@ export class Session {
|
||||
const terminalsByDirectory = await Promise.all(
|
||||
directories.map((cwd) => terminalManager.getTerminals(cwd)),
|
||||
);
|
||||
return terminalsByDirectory.flat().map((session) => {
|
||||
return terminalsByDirectory.flat();
|
||||
}
|
||||
|
||||
// A terminal belongs to the workspace it carries, whatever its cwd. Needs-input stays: the
|
||||
// terminal is still waiting on the user, like an agent's pending permission.
|
||||
private async clearWorkspaceTerminalAttention(workspaceId: string): Promise<void> {
|
||||
const terminalManager = this.terminalManager;
|
||||
if (!terminalManager) {
|
||||
return;
|
||||
}
|
||||
const finishedTerminals = (await this.listAllTerminals()).filter(
|
||||
(terminal) =>
|
||||
terminal.workspaceId === workspaceId &&
|
||||
terminal.getActivity()?.attentionReason === "finished",
|
||||
);
|
||||
for (const terminal of finishedTerminals) {
|
||||
await terminalManager.clearTerminalAttention(terminal.id);
|
||||
}
|
||||
}
|
||||
|
||||
private async listTerminalActivityContributions(): Promise<
|
||||
Array<{ cwd: string; workspaceId?: string; activity: TerminalActivity | null }>
|
||||
> {
|
||||
return (await this.listAllTerminals()).map((session) => {
|
||||
const contribution: { cwd: string; workspaceId?: string; activity: TerminalActivity | null } =
|
||||
{
|
||||
cwd: session.cwd,
|
||||
@@ -8579,6 +8601,7 @@ export class Session {
|
||||
await this.agentManager.clearAgentAttention(agentId);
|
||||
clearedAgentIds.push(agentId);
|
||||
}
|
||||
await this.clearWorkspaceTerminalAttention(workspace.workspaceId);
|
||||
|
||||
await this.emitWorkspaceUpdateForWorkspaceId(workspace.workspaceId);
|
||||
results.push({
|
||||
|
||||
@@ -8913,6 +8913,88 @@ test("terminal activity contribution change updates the correct workspace", asyn
|
||||
});
|
||||
});
|
||||
|
||||
async function createWorkspaceWithTerminals(name: string) {
|
||||
const emitted: SessionOutboundMessage[] = [];
|
||||
const cwd = mkdtempSync(path.join(tmpdir(), `paseo-session-${name}-`));
|
||||
const workspace = createPersistedWorkspaceRecord({
|
||||
workspaceId: `ws-${name}`,
|
||||
projectId: `proj-${name}`,
|
||||
cwd,
|
||||
kind: "directory",
|
||||
displayName: name,
|
||||
createdAt: "2026-03-01T12:00:00.000Z",
|
||||
updatedAt: "2026-03-01T12:00:00.000Z",
|
||||
});
|
||||
const project = createPersistedProjectRecord({
|
||||
projectId: `proj-${name}`,
|
||||
rootPath: cwd,
|
||||
kind: "non_git",
|
||||
displayName: name,
|
||||
createdAt: "2026-03-01T12:00:00.000Z",
|
||||
updatedAt: "2026-03-01T12:00:00.000Z",
|
||||
});
|
||||
const { session, terminalManager } = await createSessionWithTerminalManager({
|
||||
workspaces: [workspace],
|
||||
projects: [project],
|
||||
onMessage: (message) => emitted.push(message),
|
||||
});
|
||||
const createTerminal = () =>
|
||||
terminalManager.createTerminal({ cwd, workspaceId: workspace.workspaceId });
|
||||
return { emitted, workspace, session, terminalManager, createTerminal };
|
||||
}
|
||||
|
||||
test("workspace clear attention clears a finished terminal in the workspace", async () => {
|
||||
const { emitted, workspace, session, terminalManager, createTerminal } =
|
||||
await createWorkspaceWithTerminals("clear-terminal");
|
||||
const terminal = await createTerminal();
|
||||
await terminalManager.setTerminalActivity(terminal.id, "working");
|
||||
await terminalManager.setTerminalActivity(terminal.id, "idle");
|
||||
await waitForWorkspaceUpdate(
|
||||
emitted,
|
||||
(message) =>
|
||||
message.payload.kind === "upsert" &&
|
||||
message.payload.workspace.id === workspace.workspaceId &&
|
||||
message.payload.workspace.status === "attention",
|
||||
"a finished terminal marks the workspace for attention",
|
||||
);
|
||||
|
||||
await session.handleMessage({
|
||||
type: "workspace.clear_attention.request",
|
||||
workspaceId: workspace.workspaceId,
|
||||
requestId: "req-clear-terminal",
|
||||
});
|
||||
|
||||
expect(findByType(emitted, "workspace.clear_attention.response").payload).toMatchObject({
|
||||
requestId: "req-clear-terminal",
|
||||
success: true,
|
||||
});
|
||||
expect(terminalManager.getTerminal(terminal.id)?.getActivity()?.attentionReason ?? null).toBe(
|
||||
null,
|
||||
);
|
||||
const lastUpdate = filterByType(emitted, "workspace_update").findLast(
|
||||
(message) =>
|
||||
message.payload.kind === "upsert" && message.payload.workspace.id === workspace.workspaceId,
|
||||
);
|
||||
expect(lastUpdate?.payload).toMatchObject({ workspace: { status: "done" } });
|
||||
});
|
||||
|
||||
test("workspace clear attention keeps a terminal that needs input", async () => {
|
||||
const { session, workspace, terminalManager, createTerminal } =
|
||||
await createWorkspaceWithTerminals("keep-needs-input");
|
||||
const terminal = await createTerminal();
|
||||
await terminalManager.setTerminalActivity(terminal.id, "attention");
|
||||
|
||||
await session.handleMessage({
|
||||
type: "workspace.clear_attention.request",
|
||||
workspaceId: workspace.workspaceId,
|
||||
requestId: "req-keep-needs-input",
|
||||
});
|
||||
|
||||
expect(terminalManager.getTerminal(terminal.id)?.getActivity()?.attentionReason).toBe(
|
||||
"needs_input",
|
||||
);
|
||||
});
|
||||
|
||||
test("same-cwd terminal activity updates only the workspace that owns the terminal", async () => {
|
||||
const emitted: SessionOutboundMessage[] = [];
|
||||
const cwd = mkdtempSync(path.join(tmpdir(), "paseo-session-same-cwd-"));
|
||||
|
||||
Reference in New Issue
Block a user