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 @@ -37,6 +37,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
### Fixes & Improvements

- **Messages sent during a run no longer all turn into “Not sent: it may have been sent.”** After several prompts reached OMP in quick succession (for example automatic PR-update prompts), every later message to that session could fail this way while OMP still showed it, until an idle send restarted the session's OMP process. Now, at the end of each run and before an idle send, the web server asks OMP whether everything it accepted has settled, and only then trusts new messages' echoes again, without restarting OMP. Sessions shared through a host daemon recover too. Messages already marked uncertain stay that way and are never resent.
- **The file viewer highlights more file types, and you can pick the language.** `.diff` and `.patch` files now show added and removed lines in color instead of plain text, and so do `.proto`, `.ini`/`.cfg`/`.conf`, `.mk`, `.kts` and `.cc`/`.cxx`/`.hh` files. `.tsx`/`.jsx` files now color JSX tags, and `.scss` files use the SCSS grammar. For any other file, the language menu in the source view's toolbar applies a grammar by hand (or plain text); it resets to **Auto** when you open another file.
- **Delivered messages leave every shared-server chat's pending list.** When another web-server process delivers a message from the shared outbox, open chats now receive its updated state and delivery confirmation without switching sessions or reloading. Startup retries resync existing chats, observer failures cannot interrupt delivery or other observers, and pending, failed and delivered messages retain their historical session identities through repeated native moves. Per-session revisions prevent unrelated database writes from resending unchanged chat payloads.
- **A pending message is replaced, never dropped.** With an OMP that reports `supportsClientMessageIds`, each message carries its outbox ID to OMP, and the pending row stays until that exact message, queue entry or explicit withdrawal appears in the chat, even when another server delivers it or its echo arrives late. If OMP no longer has any trace of it (its process ended, or `/new` ran while it was queued), the row turns into **Not sent: it may have been sent** and can be dismissed. An older OMP is sent messages as before and their rows clear on delivery.
- **Anthropic stays visible when usage limits are unavailable.** The Provider Usage panel keeps accounts that omp reports without usage data and marks them as unavailable rather than unlimited.
Expand Down
46 changes: 45 additions & 1 deletion app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,10 @@ html[data-touch-targets="accessible"] :is(.image-lightbox-stepper button, .image
min-height: 35px;
}

.file-viewer-shell {
container: file-viewer / inline-size;
}

.file-viewer-path {
flex: 1 1 auto;
min-width: 48px;
Expand Down Expand Up @@ -1661,6 +1665,45 @@ html[data-touch-targets="accessible"] :is(.image-lightbox-stepper button, .image
filter: brightness(1.08);
}

.file-viewer-language-select {
height: 24px;
max-width: 140px;
Comment on lines +1668 to +1670

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep source toolbar controls visible in narrow file panels

At the supported 300px desktop panel width (RIGHT_PANEL_MIN_WIDTH), viewing a modified Markdown/HTML file in Source mode now clips the mode switch and Download button. The new selector joins .file-viewer-actions and .file-viewer-controls, both of which have flex-shrink: 0, in a toolbar that never wraps; .file-viewer-shell then hides the overflow. This pushes Preview/Diff outside the visible panel after switching to Source. Reflow or collapse the controls based on the panel width so the selector does not displace existing actions.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 2dce731: below 440px of panel width (a container query on the viewer, so it follows the panel, not the viewport) the toolbar wraps: the path keeps the first row, the controls move to their own right-aligned row and wrap again rather than shrink, and the metadata label hides. Checked at 300/360/440/900px in Source and Preview: no control extends past the panel.

padding: 0 6px;
border: 1px solid var(--border);
border-radius: var(--radius-control);
background: var(--bg);
color: var(--text-muted);
font: inherit;
font-size: 11px;
cursor: pointer;
}

.file-viewer-language-select:hover {
color: var(--text);
}

/* A narrow panel moves the controls to their own row, wrapping them again
rather than clipping the view modes or Download. */
@container file-viewer (max-width: 440px) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔥 The Roast: CSS Container Queries (@container) are cool and all — Chrome 105, Firefox 110, Safari 16. If your user base includes anyone on older browsers (Enterprise Chrome, ancient Safari), the responsive toolbar just... doesn't wrap. No fallback, no @supports guard. The layout breaks silently.

🩹 The Fix: Wrap the container query in @supports (container-type: inline-size) { ... } or provide a media-query fallback for the narrow layout. Or just document the browser requirement since this is a dev tool.

📏 Severity: suggestion

@andrebrait andrebrait Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not adding a fallback: the repository already relies on unguarded @container rules in several places (sidebar, composer, breadcrumb, table charts), and this follows that convention. Known limit: a browser without container queries (before Chrome 105, Firefox 110 or Safari 16) keeps the single-row toolbar, so in a narrow panel the new picker can push the last controls out of view there.

.file-viewer-toolbar {
flex-wrap: wrap;
row-gap: 5px;
}

.file-viewer-meta {
display: none;
}

.file-viewer-controls {
flex-shrink: 1;
flex-wrap: wrap;
justify-content: flex-end;
row-gap: 5px;
min-width: 0;
margin-left: auto;
}
}

