Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f

### Fixes & Improvements

- **Goal mode is available to native clients.** `goal` RPC commands (`create`, `get`, `pause`, `resume`, `drop`) are forwarded to omp unchanged, and `get_state` carries omp's `goal` snapshot (an absent field stays absent on older omp). Native apps can now start, show and control a running goal; `goal_updated` frames already streamed.
- **In-app updates work when ompweb runs as a systemd service.** The update worker ran inside the service's cgroup, so stopping the server killed the worker too: nothing was installed, the service could stay down (`Restart=on-failure` does not restart a clean SIGTERM exit), and every page load reopened the update dialog at "Stop ompweb-managed sessions". The worker now runs in its own transient scope (`systemd-run --scope`) and stops, updates and starts the unit through `systemctl`, starting it again if the install fails.
- **An update whose worker died is reported as failed.** A running update whose worker process is gone, or whose lease has expired, now becomes a failed attempt the dialog can show and clean up, instead of waiting forever.
- **The Provider Usage header stays put while its list scrolls.** Scrolling a long provider list in the sidebar also scrolled the section header (title, window toggle, refresh) out of view, on desktop and mobile. Only the list scrolls now.
Expand Down
24 changes: 24 additions & 0 deletions lib/pi-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ export type UsageLimitState =

export type SlowModeScope = "session" | "global";

/** omp's goal record (`goal` command reply, `goal_updated`, `get_state.goal.goal`). */
export interface GoalInfo {
id: string;
objective: string;
/** `active` / `paused`; completed and dropped goals answer `null` instead. */
status: string;
tokenBudget?: number;
tokensUsed: number;
timeUsedSeconds: number;
createdAt: number;
updatedAt: number;
}

/** Mirror of omp's GoalModeState: the `goal` reply and the `goal` field of `get_state`. */
export interface GoalModeState {
enabled: boolean;
mode: string;
goal: GoalInfo | null;
}

export interface ModelLike {
id: string;
provider: string;
Expand Down Expand Up @@ -102,6 +122,8 @@ export interface RpcSessionState {
tokensPerSecond?: number | null;
/** Structured skill resolution diagnostics; absent on older OMP builds. */
skillDiagnostics?: SkillDiagnosticsSnapshot;
/** omp goal mode; absent on older OMP builds (never invented here). */
goal?: GoalModeState | null;
}

/**
Expand Down Expand Up @@ -140,6 +162,8 @@ export interface WebSessionState {
/** Parsed public diagnostics DTO; absent means unsupported or malformed. */
skillDiagnostics?: SkillDiagnosticsSnapshot;
todoPhases: TodoPhase[];
/** omp goal mode snapshot; omitted when the child predates the `goal` field. */
goal?: GoalModeState | null;
extensionStatuses: Array<{ key: string; text: string }>;
extensionWidgets: Array<{ key: string; lines: string[]; placement: "aboveEditor" | "belowEditor" }>;
}
Expand Down
67 changes: 67 additions & 0 deletions lib/rpc-manager.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,73 @@ test("commands with no omp equivalent fail with a clear unsupported error", asyn
}
});

test("goal commands reach omp verbatim and answer its goal payload", async () => {
const { AgentSessionWrapper } = await runtimeJiti.import("./rpc-manager.ts");
const goal = {
id: "goal-1", objective: "ship the export", status: "active", tokenBudget: 2000,
tokensUsed: 0, timeUsedSeconds: 0, createdAt: 1, updatedAt: 1,
};
const reply = { goal, state: { enabled: true, mode: "active", goal } };
const sent = [];
const fakeProc = {
isAlive: true,
onFrame: () => () => {},
sendCommand: async (command, timeoutMs) => {
sent.push({ command, timeoutMs });
return reply;
},
sendFrame: () => {},
dispose: async () => {},
};
const wrapper = new AgentSessionWrapper(fakeProc, process.cwd());
wrapper.start();
try {
const command = { type: "goal", op: "create", objective: "ship the export", token_budget: 2000 };
const result = await wrapper.send(command);
assert.deepEqual(sent.map(({ command: forwarded }) => forwarded), [command]);
assert.equal(sent[0].timeoutMs, undefined, "goal keeps the passthrough's unbounded wait");
assert.deepEqual(result, reply, "native clients need omp's {goal, state} shape");
} finally {
await wrapper.destroyAndWait();
}
});

test("get_state forwards omp's goal snapshot and omits an absent field", async () => {
const { AgentSessionWrapper } = await runtimeJiti.import("./rpc-manager.ts");
const goal = {
id: "goal-2", objective: "keep going", status: "paused", tokensUsed: 3,
timeUsedSeconds: 7, createdAt: 2, updatedAt: 3,
};
let rawState = {
sessionId: "goal-state",
sessionFile: "/tmp/goal-state.jsonl",
isStreaming: false,
isCompacting: false,
goal: { enabled: true, mode: "active", goal },
};
const fakeProc = {
isAlive: true,
onFrame: () => () => {},
sendCommand: async (command) => command.type === "get_state" ? rawState : {},
sendFrame: () => {},
dispose: async () => {},
};
const wrapper = new AgentSessionWrapper(fakeProc, process.cwd());
wrapper.start();
try {
const state = await wrapper.send({ type: "get_state" });
assert.deepEqual(state.goal, rawState.goal);
// An older omp has no `goal` field: the server must not invent `null`,
// which native clients read as "omp explicitly has no goal".
rawState = { ...rawState };
delete rawState.goal;
const legacy = await wrapper.send({ type: "get_state" });
assert.equal(Object.hasOwn(legacy, "goal"), false);
} finally {
await wrapper.destroyAndWait();
}
});

test("terminal completion retains response evidence without retaining the unpersisted message", async (t) => {
const { wrapper, emit } = snapshotSession(t, async () => ({
sessionId: "observed-response", isStreaming: false, isCompacting: false,
Expand Down
6 changes: 6 additions & 0 deletions lib/rpc-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ const PASSTHROUGH_COMMANDS = new Set([
"btw",
"btw_cancel",
"get_btw_history",
// Goal mode (`{type:"goal", op}`) has the same shape as omp's RPC frame and
// is the only way native clients reach it; every op answers `{goal, state}`.
"goal",
]);

// Outlasts omp's cold prediction-daemon start (up to 3 × 30s start rounds plus a
Expand Down Expand Up @@ -1577,6 +1580,9 @@ export class AgentSessionWrapper {
usageLimit: state.usageLimit,
...(skillDiagnostics ? { skillDiagnostics } : {}),
todoPhases: state.todoPhases ?? [],
// Clients distinguish "no goal" (explicit null) from "omp does not know
// goals" (field absent), so an absent field stays absent.
...(state.goal !== undefined ? { goal: state.goal } : {}),
extensionStatuses: Array.from(this.extensionStatuses, ([key, text]) => ({ key, text })),
extensionWidgets: Array.from(this.extensionWidgets.values()),
};
Expand Down