feat: history/favorites panel, image preview, context strip
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
6360c75ff8
commit
7116af9434
9 files changed
+930
-79
No files matched your search
@@ -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");
|
||||
});
|
||||
Reference in new issue
Block a user