Skip to content

Fix/401 focus node bug#405

Merged
felix-schultz merged 3 commits intodevfrom
fix/401-focus-node-bug
Nov 28, 2025
Merged

Fix/401 focus node bug#405
felix-schultz merged 3 commits intodevfrom
fix/401-focus-node-bug

Conversation

@felix-schultz
Copy link
Copy Markdown
Member

This pull request introduces comprehensive support for layers (also called placeholders) in the flow copilot context and command system. It adds a new LayerContext structure, updates the graph context to include layers and their hierarchy, and extends all relevant copilot commands and tools to support placing, moving, and nesting nodes, placeholders, and comments within layers. Additionally, the UI is updated to streamline node focusing and propagate focus actions throughout components.

Layer/Placeholder Support and Context Expansion

  • Added a new LayerContext struct to represent layers/placeholder nodes, including hierarchy, pins, and contained node IDs, and integrated it into the GraphContext for LLM context generation. [1] [2]
  • Updated copilot prompt instructions and documentation to describe the new "layers" array, how to connect to layers, and new command fields for layer placement and nesting. [1] [2]
  • Exported LayerContext for use in other modules.

Copilot Command and Tool Extensions

  • Added an optional target_layer field to all relevant copilot commands (AddNode, AddPlaceholder, MoveNode, CreateComment, CreateLayer) to specify placement or nesting within a layer. [1] [2] [3] [4] [5]
  • Updated the emit command tool schemas to include target_layer for all applicable commands, with descriptions for LLM usage. [1] [2] [3] [4] [5]

UI Improvements and Node Focusing

  • Refactored the FlowBoard and FlowRunsComponent to centralize node focusing logic using the focusNode function, removing redundant code and ensuring consistent node focus behavior across components. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

These changes collectively enable advanced process modeling workflows with nested layers, better LLM context, and improved user interactions in the flow UI.

@felix-schultz felix-schultz linked an issue Nov 28, 2025 that may be closed by this pull request
@felix-schultz felix-schultz merged commit f6c62bf into dev Nov 28, 2025
3 of 10 checks passed
@felix-schultz felix-schultz deleted the fix/401-focus-node-bug branch November 28, 2025 07:14
Comment on lines +373 to 383
async (_instance: ReactFlowInstance) => {
if (initialized) return;
if (!nodeId || nodeId === "") return;

instance.fitView({
nodes: [
{
id: nodeId ?? "",
},
],
duration: 500,
});
focusNode(nodeId);
setInitialized(true);
},
[nodeId, initialized],
[nodeId, initialized, focusNode],
);

const [varsOpen, setVarsOpen] = useState(false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: focusNode's early return prevents setInitialized(true) if board.data is not loaded, causing node focus to fail silently.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The initializeFlow callback calls focusNode(nodeId) which contains an early return if board.data?.nodes[nodeId] is not found. If board.data has not loaded when onInit fires, focusNode returns early, preventing setInitialized(true) from being called. Since onInit only fires once, the node will never be focused even after board.data loads, leading to a silent failure to focus the node on initial board load.

💡 Suggested Fix

Ensure setInitialized(true) is always called in initializeFlow regardless of focusNode's outcome, or implement a retry mechanism for focusNode after board.data loads.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/ui/components/flow/flow-board.tsx#L370-L383

Potential issue: The `initializeFlow` callback calls `focusNode(nodeId)` which contains
an early return if `board.data?.nodes[nodeId]` is not found. If `board.data` has not
loaded when `onInit` fires, `focusNode` returns early, preventing `setInitialized(true)`
from being called. Since `onInit` only fires once, the node will never be focused even
after `board.data` loads, leading to a silent failure to focus the node on initial board
load.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 170916

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Focus Node Bug

1 participant