.file-viewer-icon-button {
display: inline-flex;
align-items: center;
Expand Down Expand Up @@ -1695,7 +1738,8 @@ html[data-touch-targets="accessible"] :is(.image-lightbox-stepper button, .image
}

.file-viewer-mode-button:focus-visible,
.file-viewer-icon-button:focus-visible {
.file-viewer-icon-button:focus-visible,
.file-viewer-language-select:focus-visible {
outline: 2px solid var(--accent);
outline-offset: -2px;
}
Expand Down
57 changes: 57 additions & 0 deletions components/FileViewer.language.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import assert from "node:assert/strict";
import "../tests/setup-dom.mjs";
import test, { afterEach } from "node:test";
import React from "react";
const { cleanup, fireEvent, render, waitFor } = await import("@testing-library/react/pure.js");

const { FileViewer } = await import("./FileViewer.tsx");

const originalFetch = globalThis.fetch;
const originalWorker = globalThis.Worker;
afterEach(async () => {
await React.act(async () => {
await new Promise((resolve) => setTimeout(resolve, 50));
cleanup();
});
globalThis.fetch = originalFetch;
globalThis.Worker = originalWorker;
delete window.matchMedia;
});

const PATCH = "--- a/x\n+++ b/x\n-old\n+new\n";

function setup() {
globalThis.fetch = async (url) => {
const body = String(url).startsWith("/api/git/") ? { supported: false } : { content: PATCH, language: "text", size: PATCH.length };
return { ok: true, json: async () => body };
};
globalThis.Worker = class { onmessage = null; onerror = null; postMessage() {} };
window.matchMedia = () => ({ matches: false, addEventListener() {}, removeEventListener() {} });
}

const props = (filePath) => ({ filePath, hostId: "local", cwd: "/ws", sourceSessionId: "s1" });

test("the language picker highlights a file whose extension maps to no grammar, and resets for the next file", async () => {
setup();
const view = render(React.createElement(FileViewer, props("/ws/change.txt")));
const picker = await waitFor(() => {
const select = view.container.querySelector("select.file-viewer-language-select");
assert.ok(select);
return select;
});
assert.equal(picker.value, "");
assert.equal(view.container.querySelector(".file-source-view .token"), null);

fireEvent.change(picker, { target: { value: "diff" } });
await waitFor(() => assert.ok(view.container.querySelector(".file-source-view .token")));

// Leaving the tab and coming back to the same file keeps the pick.
view.rerender(React.createElement(FileViewer, { ...props("/ws/change.txt"), active: false }));
view.rerender(React.createElement(FileViewer, props("/ws/change.txt")));
await waitFor(() => assert.ok(view.container.querySelector(".file-source-view .token")));
assert.equal(view.container.querySelector("select.file-viewer-language-select").value, "diff");

view.rerender(React.createElement(FileViewer, props("/ws/other.txt")));
await waitFor(() => assert.equal(view.container.querySelector(".file-source-view .token"), null));
assert.equal(view.container.querySelector("select.file-viewer-language-select").value, "");
});
22 changes: 21 additions & 1 deletion components/FileViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { SyntaxHighlighterProps } from "react-syntax-highlighter";
import {
createSyntaxElement as renderSyntaxNode,
ensureLanguageRegistered,
HIGHLIGHT_LANGUAGES,
isLanguageRegistered,
SyntaxHighlighter,
vs,
Expand Down Expand Up @@ -823,6 +824,8 @@ function TextFileViewer({ filePath, hostId, cwd, sourceSessionId, onOpenFile, on
}, [data]);
const [displayMode, setDisplayMode] = useState<DisplayMode>("source");
const [wrapLines, setWrapLines] = useState(false);
// Picked by the user when the extension maps to the wrong grammar or none; null = detected.
const [languageOverride, setLanguageOverride] = useState<string | null>(null);
const [watching, setWatching] = useState(false);
const gitDiffRequestRef = useRef(0);
const contentRequestRef = useRef(0);
Expand Down Expand Up @@ -876,6 +879,11 @@ function TextFileViewer({ filePath, hostId, cwd, sourceSessionId, onOpenFile, on
}
}, [cwd, hostId]);

// Reset per file, not per activation: switching tabs back keeps the user's pick.
useEffect(() => {
setLanguageOverride(null);
}, [filePath]);

// Initial load + SSE watch setup
useEffect(() => {
if (!active) {
Expand Down Expand Up @@ -1121,6 +1129,18 @@ function TextFileViewer({ filePath, hostId, cwd, sourceSessionId, onOpenFile, on
<div className="file-viewer-actions">
{displayMode === "source" && (
<>
<Tooltip content={t("fileViewer.highlightLanguage")}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔥 The Roast: Wrapping a native <select> in Radix Tooltip is a classic "it works on my desktop" move. The Tooltip.Trigger clones your select and slaps onMouseEnter/onFocus handlers on it. On mobile, there's no hover — so the tooltip never shows, or worse, a long-press triggers it and fights the select's own dropdown. The aria-label on the select already covers accessibility; the tooltip is just decorative clutter here.

🩹 The Fix: Drop the Tooltip wrapper for the language select. Keep the aria-label and maybe add a visible label or placeholder text if the design needs it.

📏 Severity: warning

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changing: this is the house Tooltip (Base UI), the same wrapper every other control in this toolbar uses. Base UI tooltips open on mouse hover and keyboard focus, not on touch, so a long-press or tap on mobile goes straight to the native picker. The tooltip only tells desktop users what the menu is for, because its visible text is just the language name.

<select
value={languageOverride ?? ""}
onChange={(event) => setLanguageOverride(event.target.value || null)}
aria-label={t("fileViewer.highlightLanguage")}
className="file-viewer-language-select"
>
<option value="">{t("fileViewer.languageAuto", { language: data.language })}</option>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔥 The Roast: The "Auto" option renders as Auto ({language}) where language is the raw server value. For a .txt file that's text, so users see "Auto (text)" — which reads like a bug report. For .tsx it's "Auto (tsx)" which is fine, but the inconsistency is sloppy.

🩹 The Fix: Map the detected language to a friendly name, or just show the file extension: Auto (.txt) / Auto (.tsx). The data.language comes from getFileLanguage() which returns grammar keys — you'd need a reverse map or just use the file extension from filePath.

📏 Severity: suggestion

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Keeping as is: the label shows the detected grammar exactly as the toolbar's metadata line does (text · 8 lines · …), so Auto (text) is consistent with what the viewer already displays for unmapped files.

<option value="plaintext">{t("fileViewer.plainText")}</option>
{HIGHLIGHT_LANGUAGES.map((language) => <option key={language} value={language}>{language}</option>)}
</select>
</Tooltip>
<Tooltip content={t("fileViewer.mentionSelectedLines")}>
<button
type="button"
Expand Down Expand Up @@ -1241,7 +1261,7 @@ function TextFileViewer({ filePath, hostId, cwd, sourceSessionId, onOpenFile, on
) : highlightReady ? (
<SyntaxHighlighter
className={wrapLines ? "file-source-view is-wrapped" : "file-source-view"}
language={data.language === "text" ? "plaintext" : data.language}
language={languageOverride ?? (data.language === "text" ? "plaintext" : data.language)}
style={isDark ? vscDarkPlus : vs}
showLineNumbers
lineNumberStyle={{
Expand Down
2 changes: 1 addition & 1 deletion graphify-out/graph.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions lib/file-types.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ test("extracts extensions from mixed path styles", async () => {
assert.equal(documentPreviewKind("/tmp/manual.md"), null);
});

test("maps file names to the highlighting grammar the viewer registers", async () => {
const { getFileLanguage } = await loadSubject();

assert.equal(getFileLanguage("/tmp/change.diff"), "diff");
assert.equal(getFileLanguage("C:\\work\\fix.PATCH"), "diff");
assert.equal(getFileLanguage("/ws/App.tsx"), "tsx");
assert.equal(getFileLanguage("/ws/Makefile"), "makefile");
assert.equal(getFileLanguage("/ws/notes.unknown"), "text");
});

test("streamed SVG documents carry a script-blocking security policy", async () => {
const { getStreamSecurityHeaders, IMAGE_EXT_TO_MIME } = await loadSubject();

Expand Down
10 changes: 6 additions & 4 deletions lib/file-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,18 @@ export function isDocumentPreviewPath(filePath: string): boolean {
return documentPreviewKind(filePath) !== null;
}
const EXT_TO_LANGUAGE: Record<string, string> = {
ts: "typescript", tsx: "typescript", js: "javascript", jsx: "javascript",
ts: "typescript", tsx: "tsx", js: "javascript", jsx: "jsx",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔥 The Roast: Changed tsx from "typescript" to "tsx" and jsx from "javascript" to "jsx". The tsx grammar includes TypeScript syntax plus JSX, so it's a superset — but this is a silent behavior change for anyone who liked the old highlighting. No migration note, no config flag, just "surprise, your JSX tags are colored now."

🩹 The Fix: At minimum, call this out in the changelog (you did, good). For extra credit, keep a typescript fallback for .tsx if someone really wants pure TS highlighting without JSX tokens — but the tsx grammar handles both, so this is mostly a nit.

📏 Severity: nitpick

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Intentional, and called out in the changelog: the tsx/jsx grammars are supersets of TypeScript/JavaScript, so nothing is lost. The picker can still force typescript for a file if wanted.

mjs: "javascript", cjs: "javascript", py: "python", rb: "ruby",
go: "go", rs: "rust", java: "java", kt: "kotlin", swift: "swift",
c: "c", cpp: "cpp", h: "c", hpp: "cpp", cs: "csharp",
html: "html", htm: "html", css: "css", scss: "css", less: "css",
go: "go", rs: "rust", java: "java", kt: "kotlin", kts: "kotlin", swift: "swift",
c: "c", cpp: "cpp", cc: "cpp", cxx: "cpp", h: "c", hpp: "cpp", hh: "cpp", cs: "csharp",
html: "html", htm: "html", css: "css", scss: "scss", less: "css",
json: "json", jsonl: "json", yaml: "yaml", yml: "yaml",
toml: "toml", xml: "xml", md: "markdown", mdx: "markdown",
sh: "bash", bash: "bash", zsh: "bash", fish: "bash",
sql: "sql", graphql: "graphql", gql: "graphql",
dockerfile: "dockerfile", tf: "hcl", hcl: "hcl",
diff: "diff", patch: "diff", proto: "protobuf",
ini: "ini", cfg: "ini", conf: "ini", mk: "makefile",
env: "bash", gitignore: "bash", txt: "text",
pdf: "pdf", docx: "word",
};
Expand Down
3 changes: 3 additions & 0 deletions lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -874,9 +874,11 @@
"fileViewer.docxTooLarge": "DOCX too large for preview (>10MB)",
"fileViewer.downloadFile": "Download file",
"fileViewer.enableWordWrap": "Enable word wrap",
"fileViewer.highlightLanguage": "Syntax highlighting language",
"fileViewer.htmlPreview": "HTML preview",
"fileViewer.imageLoadFailed": "Failed to load image",
"fileViewer.imageType": "image",
"fileViewer.languageAuto": "Auto ({language})",
"fileViewer.live": "live",
"fileViewer.liveSyncActive": "Live sync active",
"fileViewer.loading": "Loading...",
Expand All @@ -889,6 +891,7 @@
"fileViewer.notWatching": "Not watching",
"fileViewer.previewTitle": "Preview {name}",
"fileViewer.pdfType": "PDF",
"fileViewer.plainText": "Plain text",
"fileViewer.static": "static",
"fileViewer.unchangedLines.one": "... {count} unchanged line ...",
"fileViewer.unchangedLines.other": "... {count} unchanged lines ...",
Expand Down
3 changes: 3 additions & 0 deletions lib/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,11 @@
"fileViewer.docxTooLarge": "DOCX が大きすぎてプレビューできません(10MB 超)",
"fileViewer.downloadFile": "ファイルをダウンロード",
"fileViewer.enableWordWrap": "折り返しを有効にする",
"fileViewer.highlightLanguage": "シンタックスハイライトの言語",
"fileViewer.htmlPreview": "HTML プレビュー",
"fileViewer.imageLoadFailed": "画像の読み込みに失敗しました",
"fileViewer.imageType": "画像",
"fileViewer.languageAuto": "自動({language})",
"fileViewer.live": "ライブ",
"fileViewer.liveSyncActive": "ライブ同期が有効",
"fileViewer.loading": "読み込み中...",
Expand All @@ -849,6 +851,7 @@
"fileViewer.notWatching": "監視していません",
"fileViewer.previewTitle": "{name} をプレビュー",
"fileViewer.pdfType": "PDF",
"fileViewer.plainText": "プレーンテキスト",
"fileViewer.static": "静的",
"fileViewer.unchangedLines.one": "... 変更なし {count} 行 ...",
"fileViewer.unchangedLines.other": "... 変更なし {count} 行 ...",
Expand Down
3 changes: 3 additions & 0 deletions lib/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,11 @@
"fileViewer.docxTooLarge": "DOCX 过大,无法预览(>10MB)",
"fileViewer.downloadFile": "下载文件",
"fileViewer.enableWordWrap": "开启自动换行",
"fileViewer.highlightLanguage": "语法高亮语言",
"fileViewer.htmlPreview": "HTML 预览",
"fileViewer.imageLoadFailed": "图片加载失败",
"fileViewer.imageType": "图片",
"fileViewer.languageAuto": "自动({language})",
"fileViewer.live": "实时",
"fileViewer.liveSyncActive": "实时同步已启用",
"fileViewer.loading": "加载中...",
Expand All @@ -849,6 +851,7 @@
"fileViewer.notWatching": "未监听",
"fileViewer.previewTitle": "预览 {name}",
"fileViewer.pdfType": "PDF",
"fileViewer.plainText": "纯文本",
"fileViewer.static": "静态",
"fileViewer.unchangedLines.one": "... {count} 行未更改 ...",
"fileViewer.unchangedLines.other": "... {count} 行未更改 ...",
Expand Down
3 changes: 3 additions & 0 deletions lib/syntax-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ for (const [name, grammar] of Object.entries(GRAMMARS)) {
PrismLight.registerLanguage(name, grammar);
}

/** Grammar names the file viewer offers in its language picker. */
export const HIGHLIGHT_LANGUAGES = Object.keys(GRAMMARS);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔥 The Roast: HIGHLIGHT_LANGUAGES dumps Object.keys(GRAMMARS) straight into the picker — insertion order, not alphabetical. Your users get to play "find the language" in a list that starts with bash, c, cpp, csharp... because that's how you happened to type the imports. It's a select box, not a scavenger hunt.

🩹 The Fix: Sort the keys: export const HIGHLIGHT_LANGUAGES = Object.keys(GRAMMARS).sort();

📏 Severity: suggestion

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changing: GRAMMARS is already declared in alphabetical order (bash, c, cpp, csharp, css, diff, docker, go, …), so Object.keys yields a sorted list. A .sort() would add nothing.


/**
* True for every language — all grammars are registered eagerly, so nothing
* ever needs a pending load. Unknown languages are passed through and fall
Expand Down
Loading