Repository navigation
feat(pages): tell readers comments reach an agent, and badge workspaces waiting on one #7730
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5d9da3c
feat(pages): tell readers comments reach an agent, and badge workspac…
harshithmullapudi 56a255c
docs(pages): capture the reader hint and sidebar badge against the de…
harshithmullapudi 9eaec6a
fix(pages): stop the reader hint and sidebar badge over-promising
harshithmullapudi c3ab0ce
docs(pages): recapture the reader hint in both states
harshithmullapudi 0cfb2da
fix(desktop): keep the page-comment badge reachable and org-correct
harshithmullapudi d1e20f8
test(desktop): put the modules LanguageAwareI18nProvider stubs back
harshithmullapudi 3874698
chore(pages): drop verification screenshots from the repo
harshithmullapudi 63689d2
refactor(desktop): show waiting page comments as a chip, not a row badge
harshithmullapudi 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
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
71 changes: 71 additions & 0 deletions
71
...ips/components/DashboardSidebarPageCommentsChip/DashboardSidebarPageCommentsChip.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,71 @@ | ||
| import { afterAll, afterEach, describe, expect, test } from "bun:test"; | ||
| import { GlobalRegistrator } from "@happy-dom/global-registrator"; | ||
|
|
||
| // happy-dom over the preloaded plain-object document — Radix's tooltip trigger | ||
| // needs a real DOM. Bun runs test files sequentially in one process and | ||
| // happy-dom's globals are process-wide, so we MUST unregister in afterAll to | ||
| // restore the shared mock document for the other renderer suites. | ||
| const alreadyRegistered = GlobalRegistrator.isRegistered; | ||
| if (!alreadyRegistered) GlobalRegistrator.register(); | ||
| ( | ||
| globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean } | ||
| ).IS_REACT_ACT_ENVIRONMENT = true; | ||
|
|
||
| const { cleanup, render } = await import("@testing-library/react"); | ||
| const { DashboardSidebarPageCommentsChip } = await import( | ||
| "./DashboardSidebarPageCommentsChip" | ||
| ); | ||
|
|
||
| afterEach(cleanup); | ||
| afterAll(async () => { | ||
| if (!alreadyRegistered) await GlobalRegistrator.unregister(); | ||
| }); | ||
|
|
||
| describe("DashboardSidebarPageCommentsChip", () => { | ||
| test("renders nothing when no comment is waiting", () => { | ||
| const { container } = render( | ||
| <DashboardSidebarPageCommentsChip count={0} />, | ||
| ); | ||
|
|
||
| expect(container.firstElementChild).toBeNull(); | ||
| }); | ||
|
|
||
| test("describes the count without relying on the tooltip", () => { | ||
| const { container } = render( | ||
| <DashboardSidebarPageCommentsChip count={3} />, | ||
| ); | ||
|
|
||
| const chip = container.firstElementChild as HTMLElement; | ||
| expect(chip.querySelector("span[aria-hidden='true']")?.textContent).toBe( | ||
| "3", | ||
| ); | ||
| expect(chip.querySelector(".sr-only")?.textContent).toBe( | ||
| "3 page comments are waiting on an agent here", | ||
| ); | ||
| }); | ||
|
|
||
| test("caps the rendered count but describes the real one", () => { | ||
| const { container } = render( | ||
| <DashboardSidebarPageCommentsChip count={150} />, | ||
| ); | ||
|
|
||
| const chip = container.firstElementChild as HTMLElement; | ||
| expect(chip.querySelector("span[aria-hidden='true']")?.textContent).toBe( | ||
| "99+", | ||
| ); | ||
| expect(chip.querySelector(".sr-only")?.textContent).toBe( | ||
| "150 page comments are waiting on an agent here", | ||
| ); | ||
| }); | ||
|
|
||
| test("carries the comment icon the other chips' chassis expects", () => { | ||
| const { container } = render( | ||
| <DashboardSidebarPageCommentsChip count={1} />, | ||
| ); | ||
|
|
||
| const chip = container.firstElementChild as HTMLElement; | ||
| expect(chip.className).toContain("rounded-full"); | ||
| expect(chip.className).toContain("bg-muted/60"); | ||
| expect(chip.querySelector("svg")).not.toBeNull(); | ||
| }); | ||
| }); | ||
55 changes: 55 additions & 0 deletions
55
...aceChips/components/DashboardSidebarPageCommentsChip/DashboardSidebarPageCommentsChip.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,55 @@ | ||
| import { Plural } from "@lingui/react/macro"; | ||
| import { Badge } from "@superset/ui/badge"; | ||
| import { Tooltip, TooltipContent, TooltipTrigger } from "@superset/ui/tooltip"; | ||
| import { LuMessageSquare } from "react-icons/lu"; | ||
| import { STROKE_WIDTH } from "renderer/screens/main/components/WorkspaceSidebar/constants"; | ||
|
|
||
| const MAX_RENDERED_COUNT = 99; | ||
|
|
||
| interface DashboardSidebarPageCommentsChipProps { | ||
| count: number; | ||
| } | ||
|
|
||
| /** | ||
| * Page-comment chip on the workspace activity line: how many page comments are | ||
| * waiting on an agent in this workspace. Unlike its neighbours there is no | ||
| * hover card — the read model behind it counts threads and cannot list them. | ||
| */ | ||
| export function DashboardSidebarPageCommentsChip({ | ||
| count, | ||
| }: DashboardSidebarPageCommentsChipProps) { | ||
| if (count <= 0) return null; | ||
|
|
||
| return ( | ||
| <Tooltip delayDuration={300}> | ||
| <TooltipTrigger asChild> | ||
| <Badge | ||
| variant="secondary" | ||
| className="h-[18px] bg-muted/60 px-1.5 py-0 text-[9px] font-medium tabular-nums text-muted-foreground [&>svg]:size-2.5" | ||
| > | ||
| <LuMessageSquare | ||
| className="size-2.5 shrink-0 text-primary" | ||
| strokeWidth={STROKE_WIDTH} | ||
| /> | ||
| <span aria-hidden="true" className="shrink-0"> | ||
| {count > MAX_RENDERED_COUNT ? `${MAX_RENDERED_COUNT}+` : count} | ||
| </span> | ||
| <span className="sr-only"> | ||
| <Plural | ||
| value={count} | ||
| one="# page comment is waiting on an agent here" | ||
| other="# page comments are waiting on an agent here" | ||
| /> | ||
| </span> | ||
| </Badge> | ||
| </TooltipTrigger> | ||
| <TooltipContent side="right"> | ||
| <Plural | ||
| value={count} | ||
| one="# page comment is waiting on an agent here" | ||
| other="# page comments are waiting on an agent here" | ||
| /> | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| ); | ||
| } |
1 change: 1 addition & 0 deletions
1
...nents/DashboardSidebarWorkspaceChips/components/DashboardSidebarPageCommentsChip/index.ts
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 @@ | ||
| export { DashboardSidebarPageCommentsChip } from "./DashboardSidebarPageCommentsChip"; |
45 changes: 45 additions & 0 deletions
45
...r/providers/DashboardSidebarPageCommentsProvider/DashboardSidebarPageCommentsProvider.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,45 @@ | ||
| import { createContext, type ReactNode, useContext, useMemo } from "react"; | ||
| import { useActiveOrganizationId } from "renderer/hooks/useActiveOrganizationId"; | ||
| import { cloudTrpc } from "renderer/lib/cloud-trpc"; | ||
|
|
||
| const WAITING_REFETCH_INTERVAL_MS = 60_000; | ||
| const WAITING_STALE_TIME_MS = 30_000; | ||
|
|
||
| const DashboardSidebarPageCommentsContext = createContext<Map< | ||
| string, | ||
| number | ||
| > | null>(null); | ||
|
|
||
| export function DashboardSidebarPageCommentsProvider({ | ||
| children, | ||
| }: { | ||
| children: ReactNode; | ||
| }) { | ||
| const organizationId = useActiveOrganizationId(); | ||
| const { data } = cloudTrpc.pageComment.waitingByWorkspace.useQuery( | ||
| undefined, | ||
| { | ||
| enabled: organizationId !== null, | ||
| refetchInterval: WAITING_REFETCH_INTERVAL_MS, | ||
| staleTime: WAITING_STALE_TIME_MS, | ||
| }, | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| ); | ||
|
|
||
| const waitingByWorkspaceId = useMemo( | ||
| () => | ||
| new Map( | ||
| (data ?? []).map((row) => [row.workspaceId, row.waitingCount] as const), | ||
| ), | ||
| [data], | ||
| ); | ||
|
|
||
| return ( | ||
| <DashboardSidebarPageCommentsContext.Provider value={waitingByWorkspaceId}> | ||
| {children} | ||
| </DashboardSidebarPageCommentsContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| export function useWorkspacePageCommentsWaiting(workspaceId: string): number { | ||
| return useContext(DashboardSidebarPageCommentsContext)?.get(workspaceId) ?? 0; | ||
| } | ||
4 changes: 4 additions & 0 deletions
4
...board/components/DashboardSidebar/providers/DashboardSidebarPageCommentsProvider/index.ts
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,4 @@ | ||
| export { | ||
| DashboardSidebarPageCommentsProvider, | ||
| useWorkspacePageCommentsWaiting, | ||
| } from "./DashboardSidebarPageCommentsProvider"; |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Restore the prior React act-environment value.
This file restores happy-dom but leaves
IS_REACT_ACT_ENVIRONMENTset totrue. Later renderer suites inherit the changed global state. Save the previous value before Line 12 and restore or delete the property inafterAll.Proposed fix
🤖 Prompt for AI Agents