Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions AGENTS.md

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to **tau** (`@ompweb-dev/tau`) are documented in this file.

### Added

- **A conversation copied to another machine is flagged in the sidebar.** When two hosts list the same session id (its file was copied between machines), the sidebar shows one row, on this machine if it is here, and its status line says which other hosts also have it ("Also on Build box"). tau does not keep such copies apart: commands, deletes and archives act on the copy whose process runs, else on the one shown, and a delete also clears state kept by the id (GitHub watches, retry history) for both.
- **The Files tab has a search field, and file icons show their language.** The field above the tree is always there (the panel's search toggle is gone): type to list matching files by name, Escape clears it and returns to the tree. File icons carry their language's colour (TypeScript and C/C++ blue, headers purple, JavaScript and JSON yellow, Python and Go teal, and so on), and C, C++, C#, Java, Kotlin, Swift, Ruby, PHP, Lua, Zig, CMake and 3D model files get labels of their own.
- **The composer shows its hints and marks line references.** An empty composer reads "Ask anything" followed by its shortcuts (@ files, / commands, ! shell; a shortcut that does not fit is left out whole). A line range mentioned from a file (`@src/main.cpp:27-28`) is drawn as a chip in the text; it stays ordinary text, so it is edited, deleted and sent as before.
- **Answer a waiting question from the notification itself.** A notification for a blocking dialog (confirm, select, input, editor, or the ask tool's questions) carries the dialog when it fits a push in full, so a phone or a native client can answer without opening the session: `POST /api/notifications/answer` takes the session id, the dialog's request id and one response. The answer goes through the same path as the web dialog and is checked against the pending dialog first; a settled dialog's notification is retracted on every open tab. (ompweb-dev/ompweb#414)
Expand All @@ -20,10 +21,10 @@ All notable changes to **tau** (`@ompweb-dev/tau`) are documented in this file.
### Changed

- **tau runs on Bun only.** Every command in the npm package (`tau`, `tau host`, the tray, the service installers) runs on the Bun on `PATH` (1.4.4 or newer) and refuses Node.js, and so do the update workers. The package no longer bundles Bun or jiti. Install with `bun add -g @ompweb-dev/tau` (or `npm install -g` with Bun on `PATH`); an earlier version cannot update itself to this one from Settings (its updater runs the new release on Node, which refuses it), and services it installed run the launcher on Node: install this version by hand and install the services again. The single binary is unchanged.
- **Search, the file index and session deletes follow what is on screen.**
- **Search and the file index follow what is on screen.**
- The Files and Search tabs search the folder the panel shows, instead of always the conversation's working directory, as long as it is one of the conversation's own folders: its project, or a folder in it. A conversation whose worktree was removed searches its repository again instead of failing. Another worktree of the same repository is refused.
- Text search no longer holds up the host while it resolves paths, and hard-linked files (a pnpm store, for example) are no longer each put through the full credential check.
- Deleting or archiving a conversation, and checking a reopened tab's conversation still exists, act on the host its row or tab names (`?hostId=`), so a conversation whose id exists on two hosts is never deleted on the other one.
- A deleted or archived conversation leaves its host's cached session list at once, so it does not reappear while that host's list is refreshed.

- **Session rows have a status line.** Under each conversation's title the sidebar says what it is doing and how old it is: Ready, Running, Needs input, Stopped or Done (finished while you were elsewhere), with Draft when an unsent message waits, then its age ("Ready · 2h"). The age left the row's right edge, which keeps only the activity mark and the menu.
- **The chat's own controls float at its top right.** Full history, Branches and System prompt left the top bar for a small toolbar over the top right of the selected chat (the one the top bar's title names); the branch list and the system prompt open below it. The top bar keeps the sidebar, theme, language and command palette on the left and the conversation title in the middle.
Expand All @@ -42,10 +43,6 @@ All notable changes to **tau** (`@ompweb-dev/tau`) are documented in this file.

### Fixed

- **A session id on two hosts runs as two sessions on the server.** Each host's copy has its own live process, exit mark and command queue; `POST`/`GET /api/agent/[id]?hostId=`, the `session` event channel's `hostId` and `POST /api/notifications/answer`'s `hostId` name one copy. A request without a host takes a live copy (this machine's first), else the host that lists the id.
- **The browser keeps each host's copy of a session apart.** Every agent command and state read names its host (`/api/agent/[id]?hostId=`, `local` for this machine); a chat follows only its own copy's run, and switching between two copies of an id is switching sessions. The sidebar's running, needs-input, stopped, finished and recently-completed marks belong to one copy, a notification names its host (`hostId` on the event) so viewing one copy does not silence the other and its click opens the right copy, and each copy has its own composer draft. Drafts, goals, sidebar marks and notification tags, history ids and presence all use one key, `<hostId>/<id>` (`local/<id>` for this machine); stored drafts, unread marks, recent runs and notification history keys change once (pre-alpha: no migration).
- **A `hostId` that is not a host id is refused.** `/api/agent/[id]`, `/api/sessions/[id]/*` and `POST /api/notifications/answer` answer 400 `invalid_host_id` for an empty value or one with characters other than letters, digits, `-` and `_`. The `running` event frame and `GET /api/sessions` no longer carry `runningSessionIds` (use `runningSessions`).
- **Held messages and GitHub watches keep each host's copy of a session apart.** Outbox entries record their host (`host_id` in `outbox.db`; `hostId` on `OutboxEntry` and browser entries, posted as `?hostId=`); an add naming no host whose host cannot be determined yet answers a retryable 503 instead of being stored. Pre-alpha: messages held from before this change are bound to this machine; one for a remote session is not shown in that session's chat and cannot be retried there, so send it again; delivery, claims, wakes, retry lineage, archive holds and deletes act on that copy only. GitHub watches, pending updates, read grants and Actions receipts are keyed by host and session; a GitHub watch store from before this change is dropped once (pre-alpha: watches must be set again).
- **In-app updates can replace an npm-global Windows install started by the tray.** The update stops the tray and any process still using that install and runs the install from outside the package, so Windows can rename it. (ompweb-dev/ompweb#519)
- **A host update's failed candidate is stopped on Windows even when it got the old daemon's pid.** (ompweb-dev/ompweb#526)
- **In-app updates work on a Windows install without administrator rights.** Task Scheduler's service host is recognized without reading its executable path. (ompweb-dev/ompweb#539)
Expand Down
6 changes: 2 additions & 4 deletions app/api/agent/[id]/bash-output/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { apiErrorResponse, hostIdParam, opErrorResponse, resolveWorkspaceHost } from "@/lib/api-utils";
import { apiErrorResponse, opErrorResponse, resolveWorkspaceHost } from "@/lib/api-utils";
import { workspaceReadStream } from "@/lib/workspace-http";

export async function GET(
Expand All @@ -10,9 +10,7 @@ export async function GET(
const query = new URL(request.url).searchParams;
const path = query.get("path");
if (!path) return Response.json({ error: "path required" }, { status: 400 });
const named = hostIdParam(query.get("hostId"));
if ("response" in named) return named.response;
const resolved = await resolveWorkspaceHost(named.hostId ?? undefined, id);
const resolved = await resolveWorkspaceHost(query.get("hostId") ?? undefined, id);
if ("response" in resolved) return resolved.response;
const { host } = resolved;
if (query.get("download") === "1") {
Expand Down
18 changes: 5 additions & 13 deletions app/api/agent/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { getLiveRpcSession, WebRpcError } from "@/lib/rpc-manager";
import { getRpcSession, WebRpcError } from "@/lib/rpc-manager";
import { commandErrorResponse, runAgentCommand } from "@/lib/agent-command";
import { parseJsonWithinLimit } from "@/lib/bounded-form-data";
import { MAX_AGENT_COMMAND_REQUEST_BYTES } from "@/lib/image-attachments";
import { requestOwner } from "@/lib/web-auth";
import { hostIdParam } from "@/lib/api-utils";

/** Stamp when the handler had the request and when it answered, so the browser
* can split network time from server time. */
Expand All @@ -13,7 +12,7 @@ function timed(receivedAt: number, res: Response): Response {
return res;
}

// POST /api/agent/[id]?hostId= - Send a command to an existing session (that host's copy when named)
// POST /api/agent/[id] - Send a command to an existing session
export async function POST(
req: Request,
{ params }: { params: Promise<{ id: string }> }
Expand All @@ -26,9 +25,7 @@ export async function POST(
try {
const body = await parseJsonWithinLimit<unknown>(req, MAX_AGENT_COMMAND_REQUEST_BYTES);
receivedAt = Date.now();
const host = hostIdParam(new URL(req.url).searchParams.get("hostId"));
if ("response" in host) return timed(receivedAt, host.response);
return timed(receivedAt, await runAgentCommand(id, body, requestOwner(req), { hostId: host.hostId }));
return timed(receivedAt, await runAgentCommand(id, body, requestOwner(req)));
} catch (error) {
return timed(receivedAt ?? Date.now(), commandErrorResponse(error));
}
Expand All @@ -42,15 +39,10 @@ export async function GET(
const { id } = await params;
// Default stays the full shape; `?systemPrompt=0` drops the ~13 KB prompt
// from the 15 s state poll. Any other value (including "1") keeps it.
const { searchParams } = new URL(req.url);
const includeSystemPrompt = searchParams.get("systemPrompt") !== "0";
const includeSystemPrompt = new URL(req.url).searchParams.get("systemPrompt") !== "0";

const host = hostIdParam(searchParams.get("hostId"));
if ("response" in host) return host.response;
try {
// `?hostId=`: only that host's copy; the same id live on another host is another session.
// Without one, a live copy: a dead wrapper on this machine must not hide a live one elsewhere.
const session = getLiveRpcSession(id, host.hostId);
const session = getRpcSession(id);
if (!session || !session.isAlive()) {
return Response.json({ running: false });
}
Expand Down
9 changes: 2 additions & 7 deletions app/api/notifications/answer/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { hostIdParam } from "@/lib/api-utils";
import { commandErrorResponse } from "@/lib/agent-command";
import { parseJsonWithinLimit, RequestBodyTooLargeError } from "@/lib/bounded-form-data";
import type { ExtensionUiResponse, RpcAskDialogAnswer } from "@/lib/pi-types";
import { getLiveRpcSession, isAskAnswers } from "@/lib/rpc-manager";
import { getRpcSession, isAskAnswers } from "@/lib/rpc-manager";
import { isRecord } from "@/lib/type-guards";

/** Answers are text; 64 KB leaves room for a long ask customInput without becoming a payload channel. */
Expand Down Expand Up @@ -64,11 +63,7 @@ export async function POST(req: Request) {
const response = parseResponse(body.response);
if (!response) return invalid("response must be exactly one of value, confirmed, cancelled or answers");

const host = hostIdParam(body.hostId);
if ("response" in host) return host.response;
const { hostId } = host;
// `hostId`: only that host's copy of the id; without it, as before (this machine's copy first).
const session = getLiveRpcSession(body.sessionId, hostId);
const session = getRpcSession(body.sessionId);
if (!session || !session.isAlive()) return Response.json({ status: "sessionGone" });

try {
Expand Down
19 changes: 8 additions & 11 deletions app/api/sessions/[id]/archive/route.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { apiErrorResponse, hostIdParam, hostOfflineResponse, opErrorResponse, resolveSessionHostOr404 } from "@/lib/api-utils";
import { apiErrorResponse, hostOfflineResponse, opErrorResponse, resolveSessionHostOr404 } from "@/lib/api-utils";
import { HostOpError } from "@/lib/hosts/link-protocol";
import { invalidateHostSessionList } from "@/lib/hosts/session-index";
import { clearExitedRpcSession, getRpcSession } from "@/lib/rpc-manager";

/** POST /api/sessions/[id]/archive?hostId= — stop the live child, then archive the
* native pi JSONL and its sibling artifacts (lib/pi/archive.ts), on the row's host. */
/** POST /api/sessions/[id]/archive — stop the live child, then archive the
* native pi JSONL and its sibling artifacts (lib/pi/archive.ts). */
export async function POST(
req: Request,
_req: Request,
{ params }: { params: Promise<{ id: string }> },
) {
const { id } = await params;
try {
const host = hostIdParam(new URL(req.url).searchParams.get("hostId"));
if ("response" in host) return host.response;
const resolved = await resolveSessionHostOr404(id, host.hostId);
const resolved = await resolveSessionHostOr404(id);
if ("response" in resolved) return resolved.response;
const { sessionOps } = resolved.host;
// Parent-session paths are native branch metadata. Moving only a parent
Expand All @@ -32,13 +30,12 @@ export async function POST(
// Disposing a child behind a down link would wait for the link to return.
const offline = hostOfflineResponse(resolved.host);
if (offline) return offline;
// Only this host's child: the same id live on another host is another session.
const live = getRpcSession(id, resolved.host.id);
if (live && !live.hostOwnedLifecycle) await live.destroyAndWait?.("archive", true);
const live = getRpcSession(id);
if (!live?.hostOwnedLifecycle) await live?.destroyAndWait?.("archive", true);
const result = await sessionOps.archiveSession(id);
if (!result.ok) return opErrorResponse(result);
invalidateHostSessionList(resolved.host.id, id);
clearExitedRpcSession(id, resolved.host.id);
clearExitedRpcSession(id);
return Response.json({ ok: true, archived: true, archivedPath: result.value.archivedPath });
} catch (error) {
if (error instanceof HostOpError) return apiErrorResponse(error);
Expand Down
14 changes: 5 additions & 9 deletions app/api/sessions/[id]/auto-name/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { deriveSessionTitleFromFirstMessage, sanitizeSessionTitle } from "@/lib/
import { getRpcSession } from "@/lib/rpc-manager";
import { invalidateHostSessionList } from "@/lib/hosts/session-index";
import { HostOpError } from "@/lib/hosts/link-protocol";
import { apiErrorResponse, hostIdParam, opErrorResponse, resolveSessionHostOr404 } from "@/lib/api-utils";
import { apiErrorResponse, opErrorResponse, resolveSessionHostOr404 } from "@/lib/api-utils";

/**
* POST /api/sessions/[id]/auto-name
Expand All @@ -12,16 +12,13 @@ import { apiErrorResponse, hostIdParam, opErrorResponse, resolveSessionHostOr404
* there is one, else as a session_info entry in the file). `generated` is always false.
*/
export async function POST(
req: Request,
_req: Request,
{ params }: { params: Promise<{ id: string }> },
) {
const { id } = await params;

try {
const host = hostIdParam(new URL(req.url).searchParams.get("hostId"));
if ("response" in host) return host.response;
const { hostId } = host;
const resolved = await resolveSessionHostOr404(id, hostId);
const resolved = await resolveSessionHostOr404(id);
if ("response" in resolved) return resolved.response;
const { sessionOps } = resolved.host;

Expand All @@ -40,13 +37,12 @@ export async function POST(
}

// The session list read yielded; Edit may now own this session.
if (getRpcSession(id, resolved.host.id)?.isEditingHistory()) {
if (getRpcSession(id)?.isEditingHistory()) {
return Response.json({ error: "Wait for the history edit to finish", code: "session_busy" }, { status: 409 });
}

// A live pi holds the session: name it there. Otherwise append to the file.
// The resolved host's copy: another host's live copy of the id is another session.
const rpc = getRpcSession(id, resolved.host.id);
const rpc = getRpcSession(id);
let named = false;
if (rpc?.isAlive?.()) {
try {
Expand Down
13 changes: 5 additions & 8 deletions app/api/sessions/[id]/context/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { buildSessionContext } from "@/lib/session-reader";
import { apiErrorResponse, hostIdParam, ifNoneMatchSatisfied, opErrorResponse, resolveSessionHostOr404, strongEtag } from "@/lib/api-utils";
import { getLiveRpcSession } from "@/lib/rpc-manager";
import { apiErrorResponse, ifNoneMatchSatisfied, opErrorResponse, resolveSessionHostOr404, strongEtag } from "@/lib/api-utils";
import { getRpcSession } from "@/lib/rpc-manager";
import { MAX_SYNC_MESSAGES, parseHistoryCursor, selectSessionHistory, type SessionHistoryCursor, type SessionHistoryPage, type SessionSyncResponse } from "@/lib/session-sync";

/**
Expand Down Expand Up @@ -29,9 +29,6 @@ export async function GET(
const { id } = await params;
const url = new URL(req.url);
const leafId = url.searchParams.get("leafId") ?? undefined;
const host = hostIdParam(url.searchParams.get("hostId"));
if ("response" in host) return host.response;
const { hostId } = host;
const deferThinking = url.searchParams.has("deferThinking");
const deferToolResultImages = url.searchParams.has("deferMedia");
// Read-only transcript mode: include entries omitted from the active agent context.
Expand Down Expand Up @@ -67,7 +64,7 @@ export async function GET(
}

try {
const resolved = await resolveSessionHostOr404(id, hostId);
const resolved = await resolveSessionHostOr404(id);
// A live session resolves to its host even before its file exists; the host then answers 404.
const result = "response" in resolved ? resolved : await resolved.host.sessionOps.readContext(id, leafId, {
deferThinking,
Expand All @@ -82,7 +79,7 @@ export async function GET(
// and its persisted boundary is empty (the next prompt must not 404).
// Never replace previously confirmed history when its file is missing.
const notFound = "response" in result ? result.response.status === 404 : result.status === 404;
const session = notFound && (boundary === "1" || (sync === "1" && !cursor?.lastEntryId && leafId === undefined)) ? getLiveRpcSession(id, "host" in resolved ? resolved.host.id : hostId) : undefined;
const session = notFound && (boundary === "1" || (sync === "1" && !cursor?.lastEntryId && leafId === undefined)) ? getRpcSession(id) : undefined;
if (session?.isAlive() && !(await session.host.sessionFileExists(session.sessionFile))) {
if (boundary === "1") {
return jsonBodyResponse(req, { entryIds: [] }, "no-store");
Expand All @@ -104,7 +101,7 @@ export async function GET(
const page = result.value as { history: SessionHistoryPage; leafId: string | null; tipId: string | null };
// Sample AFTER the disk read: a quiet active run still supplies its most
// recent partial output, and events arriving during the read win.
const session = "host" in resolved ? getLiveRpcSession(id, resolved.host.id) : undefined;
const session = getRpcSession(id);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
const live = session?.isAlive() && (leafId === undefined || leafId === page.tipId)
? session.getStreamSnapshot()
: null;
Expand Down
Loading
Loading