-
Notifications
You must be signed in to change notification settings - Fork 0
fix/simplify-graph-viewer #5
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,4 +5,5 @@ coverage/ | |
| .DS_Store | ||
| .vscode/ | ||
| .idea/ | ||
| /temp/ | ||
| /temp/ | ||
| .gstack/ | ||
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| import type { GraphConfig } from "./types"; | ||
|
|
||
| export const DEFAULT_GRAPH_CONFIG: GraphConfig = { | ||
| direction: "TB", | ||
| direction: "LR", | ||
| showControllers: false, | ||
| nodesep: 50, | ||
| ranksep: 30, | ||
| edgeType: "bezier", | ||
| initialZoom: null, | ||
| panToTop: true, | ||
| paletteColors: { | ||
| // Graph node/edge colors | ||
| "--color-pipe": "#ff6b6b", | ||
| "--color-pipe-bg": "rgba(224,108,117,0.18)", | ||
| "--color-pipe-text": "#ffffff", | ||
|
|
@@ -27,6 +28,14 @@ export const DEFAULT_GRAPH_CONFIG: GraphConfig = { | |
| "--color-error-bg": "rgba(255,85,85,0.15)", | ||
| "--color-accent": "#8BE9FD", | ||
| "--color-warning": "#FFB86C", | ||
| // Base theme vars used by graph-core.css | ||
| "--color-bg": "#1e1e1e", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: These new palette keys are too generic for a component that writes its theme variables onto Prompt for AI agents |
||
| "--color-bg-dots": "#334155", | ||
| "--color-text-muted": "#94a3b8", | ||
| "--color-controller-text": "#94a3b8", | ||
| "--font-sans": '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', | ||
| "--font-mono": '"JetBrains Mono", "Monaco", "Menlo", monospace', | ||
| "--shadow-lg": "0 8px 24px rgba(0, 0, 0, 0.5)", | ||
| }, | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,14 +20,15 @@ import { toAppNodes, toAppEdges } from "./rfTypes"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { buildGraph } from "../graphBuilders"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getLayoutedElements, ensureControllerSpacing } from "../graphLayout"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { applyControllers } from "../graphControllers"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { DEFAULT_GRAPH_CONFIG } from "../graphConfig"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { hydrateLabels } from "./renderLabel"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { controllerNodeTypes } from "./ControllerGroupNode"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface GraphViewerProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| graphspec: GraphSpec | null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config: GraphConfig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| direction: GraphDirection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showControllers: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config?: GraphConfig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| direction?: GraphDirection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showControllers?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onNavigateToPipe?: (pipeCode: string) => void; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onReactFlowInit?: (instance: AppRFInstance) => void; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -42,8 +43,24 @@ function cloneCachedNodes(nodes: GraphNode[]): GraphNode[] { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function GraphViewer(props: GraphViewerProps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { graphspec, config, direction, showControllers, onNavigateToPipe, onReactFlowInit } = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| props; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| graphspec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config = DEFAULT_GRAPH_CONFIG, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| direction = config.direction ?? DEFAULT_GRAPH_CONFIG.direction ?? "TB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showControllers = config.showControllers ?? DEFAULT_GRAPH_CONFIG.showControllers ?? false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onNavigateToPipe, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onReactFlowInit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } = props; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Apply palette CSS vars on mount (so consumers don't have to) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| React.useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const palette = config.paletteColors ?? DEFAULT_GRAPH_CONFIG.paletteColors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (palette) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const [cssVar, value] of Object.entries(palette)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.documentElement.style.setProperty(cssVar, value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Restore root CSS variables in this effect; otherwise one GraphViewer instance can leave a stale palette applied globally after unmount or palette changes. Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, [config.paletteColors]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [nodes, setNodes, onNodesChange] = useNodesState<AppNode>([]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [edges, setEdges, onEdgesChange] = useEdgesState<AppEdge>([]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| .react-flow-container { | ||
| width: 100%; | ||
| height: 100%; | ||
| position: absolute; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Making the exported GraphViewer root Prompt for AI agents |
||
| inset: 0; | ||
| background: var(--color-bg); | ||
| } | ||
| .react-flow__node { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| "use client"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This client directive is too broad for the Prompt for AI agents |
||
|
|
||
| import "@xyflow/react/dist/style.css"; | ||
| import "./graph-core.css"; | ||
|
|
||
| export { GraphViewer } from "./GraphViewer"; | ||
| export type { GraphViewerProps } from "./GraphViewer"; | ||
| export type { AppNode, AppEdge, AppRFInstance } from "./rfTypes"; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
P2: Changing the exported default direction to
LRsilently changesGraphViewer's public default layout for every consumer that does not passdirection. KeepTBhere unless this breaking change is being rolled out intentionally with matching docs/release updates.Prompt for AI agents