feat: history/favorites panel, image preview, context strip

Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
FactorandOvis Fast committed 2026-11-19 11:50:53 +01:00
1 parent 6360c75ff8
commit 7116af9434
9 files changed
+930 -79

No files matched your search

+12
View File
@@ -58,3 +58,15 @@ test("removeMention takes the quoted form and the bare form out", () => {
assert.equal(removeMention("see @/a/ęą.png now", "/a/ęą.png"), "see now");
assert.equal(removeMention('see @"/a b/c.png"x now', "/a b/c.png"), 'see @"/a b/c.png"x now');
});
import { formatBytes } from "../mod/ovis-composer/attachments.js";
test("formatBytes", () => {
assert.equal(formatBytes(0), "0 B");
assert.equal(formatBytes(512), "512 B");
assert.equal(formatBytes(2048), "2 KB");
assert.equal(formatBytes(1536), "1,5 KB");
assert.equal(formatBytes(5 * 1024 * 1024), "5 MB");
assert.equal(formatBytes(undefined), "");
assert.equal(formatBytes(NaN), "");
});
+47
View File
@@ -106,3 +106,50 @@ test("storage: old favourites (at) load as createdAt", () => {
store.set(KEYS.favorites, [{ id: "f", text: "x", at: 4 }]);
assert.equal(loadFavorites(store)[0].createdAt, 4);
});
import { segments, formatMoment, entryMeta, panelState, moveIndex, otherTab } from "../mod/ovis-composer/history.js";
test("segments splits a text on the ranges", () => {
assert.deepEqual(segments("uruchom testy", [[8, 12]]), [
{ text: "uruchom ", hit: false }, { text: "test", hit: true }, { text: "y", hit: false },
]);
assert.deepEqual(segments("ab", []), [{ text: "ab", hit: false }]);
assert.deepEqual(segments("abab", [[0, 2], [2, 4]]), [{ text: "ab", hit: true }, { text: "ab", hit: true }]);
assert.deepEqual(segments("", []), []);
assert.deepEqual(segments("ab", [[0, 99]]), [{ text: "ab", hit: true }]);
});
test("formatMoment is DD.MM HH:MM in local time", () => {
assert.equal(formatMoment(new Date(2026, 10, 19, 9, 5).getTime()), "19.11 09:05");
assert.equal(formatMoment(new Date(2026, 0, 2, 23, 59).getTime()), "02.01 23:59");
assert.equal(formatMoment(NaN), "");
});
test("entryMeta: history says when, where and who; a favourite says when it was saved", () => {
const at = new Date(2026, 10, 19, 9, 5).getTime();
assert.equal(entryMeta({ sentAt: at, spaceName: "herdr", tabName: "Ovis Fast", agentName: "claude-code" }, "history"), "19.11 09:05 · herdr · Ovis Fast");
assert.equal(entryMeta({ sentAt: at, spaceName: "", agentName: "" }, "history"), "19.11 09:05 · ? · ?");
assert.equal(entryMeta({ sentAt: at, spaceName: "s", tabName: "", agentName: "codex" }, "history"), "19.11 09:05 · s · codex");
assert.equal(entryMeta({ createdAt: at }, "favorites"), "zapisano 19.11 09:05");
});
test("panelState: counts, hits, and which empty state to show", () => {
const h = [entry(1, "alfa"), entry(2, "beta")];
const f = [{ id: "f", text: "gamma", createdAt: 3 }];
let s = panelState({ history: h, favorites: f, tab: "history", query: "" });
assert.deepEqual([s.counts, s.hits.length, s.empty], [{ history: 2, favorites: 1 }, 2, null]);
s = panelState({ history: h, favorites: f, tab: "favorites", query: "gam" });
assert.deepEqual([s.hits.length, s.empty], [1, null]);
assert.equal(panelState({ history: [], favorites: f, tab: "history", query: "" }).empty, "history");
assert.equal(panelState({ history: h, favorites: [], tab: "favorites", query: "" }).empty, "favorites");
assert.equal(panelState({ history: h, favorites: f, tab: "history", query: "zzz" }).empty, "query");
});
test("moveIndex wraps; otherTab flips", () => {
assert.equal(moveIndex(0, -1, 3), 2);
assert.equal(moveIndex(2, 1, 3), 0);
assert.equal(moveIndex(1, 1, 3), 2);
assert.equal(moveIndex(0, 1, 0), 0);
assert.equal(otherTab("history"), "favorites");
assert.equal(otherTab("favorites"), "history");
});
+7
View File
@@ -212,3 +212,10 @@ test("attachment states: adding -> ready with the remote path, or error; retry g
assert.equal(s.attachments.a[0].error, undefined);
assert.equal(reduce(s, { type: "attachment_update", agent: "a", id: "zz", patch: { state: "ready" } }), s);
});
test("requeue takes an uncertain entry back to the queue too (the person's \"Ponów\")", () => {
const s = reduce(mk(it("u", "uncertain", { reason: "x" })), { type: "requeue", agent: "a", id: "u" });
assert.deepEqual(s.queue.a[0], { id: "u", text: "u", state: "queued", createdAt: 1 });
const q = mk(it("q", "queued"));
assert.equal(reduce(q, { type: "requeue", agent: "a", id: "q" }), q);
});