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

- **Git commands stay on the folder's own repository.** A host daemon started from a Git hook or with `GIT_DIR` set in its environment no longer runs Git status, file search, worktree, clone or pool preparation against that other repository. The Git panel of a bare repository now reports "not a Git repository" instead of failing. On Windows pool workers, a long creation ID no longer makes preparation fail on Git's path-length limit, and the reported CPU busy time no longer counts interrupt time twice.
- **Multiple-choice questions show which options are already checked.** When omp asks one checkbox question at a time, each option now shows ☑ or ☐, and screen readers announce "checked" or "not checked". Before, every option looked unchecked, so tapping an option the agent had pre-checked unchecked it instead. In the composer, tapping a checkbox option now toggles it at once instead of waiting for **Next**, so choosing **Done selecting** next can no longer drop it. This needs an omp that sends checkbox state on `select` requests (can1357/oh-my-pi#18929); older omp versions show the options as before.
Comment thread
andrebrait marked this conversation as resolved.
Resolved
- **Reuse unchanged chat Markdown during streaming.** Markdown bodies skip rendering when their props are unchanged, while relevant tool-result changes still refresh their message. Back/forward session navigation requests the selected session instead of downloading the full session list.
- **Listing files in a folder that is not a Git repository no longer leaves a `git` process running in it.** The @-mention and file-search index asks Git first; when the folder is not a repository it now waits for both Git queries to exit before falling back to reading the folder. A leftover `git` process could briefly keep Windows from deleting or renaming that folder.
- **Dollar amounts no longer render as math.** In text such as “$5 and $10”, the span between the two dollar signs turned into glued italic formula text. Single-dollar math now follows Pandoc's rule: the opening `$` must be followed by a non-space, and the closing `$` must be preceded by a non-space and not followed by a digit. `$x^2$` still renders as math.
Comment thread
andrebrait marked this conversation as resolved.
Resolved
Expand Down
98 changes: 97 additions & 1 deletion components/ExtensionDialog.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "../tests/setup-dom.mjs";
import assert from "node:assert/strict";
import test, { afterEach } from "node:test";
import React from "react";
const { cleanup, fireEvent, render, screen } = await import("@testing-library/react/pure.js");
const { cleanup, fireEvent, render, screen, waitFor } = await import("@testing-library/react/pure.js");

const { ExtensionDialog } = await import("./ExtensionDialog.tsx");
afterEach(cleanup);
Expand Down Expand Up @@ -73,6 +73,102 @@ test("question selection survives request replay but is cleared for the next que
}
});

test("omp's checkbox select shows which options are already checked", async () => {
const request = {
type: "extension_ui_request",
id: "jobs-1",
method: "select",
title: "(2 selected) Choose enabled jobs",
options: ["pytest", "go-quality", "lint", "Other (type your own)", "✓ Done selecting"],
selectionMarker: "checkbox",
checkedIndices: [0, 1],
markableCount: 3,
};
const view = render(React.createElement(ExtensionDialog, { request, onRespond: () => {} }));
try {
// Accessible names carry the state; the visible glyph is aria-hidden.
for (const name of ["pytest, checked", "go-quality, checked", "lint, not checked", "Other (type your own)", "✓ Done selecting"]) {
screen.getByRole("button", { name });
}
assert.equal(screen.getByRole("button", { name: "pytest, checked" }).textContent, "☑pytest, checked");
assert.equal(screen.getByRole("button", { name: "lint, not checked" }).textContent, "☐lint, not checked");
} finally {
view.unmount();
}
});

