mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-12-04 03:07:08 +03:00
Compare commits
2
Commits
dev
..
grid-compact
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7008be001b | ||
|
|
18bbd2f0ae |
@@ -1667,18 +1667,6 @@ async def chat_completion(
|
|||||||
yield _emit_chain()
|
yield _emit_chain()
|
||||||
|
|
||||||
yield _emit_chain()
|
yield _emit_chain()
|
||||||
if stream_iterations >= max_iterations:
|
|
||||||
# Without this the turn ends on tool results with no answer,
|
|
||||||
# and the client has nothing to tell the user.
|
|
||||||
logger.warning(
|
|
||||||
"Max tool iterations (%d) reached in chat stream", max_iterations
|
|
||||||
)
|
|
||||||
yield _emit(
|
|
||||||
{
|
|
||||||
"type": "error",
|
|
||||||
"error": "I reached the maximum number of tool call iterations. Please try rephrasing your question.",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
yield _emit({"type": "done"})
|
yield _emit({"type": "done"})
|
||||||
|
|
||||||
return StreamingResponse(
|
return StreamingResponse(
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
* Tiles measured in separate round-trips can straddle that reflow and disagree
|
* Tiles measured in separate round-trips can straddle that reflow and disagree
|
||||||
* on scale, so cameraBoxes() takes every measurement in one evaluate.
|
* on scale, so cameraBoxes() takes every measurement in one evaluate.
|
||||||
*
|
*
|
||||||
* Used by live-grid-aspect-modes.spec.ts and masonry-live-grid.spec.ts.
|
* Used by live-grid-aspect-modes.spec.ts, live-grid-legacy-layouts.spec.ts and
|
||||||
|
* masonry-live-grid.spec.ts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { expect, type Page } from "@playwright/test";
|
import { expect, type Page } from "@playwright/test";
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ export class LivePage extends BasePage {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Birdseye tile on the draggable grid, the one without a camera card. */
|
||||||
|
get birdseyeTile(): Locator {
|
||||||
|
return this.page.locator(".react-grid-item:not(:has([data-camera]))");
|
||||||
|
}
|
||||||
|
|
||||||
/** Edit-layout toggle on the draggable grid (desktop, custom groups). */
|
/** Edit-layout toggle on the draggable grid (desktop, custom groups). */
|
||||||
get editLayoutButton(): Locator {
|
get editLayoutButton(): Locator {
|
||||||
return this.page.getByTestId("toggle-edit-layout");
|
return this.page.getByTestId("toggle-edit-layout");
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ async function installChatStreamOverride(
|
|||||||
await app.page.addInitScript(
|
await app.page.addInitScript(
|
||||||
({ chunks, chunkDelayMs, status }) => {
|
({ chunks, chunkDelayMs, status }) => {
|
||||||
(window as unknown as { __chatRequests: unknown[] }).__chatRequests = [];
|
(window as unknown as { __chatRequests: unknown[] }).__chatRequests = [];
|
||||||
// Count of mocked streams that emitted every chunk, so tests can wait
|
|
||||||
// for a stream to finish instead of sleeping.
|
|
||||||
(window as unknown as { __chatStreamsDone: number }).__chatStreamsDone =
|
|
||||||
0;
|
|
||||||
const origFetch = window.fetch;
|
const origFetch = window.fetch;
|
||||||
window.fetch = async (input, init) => {
|
window.fetch = async (input, init) => {
|
||||||
const url =
|
const url =
|
||||||
@@ -61,9 +57,6 @@ async function installChatStreamOverride(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
controller.close();
|
controller.close();
|
||||||
(
|
|
||||||
window as unknown as { __chatStreamsDone: number }
|
|
||||||
).__chatStreamsDone += 1;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return new Response(stream, { status: 200 });
|
return new Response(stream, { status: 200 });
|
||||||
@@ -226,110 +219,6 @@ test.describe("Chat — streaming @medium", () => {
|
|||||||
).toBeVisible({ timeout: 5_000 });
|
).toBeVisible({ timeout: 5_000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test("each model call's reasoning renders with its own message", async ({
|
|
||||||
frigateApp,
|
|
||||||
}) => {
|
|
||||||
const toolTurn = [
|
|
||||||
{ role: "system", content: "sys" },
|
|
||||||
{ role: "user", content: "find people" },
|
|
||||||
{
|
|
||||||
role: "assistant",
|
|
||||||
content: null,
|
|
||||||
tool_calls: [
|
|
||||||
{
|
|
||||||
id: "call_1",
|
|
||||||
type: "function",
|
|
||||||
function: {
|
|
||||||
name: "search_objects",
|
|
||||||
arguments: '{"label":"person"}',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{ role: "tool", tool_call_id: "call_1", content: "[]" },
|
|
||||||
];
|
|
||||||
await installChatStreamOverride(frigateApp, [
|
|
||||||
{ type: "reasoning", delta: "first thought" },
|
|
||||||
{ type: "messages", messages: toolTurn },
|
|
||||||
{ type: "reasoning", delta: "second thought" },
|
|
||||||
{ type: "content", delta: "No people found." },
|
|
||||||
{
|
|
||||||
type: "messages",
|
|
||||||
messages: [
|
|
||||||
...toolTurn,
|
|
||||||
{ role: "assistant", content: "No people found." },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{ type: "done" },
|
|
||||||
]);
|
|
||||||
await frigateApp.goto("/chat");
|
|
||||||
const input = frigateApp.page.getByPlaceholder(/ask/i);
|
|
||||||
await expect(input).toBeVisible({ timeout: 10_000 });
|
|
||||||
await input.fill("find people");
|
|
||||||
await input.press("Enter");
|
|
||||||
|
|
||||||
await expect(frigateApp.page.getByText("No people found.")).toBeVisible({
|
|
||||||
timeout: 10_000,
|
|
||||||
});
|
|
||||||
// Two separate, collapsed reasoning bubbles; expanding both shows each
|
|
||||||
// trace on its own rather than one concatenated block.
|
|
||||||
const toggles = frigateApp.page.getByRole("button", {
|
|
||||||
name: /show reasoning/i,
|
|
||||||
});
|
|
||||||
await expect(toggles).toHaveCount(2);
|
|
||||||
// Expanding one relabels it to "Hide reasoning", so click the first
|
|
||||||
// remaining "Show" toggle twice.
|
|
||||||
await toggles.first().click();
|
|
||||||
await expect(toggles).toHaveCount(1);
|
|
||||||
await toggles.first().click();
|
|
||||||
await expect(
|
|
||||||
frigateApp.page.locator("pre", { hasText: /^first thought$/ }),
|
|
||||||
).toHaveCount(1);
|
|
||||||
await expect(
|
|
||||||
frigateApp.page.locator("pre", { hasText: /^second thought$/ }),
|
|
||||||
).toHaveCount(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("a turn that ends without a final answer keeps its tool calls", async ({
|
|
||||||
frigateApp,
|
|
||||||
}) => {
|
|
||||||
const toolTurn = [
|
|
||||||
{ role: "system", content: "sys" },
|
|
||||||
{ role: "user", content: "find people" },
|
|
||||||
{
|
|
||||||
role: "assistant",
|
|
||||||
content: null,
|
|
||||||
tool_calls: [
|
|
||||||
{
|
|
||||||
id: "call_1",
|
|
||||||
type: "function",
|
|
||||||
function: {
|
|
||||||
name: "search_objects",
|
|
||||||
arguments: '{"label":"person"}',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{ role: "tool", tool_call_id: "call_1", content: "[]" },
|
|
||||||
];
|
|
||||||
await installChatStreamOverride(frigateApp, [
|
|
||||||
{ type: "messages", messages: toolTurn },
|
|
||||||
{ type: "messages", messages: toolTurn },
|
|
||||||
{ type: "error", error: "iteration limit" },
|
|
||||||
{ type: "done" },
|
|
||||||
]);
|
|
||||||
await frigateApp.goto("/chat");
|
|
||||||
const input = frigateApp.page.getByPlaceholder(/ask/i);
|
|
||||||
await expect(input).toBeVisible({ timeout: 10_000 });
|
|
||||||
await input.fill("find people");
|
|
||||||
await input.press("Enter");
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
frigateApp.page.getByRole("alert").filter({ hasText: /iteration limit/ }),
|
|
||||||
).toBeVisible({ timeout: 10_000 });
|
|
||||||
await expect(frigateApp.page.getByText(/search objects/i)).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("assistant markdown renders only same-origin images", async ({
|
test("assistant markdown renders only same-origin images", async ({
|
||||||
frigateApp,
|
frigateApp,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -418,80 +307,6 @@ test.describe("Chat — stop @medium", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe("Chat — new chat @medium", () => {
|
|
||||||
test("New chat during a tool-call turn stays cleared", async ({
|
|
||||||
frigateApp,
|
|
||||||
}) => {
|
|
||||||
const toolTurn = [
|
|
||||||
{ role: "system", content: "sys" },
|
|
||||||
{ role: "user", content: "find people" },
|
|
||||||
{
|
|
||||||
role: "assistant",
|
|
||||||
content: null,
|
|
||||||
tool_calls: [
|
|
||||||
{
|
|
||||||
id: "call_1",
|
|
||||||
type: "function",
|
|
||||||
function: {
|
|
||||||
name: "search_objects",
|
|
||||||
arguments: '{"label":"person"}',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{ role: "tool", tool_call_id: "call_1", content: "[]" },
|
|
||||||
];
|
|
||||||
// The mocked stream ignores the abort signal, so its remaining chunks
|
|
||||||
// and onDone still arrive after New chat: the stale request must not
|
|
||||||
// write them into the cleared chat.
|
|
||||||
await installChatStreamOverride(
|
|
||||||
frigateApp,
|
|
||||||
[
|
|
||||||
{ type: "messages", messages: toolTurn },
|
|
||||||
{ type: "content", delta: "Still answering" },
|
|
||||||
{
|
|
||||||
type: "messages",
|
|
||||||
messages: [
|
|
||||||
...toolTurn,
|
|
||||||
{ role: "assistant", content: "Still answering" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{ type: "done" },
|
|
||||||
],
|
|
||||||
{ chunkDelayMs: 400 },
|
|
||||||
);
|
|
||||||
await frigateApp.goto("/chat");
|
|
||||||
const input = frigateApp.page.getByPlaceholder(/ask/i);
|
|
||||||
await expect(input).toBeVisible({ timeout: 10_000 });
|
|
||||||
await input.fill("find people");
|
|
||||||
await input.press("Enter");
|
|
||||||
|
|
||||||
await expect(frigateApp.page.getByText(/search objects/i)).toBeVisible({
|
|
||||||
timeout: 10_000,
|
|
||||||
});
|
|
||||||
await frigateApp.page.getByRole("button", { name: "New chat" }).click();
|
|
||||||
|
|
||||||
// Wait for the stale stream to deliver its last chunk, then confirm
|
|
||||||
// nothing came back.
|
|
||||||
await expect
|
|
||||||
.poll(
|
|
||||||
() =>
|
|
||||||
frigateApp.page.evaluate(
|
|
||||||
() =>
|
|
||||||
(window as unknown as { __chatStreamsDone: number })
|
|
||||||
.__chatStreamsDone,
|
|
||||||
),
|
|
||||||
{ timeout: 10_000 },
|
|
||||||
)
|
|
||||||
.toBe(1);
|
|
||||||
await expect(
|
|
||||||
frigateApp.page.getByRole("heading", { level: 1 }),
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(frigateApp.page.getByText(/search objects/i)).toHaveCount(0);
|
|
||||||
await expect(frigateApp.page.getByText("find people")).toHaveCount(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test.describe("Chat — error @medium", () => {
|
test.describe("Chat — error @medium", () => {
|
||||||
test("non-OK response renders an error banner", async ({ frigateApp }) => {
|
test("non-OK response renders an error banner", async ({ frigateApp }) => {
|
||||||
await installChatStreamOverride(frigateApp, [], { status: 500 });
|
await installChatStreamOverride(frigateApp, [], { status: 500 });
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ test.describe("Live grid aspect modes @critical", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 0.17/0.18 shape: bare array on a 12-column grid, 4x4 standard tiles.
|
// 0.17/0.18 shape: bare array on a 12-column grid, 4x4 standard tiles.
|
||||||
// backyard was manually resized to 8x8 and sits beside front_door's column,
|
// backyard was manually resized to 8x8 and sits beside front_door's column.
|
||||||
// front_door is a standard tile on the row below.
|
// front_door is stored on the row below, but 0.18 compacted it to the top.
|
||||||
const key = await persistedLayoutKey(frigateApp.page, GROUP);
|
const key = await persistedLayoutKey(frigateApp.page, GROUP);
|
||||||
await seedLayout(frigateApp.page, key, [
|
await seedLayout(frigateApp.page, key, [
|
||||||
{ i: "backyard", x: 4, y: 0, w: 8, h: 8, moved: false, static: false },
|
{ i: "backyard", x: 4, y: 0, w: 8, h: 8, moved: false, static: false },
|
||||||
@@ -127,21 +127,21 @@ test.describe("Live grid aspect modes @critical", () => {
|
|||||||
stored.layout.find((i: LayoutItem) => i.i === "front_door"),
|
stored.layout.find((i: LayoutItem) => i.i === "front_door"),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 144,
|
y: 0,
|
||||||
w: 32,
|
w: 32,
|
||||||
h: 72,
|
h: 72,
|
||||||
});
|
});
|
||||||
|
|
||||||
// arrangement on screen: backyard indented, front_door below it
|
// arrangement on screen: front_door top-left, backyard beside it
|
||||||
const { backyard, front_door: frontDoor } = await cameraBoxes(
|
const { backyard, front_door: frontDoor } = await cameraBoxes(
|
||||||
frigateApp.page,
|
frigateApp.page,
|
||||||
["backyard", "front_door"] as const,
|
["backyard", "front_door"] as const,
|
||||||
);
|
);
|
||||||
expect(backyard.x).toBeGreaterThan(frontDoor.x + frontDoor.w / 2);
|
expect(backyard.x).toBeGreaterThan(frontDoor.x + frontDoor.w / 2);
|
||||||
expect(frontDoor.y).toBeGreaterThan(backyard.y + backyard.h / 2);
|
expect(Math.abs(frontDoor.y - backyard.y)).toBeLessThan(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("conversion is a pure scale, so odd sizes and positions survive", async ({
|
test("conversion scales odd sizes and keeps tiles adjacent", async ({
|
||||||
frigateApp,
|
frigateApp,
|
||||||
}) => {
|
}) => {
|
||||||
await frigateApp.goto(`/?group=${GROUP}`);
|
await frigateApp.goto(`/?group=${GROUP}`);
|
||||||
@@ -175,8 +175,9 @@ test.describe("Live grid aspect modes @critical", () => {
|
|||||||
)!;
|
)!;
|
||||||
const backyard = stored.layout.find((i: LayoutItem) => i.i === "backyard")!;
|
const backyard = stored.layout.find((i: LayoutItem) => i.i === "backyard")!;
|
||||||
|
|
||||||
expect(frontDoor).toMatchObject({ x: 0, y: 54, w: 40, h: 90 });
|
// the empty rows above both tiles compact away, as they did in 0.18
|
||||||
expect(backyard).toMatchObject({ x: 40, y: 54, w: 56, h: 90 });
|
expect(frontDoor).toMatchObject({ x: 0, y: 0, w: 40, h: 90 });
|
||||||
|
expect(backyard).toMatchObject({ x: 40, y: 0, w: 56, h: 90 });
|
||||||
|
|
||||||
// still adjacent, still inside the grid, still not overlapping
|
// still adjacent, still inside the grid, still not overlapping
|
||||||
expect(frontDoor.x + frontDoor.w).toBe(backyard.x);
|
expect(frontDoor.x + frontDoor.w).toBe(backyard.x);
|
||||||
|
|||||||
@@ -0,0 +1,187 @@
|
|||||||
|
/**
|
||||||
|
* Live grid layouts saved by 0.18.
|
||||||
|
*
|
||||||
|
* 0.18 stored every new tile at y 0 and let the grid compact the tiles at
|
||||||
|
* render, in render order (Birdseye, then camera order). Its stored layouts
|
||||||
|
* can share cells and hold gaps that never showed. Conversion compacts the same
|
||||||
|
* way, so each layout opens exactly as 0.18 displayed it.
|
||||||
|
*
|
||||||
|
* Each stored layout below was captured from 0.18's IndexedDB, and each
|
||||||
|
* expected cell is where 0.18 rendered that tile.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { test, expect } from "../fixtures/frigate-test";
|
||||||
|
import { BASE_CONFIG } from "../fixtures/mock-data/config";
|
||||||
|
import { LivePage } from "../pages/live.page";
|
||||||
|
import {
|
||||||
|
persistedLayoutKey,
|
||||||
|
readLayout,
|
||||||
|
seedLayout,
|
||||||
|
type LayoutItem,
|
||||||
|
} from "../helpers/grid-layout";
|
||||||
|
|
||||||
|
// one 0.18 cell is 32 columns by 72 rows on the current grid
|
||||||
|
const CELL_W = 32;
|
||||||
|
const CELL_H = 72;
|
||||||
|
|
||||||
|
const tile = (i: string, x: number, y: number) => ({ i, x, y, w: 4, h: 4 });
|
||||||
|
|
||||||
|
type Scenario = {
|
||||||
|
name: string;
|
||||||
|
cameras: string[];
|
||||||
|
stored: LayoutItem[];
|
||||||
|
rendered: Record<string, [number, number]>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const SCENARIOS: Scenario[] = [
|
||||||
|
{
|
||||||
|
name: "a group created with Birdseye",
|
||||||
|
cameras: ["birdseye", "front_door", "backyard", "garage"],
|
||||||
|
stored: [
|
||||||
|
tile("birdseye", 0, 0),
|
||||||
|
tile("front_door", 4, 0),
|
||||||
|
tile("backyard", 8, 0),
|
||||||
|
tile("garage", 0, 0),
|
||||||
|
],
|
||||||
|
rendered: {
|
||||||
|
birdseye: [0, 0],
|
||||||
|
front_door: [1, 0],
|
||||||
|
backyard: [2, 0],
|
||||||
|
garage: [0, 1],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Birdseye and a camera added after a drag",
|
||||||
|
cameras: [
|
||||||
|
"front_door",
|
||||||
|
"backyard",
|
||||||
|
"garage",
|
||||||
|
"porch",
|
||||||
|
"driveway",
|
||||||
|
"birdseye",
|
||||||
|
],
|
||||||
|
stored: [
|
||||||
|
tile("front_door", 0, 4),
|
||||||
|
tile("backyard", 4, 0),
|
||||||
|
tile("garage", 8, 0),
|
||||||
|
tile("porch", 0, 0),
|
||||||
|
tile("driveway", 4, 0),
|
||||||
|
tile("birdseye", 0, 0),
|
||||||
|
],
|
||||||
|
rendered: {
|
||||||
|
birdseye: [0, 0],
|
||||||
|
backyard: [1, 0],
|
||||||
|
garage: [2, 0],
|
||||||
|
porch: [0, 1],
|
||||||
|
driveway: [1, 1],
|
||||||
|
front_door: [0, 2],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "a camera added ahead of the others in camera order",
|
||||||
|
cameras: ["backyard", "garage", "porch", "driveway", "front_door"],
|
||||||
|
stored: [
|
||||||
|
tile("backyard", 0, 0),
|
||||||
|
tile("garage", 4, 0),
|
||||||
|
tile("porch", 8, 0),
|
||||||
|
tile("driveway", 0, 0),
|
||||||
|
tile("front_door", 0, 0),
|
||||||
|
],
|
||||||
|
rendered: {
|
||||||
|
front_door: [0, 0],
|
||||||
|
garage: [1, 0],
|
||||||
|
porch: [2, 0],
|
||||||
|
backyard: [0, 1],
|
||||||
|
driveway: [0, 2],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "a camera removed after a drag",
|
||||||
|
cameras: ["front_door", "backyard", "garage"],
|
||||||
|
stored: [
|
||||||
|
tile("front_door", 0, 4),
|
||||||
|
tile("backyard", 4, 0),
|
||||||
|
tile("garage", 8, 0),
|
||||||
|
],
|
||||||
|
rendered: {
|
||||||
|
front_door: [0, 0],
|
||||||
|
backyard: [1, 0],
|
||||||
|
garage: [2, 0],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const frontDoor = BASE_CONFIG.cameras.front_door;
|
||||||
|
|
||||||
|
test.describe("Live grid 0.18 layouts @critical", () => {
|
||||||
|
test.skip(
|
||||||
|
({ frigateApp }) => frigateApp.isMobile,
|
||||||
|
"Draggable grid is desktop-only",
|
||||||
|
);
|
||||||
|
|
||||||
|
SCENARIOS.forEach(({ name, cameras, stored, rendered }, index) => {
|
||||||
|
test(`opens ${name} as 0.18 showed it`, async ({ frigateApp }) => {
|
||||||
|
const group = `legacy${index}`;
|
||||||
|
await frigateApp.installDefaults({
|
||||||
|
config: {
|
||||||
|
cameras: {
|
||||||
|
porch: { ...frontDoor, name: "porch" },
|
||||||
|
driveway: { ...frontDoor, name: "driveway" },
|
||||||
|
},
|
||||||
|
camera_groups: { [group]: { cameras, icon: "LuCar", order: 1 } },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await frigateApp.goto(`/?group=${group}`);
|
||||||
|
const key = await persistedLayoutKey(frigateApp.page, group);
|
||||||
|
await seedLayout(frigateApp.page, key, stored);
|
||||||
|
await frigateApp.page.reload();
|
||||||
|
|
||||||
|
await expect
|
||||||
|
.poll(async () => (await readLayout(frigateApp.page, key))?.version, {
|
||||||
|
timeout: 10_000,
|
||||||
|
})
|
||||||
|
.toBe(2);
|
||||||
|
|
||||||
|
const layout = (await readLayout(frigateApp.page, key))!.layout;
|
||||||
|
const cells = Object.fromEntries(
|
||||||
|
layout.map((item) => [item.i, [item.x / CELL_W, item.y / CELL_H]]),
|
||||||
|
);
|
||||||
|
expect(cells).toEqual(rendered);
|
||||||
|
|
||||||
|
if (cameras.includes("birdseye")) {
|
||||||
|
await new LivePage(frigateApp.page, true).birdseyeTile.click();
|
||||||
|
await expect(frigateApp.page).toHaveURL(/#birdseye/);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe("Live grid 0.18 layouts on mobile @critical @mobile", () => {
|
||||||
|
test("a group with Birdseye shows every tile in the static grid", async ({
|
||||||
|
frigateApp,
|
||||||
|
}) => {
|
||||||
|
test.skip(!frigateApp.isMobile, "Mobile-only");
|
||||||
|
|
||||||
|
const { cameras } = SCENARIOS[0];
|
||||||
|
await frigateApp.installDefaults({
|
||||||
|
config: {
|
||||||
|
camera_groups: { legacy: { cameras, icon: "LuCar", order: 1 } },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await frigateApp.goto("/?group=legacy");
|
||||||
|
const live = new LivePage(frigateApp.page, false);
|
||||||
|
for (const camera of cameras.filter((name) => name !== "birdseye")) {
|
||||||
|
await expect(live.cameraCard(camera).first()).toBeVisible({
|
||||||
|
timeout: 10_000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// the static grid never reads a stored layout, so nothing can cover Birdseye
|
||||||
|
await expect(frigateApp.page.locator(".react-grid-item")).toHaveCount(0);
|
||||||
|
await expect(
|
||||||
|
frigateApp.page.locator(
|
||||||
|
"#pageRoot .aspect-video:not([data-camera]):not(:has([data-camera]))",
|
||||||
|
),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -172,43 +172,4 @@ test.describe("Navigation — mobile @critical @mobile", () => {
|
|||||||
frigateApp.page.locator('a[href="/review"]').first(),
|
frigateApp.page.locator('a[href="/review"]').first(),
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
// iOS 26+ blurs the top of a Home Screen web app unless WebKit finds an
|
|
||||||
// opaque, fixed box at least 90% wide, 4px below the top centre
|
|
||||||
test("installed app has an opaque fixed strip under the status bar", async ({
|
|
||||||
frigateApp,
|
|
||||||
}) => {
|
|
||||||
test.skip(!frigateApp.isMobile, "Mobile-only");
|
|
||||||
await frigateApp.page.addInitScript(() => {
|
|
||||||
Object.defineProperty(window.navigator, "standalone", { value: true });
|
|
||||||
});
|
|
||||||
await frigateApp.goto("/");
|
|
||||||
const strip = await frigateApp.page.evaluate(() => {
|
|
||||||
// WebKit's hit test ignores pointer-events, elementFromPoint does not
|
|
||||||
const x = window.innerWidth / 2;
|
|
||||||
const el = Array.from(document.querySelectorAll("body *")).find((e) => {
|
|
||||||
const r = e.getBoundingClientRect();
|
|
||||||
return (
|
|
||||||
getComputedStyle(e).position == "fixed" &&
|
|
||||||
r.left <= x &&
|
|
||||||
r.right >= x &&
|
|
||||||
r.top <= 4 &&
|
|
||||||
r.bottom > 6
|
|
||||||
);
|
|
||||||
});
|
|
||||||
if (!el) return null;
|
|
||||||
const style = getComputedStyle(el);
|
|
||||||
return {
|
|
||||||
widthShare: el.getBoundingClientRect().width / window.innerWidth,
|
|
||||||
background: style.backgroundColor,
|
|
||||||
opacity: style.opacity,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
expect(strip).not.toBeNull();
|
|
||||||
expect(strip!.widthShare).toBeGreaterThan(0.9);
|
|
||||||
// WebKit blends a colour below 0.75 alpha with the page; require solid
|
|
||||||
const alpha = strip!.background.match(/rgba?\(([^)]+)\)/)![1].split(",")[3];
|
|
||||||
expect(Number(alpha ?? 1)).toBe(1);
|
|
||||||
expect(Number(strip!.opacity)).toBe(1);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-6
@@ -4,7 +4,7 @@ import Wrapper from "@/components/Wrapper";
|
|||||||
import Sidebar from "@/components/navigation/Sidebar";
|
import Sidebar from "@/components/navigation/Sidebar";
|
||||||
import CommandMenu from "@/components/menu/CommandMenu";
|
import CommandMenu from "@/components/menu/CommandMenu";
|
||||||
|
|
||||||
import { isDesktop, isIOS, isMobile } from "react-device-detect";
|
import { isDesktop, isMobile } from "react-device-detect";
|
||||||
import Statusbar from "./components/Statusbar";
|
import Statusbar from "./components/Statusbar";
|
||||||
import Bottombar from "./components/navigation/Bottombar";
|
import Bottombar from "./components/navigation/Bottombar";
|
||||||
import { lazy, useContext, useEffect, useState } from "react";
|
import { lazy, useContext, useEffect, useState } from "react";
|
||||||
@@ -113,11 +113,6 @@ function DefaultAppView() {
|
|||||||
<ChromeErrorBoundary>{isDesktop && <Statusbar />}</ChromeErrorBoundary>
|
<ChromeErrorBoundary>{isDesktop && <Statusbar />}</ChromeErrorBoundary>
|
||||||
<ChromeErrorBoundary>{isDesktop && <CommandMenu />}</ChromeErrorBoundary>
|
<ChromeErrorBoundary>{isDesktop && <CommandMenu />}</ChromeErrorBoundary>
|
||||||
<ChromeErrorBoundary>{isMobile && <Bottombar />}</ChromeErrorBoundary>
|
<ChromeErrorBoundary>{isMobile && <Bottombar />}</ChromeErrorBoundary>
|
||||||
{isIOS && isPWA && (
|
|
||||||
// iOS 26+ blurs the top of a Home Screen web app unless an opaque,
|
|
||||||
// fixed, full-width box sits under the status bar
|
|
||||||
<div className="pointer-events-none fixed inset-x-0 top-0 z-50 h-2 bg-background landscape:hidden" />
|
|
||||||
)}
|
|
||||||
<div
|
<div
|
||||||
id="pageRoot"
|
id="pageRoot"
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|||||||
@@ -34,10 +34,9 @@ export function ReasoningBubble({
|
|||||||
const { t } = useTranslation(["views/chat"]);
|
const { t } = useTranslation(["views/chat"]);
|
||||||
// Open while the model is still mid-thought (no answer tokens yet);
|
// Open while the model is still mid-thought (no answer tokens yet);
|
||||||
// once the answer begins, collapse on its own but let the user reopen.
|
// once the answer begins, collapse on its own but let the user reopen.
|
||||||
// Reasoning that is already finished on mount starts collapsed.
|
const [open, setOpen] = useState(true);
|
||||||
const [open, setOpen] = useState(!answerStarted);
|
|
||||||
const userInteractedRef = useRef(false);
|
const userInteractedRef = useRef(false);
|
||||||
const lastAutoState = useRef(!answerStarted);
|
const lastAutoState = useRef(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (userInteractedRef.current) return;
|
if (userInteractedRef.current) return;
|
||||||
@@ -67,7 +66,6 @@ export function ReasoningBubble({
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
aria-label={label}
|
|
||||||
className="h-auto w-full min-w-0 justify-start gap-2 whitespace-normal p-0 text-left text-xs hover:bg-transparent"
|
className="h-auto w-full min-w-0 justify-start gap-2 whitespace-normal p-0 text-left text-xs hover:bg-transparent"
|
||||||
>
|
>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
|
|||||||
+23
-95
@@ -30,12 +30,6 @@ import {
|
|||||||
toolResponsesById,
|
toolResponsesById,
|
||||||
} from "@/utils/chatUtil";
|
} from "@/utils/chatUtil";
|
||||||
|
|
||||||
/**
|
|
||||||
* The in-flight turn. `content`, `reasoning`, and `stats` cover only the
|
|
||||||
* current model call; each time the backend emits the chain they are attached
|
|
||||||
* to the assistant message that call produced and reset, so every round of
|
|
||||||
* reasoning stays with its own tool calls.
|
|
||||||
*/
|
|
||||||
type StreamingTurn = {
|
type StreamingTurn = {
|
||||||
content: string;
|
content: string;
|
||||||
reasoning: string;
|
reasoning: string;
|
||||||
@@ -158,114 +152,52 @@ export default function ChatPage() {
|
|||||||
abortRef.current = controller;
|
abortRef.current = controller;
|
||||||
|
|
||||||
let chain: ChatMessage[] = [];
|
let chain: ChatMessage[] = [];
|
||||||
|
let stats: ChatStats | undefined;
|
||||||
|
let reasoning = "";
|
||||||
let hadError = false;
|
let hadError = false;
|
||||||
let approvals: PendingToolCall[] | null = null;
|
let approvals: PendingToolCall[] | null = null;
|
||||||
// Reasoning and stats for the current model call, attached to the
|
|
||||||
// assistant message it produces once that message shows up in the chain.
|
|
||||||
let segmentReasoning = "";
|
|
||||||
let segmentStats: ChatStats | undefined;
|
|
||||||
let seenChainLength = 0;
|
|
||||||
const extrasByIndex = new Map<
|
|
||||||
number,
|
|
||||||
Pick<ChatMessage, "reasoning" | "stats">
|
|
||||||
>();
|
|
||||||
|
|
||||||
// The backend never sees reasoning or stats, so the chain it returns
|
|
||||||
// lacks them. Restore them from earlier turns and from this turn's
|
|
||||||
// model calls. The backend prepends a system message on the first turn.
|
|
||||||
const decorate = (raw: ChatMessage[]): ChatMessage[] => {
|
|
||||||
const offset =
|
|
||||||
raw[0]?.role === "system" && messagesToSend[0]?.role !== "system"
|
|
||||||
? 1
|
|
||||||
: 0;
|
|
||||||
return raw.map((m, i) => {
|
|
||||||
const prior = i >= offset ? messagesToSend[i - offset] : undefined;
|
|
||||||
const extras = extrasByIndex.get(i);
|
|
||||||
const reasoning = extras?.reasoning ?? prior?.reasoning;
|
|
||||||
const stats = extras?.stats ?? prior?.stats;
|
|
||||||
return reasoning || stats ? { ...m, reasoning, stats } : m;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// This request owns the chat until New chat or a newer request replaces
|
|
||||||
// abortRef. Callbacks from a request that lost ownership (including the
|
|
||||||
// onDone that follows an abort) must not touch the current chat.
|
|
||||||
const owns = () => abortRef.current === controller;
|
|
||||||
|
|
||||||
await streamChatCompletion(
|
await streamChatCompletion(
|
||||||
url,
|
url,
|
||||||
headers,
|
headers,
|
||||||
toWire(messagesToSend),
|
toWire(messagesToSend),
|
||||||
{
|
{
|
||||||
onContentDelta: (delta) => {
|
onContentDelta: (delta) =>
|
||||||
if (!owns()) return;
|
setStreaming((s) => (s ? { ...s, content: s.content + delta } : s)),
|
||||||
setStreaming((s) => (s ? { ...s, content: s.content + delta } : s));
|
|
||||||
},
|
|
||||||
onReasoningDelta: (delta) => {
|
onReasoningDelta: (delta) => {
|
||||||
if (!owns()) return;
|
reasoning += delta;
|
||||||
segmentReasoning += delta;
|
|
||||||
setStreaming((s) =>
|
setStreaming((s) =>
|
||||||
s ? { ...s, reasoning: s.reasoning + delta } : s,
|
s ? { ...s, reasoning: s.reasoning + delta } : s,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onChain: (fullChain) => {
|
onChain: (fullChain) => {
|
||||||
if (!owns()) return;
|
chain = fullChain;
|
||||||
// Credit the current call's reasoning to the newest assistant
|
setStreaming((s) => (s ? { ...s, chain: fullChain } : s));
|
||||||
// message added since the last chain, then start a new segment.
|
|
||||||
for (let i = fullChain.length - 1; i >= seenChainLength; i--) {
|
|
||||||
if (fullChain[i].role !== "assistant") continue;
|
|
||||||
if (segmentReasoning || segmentStats) {
|
|
||||||
extrasByIndex.set(i, {
|
|
||||||
reasoning: segmentReasoning || undefined,
|
|
||||||
stats: segmentStats,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
segmentReasoning = "";
|
|
||||||
segmentStats = undefined;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
seenChainLength = fullChain.length;
|
|
||||||
chain = decorate(fullChain);
|
|
||||||
const decorated = chain;
|
|
||||||
setStreaming((s) =>
|
|
||||||
s
|
|
||||||
? {
|
|
||||||
...s,
|
|
||||||
chain: decorated,
|
|
||||||
content: "",
|
|
||||||
reasoning: segmentReasoning,
|
|
||||||
stats: segmentStats,
|
|
||||||
}
|
|
||||||
: s,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
onStats: (s) => {
|
onStats: (s) => {
|
||||||
if (!owns()) return;
|
stats = s;
|
||||||
segmentStats = s;
|
|
||||||
setStreaming((cur) => (cur ? { ...cur, stats: s } : cur));
|
setStreaming((cur) => (cur ? { ...cur, stats: s } : cur));
|
||||||
},
|
},
|
||||||
onApprovalRequired: (toolCalls) => {
|
onApprovalRequired: (toolCalls) => {
|
||||||
approvals = toolCalls;
|
approvals = toolCalls;
|
||||||
},
|
},
|
||||||
onError: (message) => {
|
onError: (message) => {
|
||||||
if (!owns()) return;
|
|
||||||
hadError = true;
|
hadError = true;
|
||||||
setError(message);
|
setError(message);
|
||||||
},
|
},
|
||||||
onDone: () => {
|
onDone: () => {
|
||||||
if (!owns()) return;
|
|
||||||
abortRef.current = null;
|
abortRef.current = null;
|
||||||
loadingRef.current = false;
|
loadingRef.current = false;
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setStreaming(null);
|
setStreaming(null);
|
||||||
// Keep whatever the backend got through, even when the turn ends
|
const lastMsg = chain[chain.length - 1];
|
||||||
// without a final answer (error, stop, or tool iteration limit).
|
|
||||||
// Dropping it would make the tool calls and reasoning vanish.
|
|
||||||
if (chain.length === 0) return;
|
|
||||||
const committed = chain;
|
|
||||||
setMessages(committed);
|
|
||||||
const lastMsg = committed[committed.length - 1];
|
|
||||||
if (!hadError && lastMsg?.role === "assistant") {
|
if (!hadError && lastMsg?.role === "assistant") {
|
||||||
|
const committed = chain.map((m, i) =>
|
||||||
|
i === chain.length - 1
|
||||||
|
? { ...m, reasoning: reasoning || undefined, stats }
|
||||||
|
: m,
|
||||||
|
);
|
||||||
|
setMessages(committed);
|
||||||
if (approvals?.length) {
|
if (approvals?.length) {
|
||||||
// Calls to always-allowed tools are answered here without
|
// Calls to always-allowed tools are answered here without
|
||||||
// prompting; anything else waits for the user.
|
// prompting; anything else waits for the user.
|
||||||
@@ -370,10 +302,8 @@ export default function ChatPage() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const stopGeneration = useCallback(() => {
|
const stopGeneration = useCallback(() => {
|
||||||
// Keep abortRef pointing at the stopped request so its onDone can still
|
|
||||||
// commit the partial chain. A message sent before that onDone fires
|
|
||||||
// replaces abortRef, and the stale onDone then does nothing.
|
|
||||||
abortRef.current?.abort();
|
abortRef.current?.abort();
|
||||||
|
abortRef.current = null;
|
||||||
loadingRef.current = false;
|
loadingRef.current = false;
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setStreaming(null);
|
setStreaming(null);
|
||||||
@@ -382,11 +312,8 @@ export default function ChatPage() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const startNewChat = useCallback(() => {
|
const startNewChat = useCallback(() => {
|
||||||
// Give up ownership before aborting so the aborted request's onDone
|
abortRef.current?.abort();
|
||||||
// cannot restore the conversation being cleared.
|
|
||||||
const controller = abortRef.current;
|
|
||||||
abortRef.current = null;
|
abortRef.current = null;
|
||||||
controller?.abort();
|
|
||||||
loadingRef.current = false;
|
loadingRef.current = false;
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setStreaming(null);
|
setStreaming(null);
|
||||||
@@ -450,12 +377,13 @@ export default function ChatPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={i} className="flex flex-col gap-2">
|
<div key={i} className="flex flex-col gap-2">
|
||||||
{/* Messages in the chain are finished model calls, so their
|
|
||||||
reasoning is complete even when they ended in tool calls. */}
|
|
||||||
{hasText(msg.reasoning) && (
|
|
||||||
<ReasoningBubble reasoning={msg.reasoning} answerStarted />
|
|
||||||
)}
|
|
||||||
{calls.length > 0 && <ToolCallsGroup toolCalls={calls} />}
|
{calls.length > 0 && <ToolCallsGroup toolCalls={calls} />}
|
||||||
|
{hasText(msg.reasoning) && (
|
||||||
|
<ReasoningBubble
|
||||||
|
reasoning={msg.reasoning}
|
||||||
|
answerStarted={!!contentText}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{contentText && (
|
{contentText && (
|
||||||
<MessageBubble
|
<MessageBubble
|
||||||
role="assistant"
|
role="assistant"
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ import {
|
|||||||
LayoutItem,
|
LayoutItem,
|
||||||
ResponsiveGridLayout as Responsive,
|
ResponsiveGridLayout as Responsive,
|
||||||
} from "react-grid-layout";
|
} from "react-grid-layout";
|
||||||
import { aspectRatio, getCompactor } from "react-grid-layout/core";
|
import {
|
||||||
|
aspectRatio,
|
||||||
|
getCompactor,
|
||||||
|
verticalCompactor,
|
||||||
|
} from "react-grid-layout/core";
|
||||||
import "react-grid-layout/css/styles.css";
|
import "react-grid-layout/css/styles.css";
|
||||||
import "react-resizable/css/styles.css";
|
import "react-resizable/css/styles.css";
|
||||||
import {
|
import {
|
||||||
@@ -311,10 +315,17 @@ export default function DraggableGridLayout({
|
|||||||
[layoutAspects],
|
[layoutAspects],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const cameraNames = useMemo(
|
||||||
|
() =>
|
||||||
|
includeBirdseye && birdseyeConfig?.enabled
|
||||||
|
? ["birdseye", ...cameras.map((camera) => camera?.name || "")]
|
||||||
|
: cameras.map((camera) => camera?.name || ""),
|
||||||
|
[cameras, includeBirdseye, birdseyeConfig],
|
||||||
|
);
|
||||||
|
|
||||||
// Rescale a pre-masonry layout onto the current grid. Both axes scale by a
|
// Rescale a pre-masonry layout onto the current grid. Both axes scale by a
|
||||||
// constant, so tiles the user resized keep their size and their arrangement
|
// constant, so tiles the user resized keep their size. Only meaningful in
|
||||||
// stays intact. Only meaningful in bucketed mode, where a tile still has the
|
// bucketed mode, where a tile still has the shape those coordinates assumed.
|
||||||
// shape those coordinates assumed.
|
|
||||||
const convertLegacyLayout = useCallback(
|
const convertLegacyLayout = useCallback(
|
||||||
(stored: unknown): Layout | undefined => {
|
(stored: unknown): Layout | undefined => {
|
||||||
if (naturalAspectLayout || !Array.isArray(stored) || !stored.length) {
|
if (naturalAspectLayout || !Array.isArray(stored) || !stored.length) {
|
||||||
@@ -349,9 +360,17 @@ export default function DraggableGridLayout({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return converted;
|
// 0.18 stored new tiles at y 0 and compacted the grid at render, in
|
||||||
|
// render order. Compacting the same way reproduces what 0.18 showed.
|
||||||
|
|
||||||
|
return verticalCompactor.compact(
|
||||||
|
converted
|
||||||
|
.filter((item) => cameraNames.includes(item.i))
|
||||||
|
.sort((a, b) => cameraNames.indexOf(a.i) - cameraNames.indexOf(b.i)),
|
||||||
|
GRID_COLS,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
[naturalAspectLayout],
|
[naturalAspectLayout, cameraNames],
|
||||||
);
|
);
|
||||||
|
|
||||||
const generateLayout = useCallback(
|
const generateLayout = useCallback(
|
||||||
@@ -360,11 +379,6 @@ export default function DraggableGridLayout({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cameraNames =
|
|
||||||
includeBirdseye && birdseyeConfig?.enabled
|
|
||||||
? ["birdseye", ...cameras.map((camera) => camera?.name || "")]
|
|
||||||
: cameras.map((camera) => camera?.name || "");
|
|
||||||
|
|
||||||
const existing: LayoutItem[] = baseLayout
|
const existing: LayoutItem[] = baseLayout
|
||||||
? baseLayout.filter((layout) => cameraNames.includes(layout.i))
|
? baseLayout.filter((layout) => cameraNames.includes(layout.i))
|
||||||
: [];
|
: [];
|
||||||
@@ -426,7 +440,7 @@ export default function DraggableGridLayout({
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
[cameras, isGridLayoutLoaded, includeBirdseye, birdseyeConfig, dimsFor],
|
[cameraNames, isGridLayoutLoaded, dimsFor],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user