Skip to content

Conversation

@deepfates
Copy link
Owner

Summary

  • remove the select+A combo and instead track pending sibling creation when the right arrow is pressed on the last available continuation
  • open the edit menu in this case with a draft node and only append a new sibling when the edit is saved
  • add a createSiblingNode helper on the story tree hook to append siblings, update selection, and keep metadata in sync

Testing

  • npm run lint (fails: ESLint configuration missing)
  • npm run build (fails: rollup optional dependency not installed in environment)

https://chatgpt.com/codex/tasks/task_e_68cf1f2317048327a73c1ca3ec15e86a

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new sibling editing flow that replaces the previous select+A combo with automatic sibling creation when navigating past the rightmost node. When the right arrow is pressed on the last continuation, it now opens the edit menu with a draft node and only creates the sibling when the edit is saved.

Key changes:

  • Track pending sibling creation state instead of immediately creating nodes
  • Open edit menu with draft node when moving past rightmost continuation
  • Add createSiblingNode helper to manage sibling creation, selection updates, and metadata synchronization

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
client/interface/hooks/useStoryTree.ts Adds createSiblingNode helper function for managing sibling node creation and state updates
client/interface/Interface.tsx Implements pending sibling state tracking and draft node editing flow with right arrow navigation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


return parent.continuations[newIndex];
},
[storyTree, currentTreeKey, setTrees],
Copy link

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

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

The dependency array is missing touchStoryUpdated which is called within the createSiblingNode function. This could lead to stale closure issues if touchStoryUpdated is redefined.

Suggested change
[storyTree, currentTreeKey, setTrees],
[storyTree, currentTreeKey, setTrees, touchStoryUpdated],

Copilot uses AI. Check for mistakes.
depth: currentDepth,
pathIds,
draft: {
id: `draft-${Date.now().toString(36)}`,
Copy link

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

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

Using Date.now().toString(36) for ID generation could potentially create collisions in rapid succession. Consider using a more robust ID generation method like crypto.randomUUID() or a dedicated UUID library.

Suggested change
id: `draft-${Date.now().toString(36)}`,
id: `draft-${crypto.randomUUID()}`,

Copilot uses AI. Check for mistakes.
}

return {
id: Math.random().toString(36).substring(2, 15),
Copy link

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

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

This ID generation method using Math.random() is inconsistent with the draft ID generation above and could potentially create collisions. Consider using a consistent, more robust ID generation method throughout the codebase.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants