-
-
Notifications
You must be signed in to change notification settings - Fork 11k
refactor(ui): migrate memory page to shadcn #34366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yuneng-berri
merged 6 commits into
litellm_internal_staging
from
litellm_/migrate-page-memory-9b2c09
Jul 24, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9dda5d8
test(ui): characterise the memory page's drawer and header before mig…
yuneng-berri d2f872d
refactor(ui): migrate memory page to shadcn
yuneng-berri 5a3ab86
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
yuneng-berri a928db1
fix(ui): keep the memory detail sheet inside the viewport on narrow s…
yuneng-berri 58083b9
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
yuneng-berri caac7d8
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
yuneng-berri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
ui/litellm-dashboard/src/app/(dashboard)/memory/_components/MemoryDetailDrawer.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { render, screen } from "@testing-library/react"; | ||
| import userEvent from "@testing-library/user-event"; | ||
| import React from "react"; | ||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { MemoryRow } from "@/components/networking"; | ||
|
|
||
| import { MemoryDetailDrawer } from "./MemoryDetailDrawer"; | ||
|
|
||
| const makeMemory = (overrides: Partial<MemoryRow> = {}): MemoryRow => ({ | ||
| memory_id: "mem-1", | ||
| key: "user:profile", | ||
| value: "The user prefers concise answers.", | ||
| metadata: null, | ||
| user_id: "user-42", | ||
| team_id: "team-7", | ||
| created_at: "2024-05-01T12:00:00Z", | ||
| updated_at: "2024-05-02T12:00:00Z", | ||
| created_by: "alice", | ||
| updated_by: "bob", | ||
| ...overrides, | ||
| }); | ||
|
|
||
| describe("MemoryDetailDrawer", () => { | ||
| it("renders nothing until a row is selected", () => { | ||
| render(<MemoryDetailDrawer row={null} onClose={vi.fn()} />); | ||
|
|
||
| expect(screen.queryByText("Memory ID")).not.toBeInTheDocument(); | ||
| expect(screen.queryByText("Value")).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("shows the selected row's key, identifiers and value", () => { | ||
| render(<MemoryDetailDrawer row={makeMemory()} onClose={vi.fn()} />); | ||
|
|
||
| expect(screen.getByText("user:profile")).toBeInTheDocument(); | ||
| expect(screen.getByText("Memory ID")).toBeInTheDocument(); | ||
| expect(screen.getByText("mem-1")).toBeInTheDocument(); | ||
| expect(screen.getByText("User ID")).toBeInTheDocument(); | ||
| expect(screen.getByText("user-42")).toBeInTheDocument(); | ||
| expect(screen.getByText("Team ID")).toBeInTheDocument(); | ||
| expect(screen.getByText("team-7")).toBeInTheDocument(); | ||
| expect(screen.getByText("Value")).toBeInTheDocument(); | ||
| expect(screen.getByText("The user prefers concise answers.")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("falls back to a dash for a memory with no owning user or team", () => { | ||
| render(<MemoryDetailDrawer row={makeMemory({ user_id: null, team_id: null })} onClose={vi.fn()} />); | ||
|
|
||
| expect(screen.getAllByText("-")).toHaveLength(2); | ||
| expect(screen.queryByText("user-42")).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("omits the metadata block when the row carries no metadata", () => { | ||
| render(<MemoryDetailDrawer row={makeMemory({ metadata: null })} onClose={vi.fn()} />); | ||
|
|
||
| expect(screen.queryByText("Metadata")).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("pretty-prints metadata as JSON when present", () => { | ||
| render(<MemoryDetailDrawer row={makeMemory({ metadata: { tags: ["example"] } })} onClose={vi.fn()} />); | ||
|
|
||
| expect(screen.getByText("Metadata")).toBeInTheDocument(); | ||
| expect(screen.getByText('{ "tags": [ "example" ] }')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("attributes the created and updated timestamps to their actors", () => { | ||
| render(<MemoryDetailDrawer row={makeMemory()} onClose={vi.fn()} />); | ||
|
|
||
| expect(screen.getByText(/^Created .* by alice$/)).toBeInTheDocument(); | ||
| expect(screen.getByText(/^Updated .* by bob$/)).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("renders an em dash for a timestamp the backend did not send", () => { | ||
| render(<MemoryDetailDrawer row={makeMemory({ created_at: undefined, created_by: undefined })} onClose={vi.fn()} />); | ||
|
|
||
| expect(screen.getByText("Created —")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("closes through the close control", async () => { | ||
| const user = userEvent.setup(); | ||
| const onClose = vi.fn(); | ||
| render(<MemoryDetailDrawer row={makeMemory()} onClose={onClose} />); | ||
|
|
||
| await user.click(screen.getByRole("button", { name: /close/i })); | ||
|
|
||
| expect(onClose).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.