-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat(web): Introduce Tree View and Circles View in Web Viewer #1799
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
magyargergo
merged 11 commits into
abhigyanpatwari:main
from
hugogu:feature/viewer-update
May 26, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3471e90
feat(graph-view): add tree and circles layout modes
hugogu bbae989
fix(web): cap tree layout spring iterations and remove unused variable
hugogu 14c9c58
test(graph-adapter): add circles adapter tests and tree layout perf b…
hugogu e6b9cb2
refactor(web): rename Tree View → Sequential Layout, Circles → Radial…
hugogu 8e445e0
perf(web): add adaptive large-graph guards to sequential layout physics
hugogu e2f0def
fix(web): fix stale closure in sigma event handlers breaking node sel…
hugogu f7aafb0
fix(web): address three code-review bugs in graph rendering
hugogu 743a69c
fix(web): address three code-review bugs in graph rendering
hugogu 4e5df3d
fix(web): address four more PR review comments
hugogu a18ebff
Merge branch 'main' into feature/viewer-update
magyargergo 1bd1829
Merge branch 'main' into feature/viewer-update
magyargergo 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| /** | ||
| * E2E tests for graph layout mode switching (Sequential / Radial layouts). | ||
| * | ||
| * Requires: | ||
| * - gitnexus serve running on localhost:4747 with at least one indexed repo | ||
| * - gitnexus-web dev server running on localhost:5173 | ||
| * | ||
| * Skipped when servers aren't available (CI without services, etc.). | ||
| * Set E2E=1 to force-run even without the availability check. | ||
| */ | ||
|
|
||
| const BACKEND_URL = process.env.BACKEND_URL ?? 'http://localhost:4747'; | ||
| const FRONTEND_URL = process.env.FRONTEND_URL ?? 'http://localhost:5173'; | ||
|
|
||
| test.beforeAll(async () => { | ||
| if (process.env.E2E) return; | ||
| try { | ||
| const [backendRes, frontendRes] = await Promise.allSettled([ | ||
| fetch(`${BACKEND_URL}/api/repos`), | ||
| fetch(FRONTEND_URL), | ||
| ]); | ||
| if ( | ||
| backendRes.status === 'rejected' || | ||
| (backendRes.status === 'fulfilled' && !backendRes.value.ok) | ||
| ) { | ||
| test.skip(true, 'gitnexus serve not available on :4747'); | ||
| return; | ||
| } | ||
| if ( | ||
| frontendRes.status === 'rejected' || | ||
| (frontendRes.status === 'fulfilled' && !frontendRes.value.ok) | ||
| ) { | ||
| test.skip(true, 'Vite dev server not available on :5173'); | ||
| return; | ||
| } | ||
| if (backendRes.status === 'fulfilled') { | ||
| const repos = await backendRes.value.json(); | ||
| if (!repos.length) { | ||
| test.skip(true, 'No indexed repos — run gitnexus analyze first'); | ||
| return; | ||
| } | ||
| } | ||
| } catch { | ||
| test.skip(true, 'servers not available'); | ||
| } | ||
| }); | ||
|
|
||
| async function waitForGraphLoaded(page: import('@playwright/test').Page) { | ||
| await page.goto(`${FRONTEND_URL}?lng=en`); | ||
|
|
||
| // The app starts on the landing/onboarding screen. Pick the first repo card | ||
| // (preferring a known repo name) and click it to load the graph. | ||
| const landingCards = page.locator('[data-testid="landing-repo-card"]'); | ||
| const preferredCard = landingCards.filter({ hasText: /GitNexus|local-integration/ }).first(); | ||
| try { | ||
| await landingCards.first().waitFor({ state: 'visible', timeout: 15_000 }); | ||
| const card = (await preferredCard.count()) > 0 ? preferredCard : landingCards.first(); | ||
| await card.click(); | ||
| } catch { | ||
| // Landing screen may not appear (e.g. when ?server auto-connects) | ||
| } | ||
|
|
||
| // Wait until the status bar confirms the graph is ready. | ||
| const statusBar = page.getByRole('contentinfo'); | ||
| await expect(statusBar.getByText('Ready', { exact: true })).toBeVisible({ timeout: 45_000 }); | ||
| await expect(statusBar).toContainText(/nodes/, { timeout: 20_000 }); | ||
|
|
||
| // Finally confirm the sigma canvas is present. | ||
| await page.waitForSelector('.sigma-container', { timeout: 10_000 }); | ||
| } | ||
|
|
||
| test.describe('Graph Layout Modes', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await waitForGraphLoaded(page); | ||
| }); | ||
|
|
||
| test('should switch between force, sequential, and radial layouts', async ({ page }) => { | ||
| const forceTab = page.locator('button:has-text("Force Graph")'); | ||
| const sequentialTab = page.locator('button:has-text("Sequential Layout")'); | ||
| const radialTab = page.locator('button:has-text("Radial Layout")'); | ||
|
|
||
| // Force Graph is the default active tab | ||
| await expect(forceTab).toHaveClass(/bg-accent/); | ||
| await expect(sequentialTab).not.toHaveClass(/bg-accent/); | ||
|
|
||
| // Switch to Sequential Layout | ||
| await sequentialTab.click(); | ||
| await expect(sequentialTab).toHaveClass(/bg-accent/, { timeout: 5_000 }); | ||
| await expect(forceTab).not.toHaveClass(/bg-accent/); | ||
|
|
||
| // All three layout tabs should be present in the tab bar | ||
| await expect(radialTab).toBeVisible(); | ||
|
|
||
| // Switch back to Force Graph | ||
| await forceTab.click(); | ||
| await expect(forceTab).toHaveClass(/bg-accent/, { timeout: 5_000 }); | ||
| await expect(sequentialTab).not.toHaveClass(/bg-accent/); | ||
| }); | ||
|
|
||
| test('should interact with nodes in sequential layout', async ({ page }) => { | ||
| await page.locator('button:has-text("Sequential Layout")').click(); | ||
|
|
||
| // Click the first file-tree item in the sidebar (more reliable than a | ||
| // blind canvas click, which may land on empty space). The FileTreePanel | ||
| // renders node names as <span class="truncate font-mono text-xs">. | ||
| // Clicking any of them calls setSelectedNode, which shows the selection | ||
| // bar with the "Clear" button — the same mechanism used in | ||
| // server-connect.spec.ts's "Turn Off All Highlights" test. | ||
| const firstTreeItem = page.locator('span.truncate.font-mono').first(); | ||
| await firstTreeItem.waitFor({ state: 'visible', timeout: 10_000 }); | ||
| await firstTreeItem.click(); | ||
|
|
||
| await expect(page.locator('text=Clear')).toBeVisible({ timeout: 5_000 }); | ||
| }); | ||
| }); |
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
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,22 @@ | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { renderHook, act } from '@testing-library/react'; | ||
| import { GraphStateProvider, useGraphState } from './graph'; | ||
|
|
||
| function wrapper({ children }: { children: React.ReactNode }) { | ||
| return <GraphStateProvider>{children}</GraphStateProvider>; | ||
| } | ||
|
|
||
| describe('GraphState', () => { | ||
| it('should have default graphViewMode as "force"', () => { | ||
| const { result } = renderHook(() => useGraphState(), { wrapper }); | ||
| expect(result.current.graphViewMode).toBe('force'); | ||
| }); | ||
|
|
||
| it('should toggle graphViewMode', () => { | ||
| const { result } = renderHook(() => useGraphState(), { wrapper }); | ||
| act(() => { | ||
| result.current.setGraphViewMode('tree'); | ||
| }); | ||
| expect(result.current.graphViewMode).toBe('tree'); | ||
| }); | ||
| }); |
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.