test("attached checkbox select sends each toggle at once, so Done cannot replace it", async () => {
const request = {
type: "extension_ui_request",
id: "jobs-2",
method: "select",
title: "Choose enabled jobs",
options: ["pytest", "lint", "✓ Done selecting"],
selectionMarker: "checkbox",
checkedIndices: [],
markableCount: 2,
};
const responses = [];
const dialog = (current) => React.createElement(ExtensionDialog, {
request: current,
onRespond: (answered, response) => {
responses.push({ id: answered.id, ...response });
return Promise.resolve(true);
},
attached: true,
});
const view = render(dialog(request));
try {
fireEvent.click(screen.getByRole("button", { name: "lint, not checked" }));
assert.deepEqual(responses, [{ id: "jobs-2", value: "lint" }]);
// omp takes one answer per request: the options are disabled until the next request arrives.
assert.equal(screen.getByRole("button", { name: "pytest, not checked" }).disabled, true);
fireEvent.click(screen.getByRole("button", { name: "pytest, not checked" }));
assert.equal(responses.length, 1);

// The next request carries the toggle; the action row waits for Next.
view.rerender(dialog({ ...request, id: "jobs-3", checkedIndices: [1] }));
fireEvent.click(screen.getByRole("button", { name: "✓ Done selecting" }));
assert.equal(responses.length, 1);
fireEvent.click(screen.getByRole("button", { name: "Next" }));
assert.deepEqual(responses[1], { id: "jobs-3", value: "✓ Done selecting" });
} finally {
view.unmount();
}
});

test("a checkbox toggle that fails to send can be tried again", async () => {
const request = {
type: "extension_ui_request",
id: "jobs-4",
method: "select",
title: "Choose enabled jobs",
options: ["pytest", "✓ Done selecting"],
selectionMarker: "checkbox",
checkedIndices: [],
markableCount: 1,
};
const responses = [];
const results = [false, true];
const view = render(React.createElement(ExtensionDialog, {
request,
onRespond: (answered, response) => {
responses.push({ id: answered.id, ...response });
return Promise.resolve(results.shift());
},
attached: true,
}));
try {
fireEvent.click(screen.getByRole("button", { name: "pytest, not checked" }));
await waitFor(() => assert.equal(screen.getByRole("button", { name: "pytest, not checked" }).disabled, false));
fireEvent.click(screen.getByRole("button", { name: "pytest, not checked" }));
assert.deepEqual(responses, [{ id: "jobs-4", value: "pytest" }, { id: "jobs-4", value: "pytest" }]);
assert.equal(screen.getByRole("button", { name: "pytest, not checked" }).disabled, true);
} finally {
view.unmount();
}
});

