-
Notifications
You must be signed in to change notification settings - Fork 0
FE-538: Entity sidebar (read-only) #24
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
57d0407
feat: entity sidebar with TanStack Query (FE-538)
lunelson f485d71
traceability: slice 6 done — I23 established, A21 partially validated
lunelson 24fd5da
refactor: derive observer JSON schema from Zod via toJSONSchema
lunelson dbf1c0d
refactor: remove deprecated formatHistory, update tests to use buildI…
lunelson 4e81e89
refactor: remove unused queryClient export from main.tsx
lunelson 62c3d07
refactor: remove createTranslator from sse-adapter
lunelson 4a60145
chore: update test coverage table after refactor
lunelson b5d22c2
fix: invalidate router after stream to show TurnCard
lunelson 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { useState } from 'react'; | ||
|
|
||
| import { Badge } from '@/components/ui/badge'; | ||
| import { cn } from '@/lib/utils'; | ||
|
|
||
| type Decision = { id: number; project_id: number; content: string; rationale: string | null }; | ||
| type Assumption = { id: number; project_id: number; content: string }; | ||
|
|
||
| type EntitiesData = { | ||
| decisions: Decision[]; | ||
| assumptions: Assumption[]; | ||
| }; | ||
|
|
||
| const tabs = ['Decisions', 'Assumptions'] as const; | ||
| type Tab = (typeof tabs)[number]; | ||
|
|
||
| export function useEntities(projectId: number) { | ||
| return useQuery<EntitiesData>({ | ||
| queryKey: ['entities', projectId], | ||
| queryFn: async () => { | ||
| const res = await fetch(`/api/projects/${projectId}/entities`); | ||
| if (!res.ok) throw new Error('Failed to fetch entities'); | ||
| return res.json(); | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| export function EntitySidebar({ projectId }: { projectId: number }) { | ||
| const [activeTab, setActiveTab] = useState<Tab>('Decisions'); | ||
| const { data, isLoading } = useEntities(projectId); | ||
|
|
||
| const decisions = data?.decisions ?? []; | ||
| const assumptions = data?.assumptions ?? []; | ||
|
|
||
| return ( | ||
| <div className="flex h-full w-72 flex-col border-l bg-card"> | ||
| {/* Tab bar */} | ||
| <div className="flex border-b"> | ||
| {tabs.map((tab) => { | ||
| const count = tab === 'Decisions' ? decisions.length : assumptions.length; | ||
| return ( | ||
| <button | ||
| key={tab} | ||
| type="button" | ||
| onClick={() => setActiveTab(tab)} | ||
| className={cn( | ||
| 'flex-1 px-3 py-2 text-sm font-medium transition-colors', | ||
| activeTab === tab | ||
| ? 'border-b-2 border-primary text-primary' | ||
| : 'text-muted-foreground hover:text-foreground', | ||
| )} | ||
| > | ||
| {tab} | ||
| {count > 0 && ( | ||
| <Badge variant="secondary" className="ml-1.5 px-1.5 py-0 text-[10px]"> | ||
| {count} | ||
| </Badge> | ||
| )} | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
|
|
||
| {/* Content */} | ||
| <div className="flex-1 overflow-y-auto p-3"> | ||
| {isLoading && <p className="text-sm text-muted-foreground">Loading...</p>} | ||
|
|
||
| {activeTab === 'Decisions' && ( | ||
| <div className="flex flex-col gap-2"> | ||
| {decisions.length === 0 && !isLoading && ( | ||
| <p className="text-sm italic text-muted-foreground"> | ||
| No decisions yet. They'll appear as the interview progresses. | ||
| </p> | ||
| )} | ||
| {decisions.map((d) => ( | ||
| <div key={d.id} className="rounded-md border p-2.5"> | ||
| <p className="text-sm">{d.content}</p> | ||
| {d.rationale && <p className="mt-1 text-xs text-muted-foreground">{d.rationale}</p>} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| )} | ||
|
|
||
| {activeTab === 'Assumptions' && ( | ||
| <div className="flex flex-col gap-2"> | ||
| {assumptions.length === 0 && !isLoading && ( | ||
| <p className="text-sm italic text-muted-foreground"> | ||
| No assumptions yet. They'll appear as the interview progresses. | ||
| </p> | ||
| )} | ||
| {assumptions.map((a) => ( | ||
| <div key={a.id} className="rounded-md border p-2.5"> | ||
| <p className="text-sm">{a.content}</p> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
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 |
|---|---|---|
| @@ -1,12 +1,24 @@ | ||
| import './index.css'; | ||
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
| import { RouterProvider } from '@tanstack/react-router'; | ||
| import { StrictMode } from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
|
|
||
| import { router } from './router.js'; | ||
|
|
||
| const queryClient = new QueryClient({ | ||
| defaultOptions: { | ||
| queries: { | ||
| staleTime: 30_000, | ||
| refetchOnWindowFocus: false, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| createRoot(document.getElementById('root')!).render( | ||
| <StrictMode> | ||
| <RouterProvider router={router} /> | ||
| <QueryClientProvider client={queryClient}> | ||
| <RouterProvider router={router} /> | ||
| </QueryClientProvider> | ||
| </StrictMode>, | ||
| ); |
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.
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.
src/client/components/EntitySidebar.tsx:31:
useEntitiesfailures aren’t surfaced, so a network/500 error will render the “No decisions/assumptions yet” empty state and silently mask the problem. Consider rendering an explicit error state usingisError/errorfrom React Query so users can distinguish “no entities” from “failed to load”.Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.