test("ExtensionDialog masks sensitive input and toggles visibility", async () => {
const request = {
type: "extension_ui_request",
Expand Down
32 changes: 26 additions & 6 deletions components/ExtensionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ export function ExtensionDialog({
attached = false,
}: {
request: ExtensionDialogRequest;
onRespond: (request: ExtensionDialogRequest, response: ExtensionDialogResponse) => void;
/** Resolves `false` when the answer could not be sent, so the panel takes another answer. */
onRespond: (request: ExtensionDialogRequest, response: ExtensionDialogResponse) => void | Promise<boolean>;
/** Render as a composer panel instead of a full-chat overlay. */
attached?: boolean;
}) {
Expand All @@ -247,6 +248,10 @@ export function ExtensionDialog({
// `pointerType` of the latest press: the pointer media query only describes
// the primary pointer, not the one pressing now.
const pressPointerRef = useRef<string | null>(null);
// omp takes one answer per request id and the panel stays up until the next request arrives, so the
// select controls are disabled in that window instead of sending a tap omp would silently drop.
const [answeredId, setAnsweredId] = useState<string | null>(null);
const awaitingNext = request.method === "select" && answeredId === request.id;
const [askDrafts, setAskDrafts] = useState(() => initialAskDrafts(request));
const viewportMaxHeight = useViewportMaxHeight();
const { touchTargets } = useTouchTargets();
Expand Down Expand Up @@ -278,9 +283,16 @@ export function ExtensionDialog({
// task, so the phone keyboard closes once instead of flashing as the
// focused field disappears from under it.
const respond = (response: ExtensionDialogResponse) => {
if (request.method === "select") {
if (awaitingNext) return;
setAnsweredId(request.id);
}
const active = document.activeElement;
if (active instanceof HTMLElement && panelRef.current?.contains(active)) active.blur();
onRespond(request, response);
const id = request.id;
void Promise.resolve(onRespond(request, response)).then((sent) => {
if (sent === false) setAnsweredId((current) => current === id ? null : current);
});
};
const cancel = () => respond({ cancelled: true });

Expand Down Expand Up @@ -415,13 +427,19 @@ export function ExtensionDialog({
)}
{request.method === "select" && (
<div style={{ display: "grid", gap: 8 }}>
{request.options.map((option) => {
{request.options.map((option, index) => {
const selected = selectedOption === option;
const checkbox = request.selectionMarker === "checkbox" && index < (request.markableCount ?? request.options.length);
const checked = checkbox && (request.checkedIndices?.includes(index) ?? false);
Comment thread
andrebrait marked this conversation as resolved.
Resolved

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test comment on PR diff file

// A checkbox toggle goes out at once even when attached: staging it for Next would let the
// next row (often "Done selecting") silently replace it, and a stray toggle is undone by one tap.
const stage = attached && !checkbox;
return (
<button
key={option}
onClick={() => attached ? setSelectedOption(option) : respond({ value: option })}
aria-pressed={attached ? selected : undefined}
onClick={() => stage ? setSelectedOption(option) : respond({ value: option })}
Comment thread
andrebrait marked this conversation as resolved.
Resolved
disabled={awaitingNext}
aria-pressed={stage ? selected : undefined}
style={{
width: "100%",
padding: "7px 10px",
Expand All @@ -438,7 +456,9 @@ export function ExtensionDialog({
onMouseEnter={attached ? undefined : (e) => { e.currentTarget.style.background = "var(--bg-hover)"; }}
onMouseLeave={attached ? undefined : (e) => { e.currentTarget.style.background = "var(--bg-panel)"; }}
>
{checkbox && <span aria-hidden="true" style={{ marginRight: 6, color: checked ? "var(--accent)" : "var(--text-dim)" }}>{checked ? "☑" : "☐"}</span>}
Comment thread
andrebrait marked this conversation as resolved.
Resolved
{option}
{checkbox && <span className="sr-only">, {t(checked ? "chatWindow.optionChecked" : "chatWindow.optionUnchecked")}</span>}
Comment thread
andrebrait marked this conversation as resolved.
Resolved
</button>
);
})}
Expand Down Expand Up @@ -712,7 +732,7 @@ export function ExtensionDialog({
) : (request.method === "select" && attached) || request.method === "ask" ? (
<button
onClick={submitValue}
disabled={!canSubmit}
disabled={!canSubmit || awaitingNext}
style={{
padding: "6px 10px",
minHeight: touchTargets === "accessible" ? 44 : undefined,
Expand Down
2 changes: 1 addition & 1 deletion graphify-out/graph.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions hooks/useAgentSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1971,11 +1971,11 @@ export function useAgentSession(opts: UseAgentSessionOptions) {
const respondToExtensionUi = useCallback(async (
request: ExtensionUiDialogRequest,
response: { value: string } | { confirmed: boolean } | { cancelled: true } | { answers: RpcAskDialogAnswer[] },
) => {
): Promise<boolean> => {
const sid = sessionIdRef.current;
if (!sid) {
setExtensionDialog((current) => current?.id === request.id ? null : current);
return;
return true;
}
// Claim the dialog before awaiting: another tab answering broadcasts a
// synchronized "cancel" for the same request id, which must not tear down
Expand All @@ -1988,19 +1988,23 @@ export function useAgentSession(opts: UseAgentSessionOptions) {
id: request.id,
...response,
});
if (!hookAliveRef.current || sessionIdRef.current !== sid) return;
if (!hookAliveRef.current || sessionIdRef.current !== sid) return true;
// Keep the answered panel mounted briefly while the next question arrives.
clearTimeout(extensionDialogClearTimerRef.current ?? undefined);
extensionDialogClearTimerRef.current = setTimeout(() => {
setExtensionDialog((current) => current?.id === request.id ? null : current);
if (locallyAnsweredDialogRef.current === request.id) locallyAnsweredDialogRef.current = null;
extensionDialogClearTimerRef.current = null;
}, 250);
return true;
} catch (e) {
console.error("Failed to send extension UI response:", e);
if (hookAliveRef.current && sessionIdRef.current === sid) {
addNotice({ type: "error", message: e instanceof Error ? e.message : String(e) });
}
// Let the panel take another answer: omp never got this one.
if (locallyAnsweredDialogRef.current === request.id) locallyAnsweredDialogRef.current = null;
return false;
}
}, [addNotice]);

Expand Down
2 changes: 2 additions & 0 deletions lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@
"chatWindow.askTitle": "Questions from the agent",
"chatWindow.askRecommended": "Recommended",
"chatWindow.askOther": "Other: type your own answer",
"chatWindow.optionChecked": "checked",
"chatWindow.optionUnchecked": "not checked",
"chatWindow.thinking": "Thinking...",
"chatWindow.subagentCount.one": "{count} subagent",
"chatWindow.subagentCount.other": "{count} subagents",
Expand Down
2 changes: 2 additions & 0 deletions lib/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@
"chatWindow.askTitle": "エージェントからの質問",
"chatWindow.askRecommended": "推奨",
"chatWindow.askOther": "その他:自由に回答を入力",
"chatWindow.optionChecked": "チェック済み",
"chatWindow.optionUnchecked": "未チェック",
"chatWindow.thinking": "思考中...",
"chatWindow.subagentCount.one": "サブエージェント {count} 件",
"chatWindow.subagentCount.other": "サブエージェント {count} 件",
Expand Down
2 changes: 2 additions & 0 deletions lib/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@
"chatWindow.askTitle": "来自智能体的问题",
"chatWindow.askRecommended": "推荐",
"chatWindow.askOther": "其他:输入你自己的答案",
"chatWindow.optionChecked": "已勾选",
"chatWindow.optionUnchecked": "未勾选",
"chatWindow.thinking": "思考中...",
"chatWindow.subagentCount.one": "{count} 个子代理",
"chatWindow.subagentCount.other": "{count} 个子代理",
Expand Down
7 changes: 7 additions & 0 deletions lib/i18n/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@
"chatWindow.askTitle": "來自代理的提問",
"chatWindow.askRecommended": "建議",
"chatWindow.askOther": "其他:自行輸入答案",
"chatWindow.optionChecked": "已勾選",
"chatWindow.optionUnchecked": "未勾選",
"chatWindow.thinking": "思考中...",
"chatWindow.subagentCount.one": "{count} 個子代理",
"chatWindow.subagentCount.other": "{count} 個子代理",
Expand Down Expand Up @@ -1450,6 +1452,11 @@
"hostsConfig.serverProtocol": "此網頁應用程式預期使用連線協定 v{version}。",
"hostsConfig.allowAgentStart": "代理可在此處直接開始對話,無需詢問",
"hostsConfig.allowAgentStartAria": "代理可在 {name} 上直接開始對話,無需詢問",
"hostsConfig.shareCredentials": "使用此伺服器的供應商登入資訊",
"hostsConfig.shareCredentialsAria": "在 {name} 上使用此伺服器的供應商登入資訊",
"hostsConfig.shareCredentialsTitle": "要與 {name} 共用認證資訊嗎?",
"hostsConfig.shareCredentialsDescription": "在 {name} 上啟動的對話將使用此伺服器的供應商登入資訊。該主機可讀取其存取權杖與已儲存的 API 金鑰,而不會使用該主機自身的登入資訊。",
"hostsConfig.shareCredentialsConfirm": "共用",
"hostsConfig.rename": "重新命名",
"hostsConfig.renameTitle": "重新命名主機",
"hostsConfig.renameAria": "重新命名 {name}",
Expand Down
5 changes: 5 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ export type ExtensionUiRequest =
method: "select";
title: string;
options: string[];
/** omp's checkbox list (ask multi-select): `checkedIndices` is the authoritative checked state. */
selectionMarker?: "radio" | "checkbox";
checkedIndices?: number[];
/** Leading options that get a marker; the rest are actions such as Other and Done. */
markableCount?: number;
timeout?: number;
expiresAt?: number;
}
Expand Down
Loading