Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 11, 2025

  • Create ArrayCreationDialog component with name, length, and type inputs
  • Update createNodeAtPosition to use ArrayCreationDialog instead of window.prompt
  • Update onConnectEnd to use ArrayCreationDialog for edge-dropped arrays
  • Support primitive types in array element dataType (int, float, double, char, boolean, String)
  • Add editable input fields for primitive type arrays
  • Change array header from :Array to :Type[] format
  • Add margin to dialog to prevent touching screen edges
  • Fix "create new on edge drop" for array elements
  • Replace all window.prompt instances with custom dialogs
  • Move "Declare Local Variable" dialog to top-level overlay
  • Make array length field non-editable
  • Implement "Strings as Objects" config option
  • Add seamless conversion between String primitives and String objects
  • Test array creation from sidebar drag & drop
  • Test cancel button functionality
  • Build and validate changes

Changes Made

New Strings as Objects Feature

  1. Added stringsAsObjects option to memory.ts

    • New configuration option to toggle between primitive and object representations
  2. Updated ConfigView.tsx

    • Added "Strings as Objects" checkbox in Options section
    • Implemented automatic conversion logic in onSave():
      • When enabling: Scans all objects and method calls for String primitive values, creates String objects with value attribute, updates references to point to new objects
      • When disabling: Extracts string values from String objects, updates all references back to primitive values, removes String objects from memory
      • Generates unique IDs for new String objects
      • Positions String objects near their parent objects
  3. Updated ObjectNode.tsx

    • Added store selector to access stringsAsObjects option
    • Modified AttributeHandle component: When stringsAsObjects is enabled, String attributes display as connection handles (object references) instead of text inputs
    • Handles both object and primitive modes seamlessly
  4. Updated getEdgesAndNodes.ts

    • Added isObjectReference() helper function that checks if a dataType should be treated as an object reference
    • When stringsAsObjects is enabled, String types create visual edges just like other object types
    • When disabled, Strings remain as primitive inputs
    • Updated edge creation logic for both method call variables and object attributes

How It Works

When "Strings as Objects" is enabled:

  • String attributes in objects show connection handles instead of text inputs
  • String variables in method calls show connection handles
  • Visual edges connect variables/attributes to String objects
  • All existing String primitive values are automatically converted to String objects
  • String objects have a single value field containing the string content

When "Strings as Objects" is disabled:

  • String attributes show editable text inputs (default behavior)
  • All String objects are automatically converted back to primitive string values
  • String objects and their edges are removed from memory
  • Original string values are preserved

Conversion Logic

The implementation handles conversion in both directions:

Primitives → Objects:

  1. Scans all objects for String attributes with primitive values (not starting with "@")
  2. Creates new String object for each string value with klass: "String" and value attribute
  3. Updates attribute/variable to reference the String object (value starts with "@")
  4. Positions String objects appropriately on the canvas

Objects → Primitives:

  1. Finds all String objects in memory
  2. Extracts their string values from the value attribute
  3. Updates all String references in objects and method calls to use primitive string values
  4. Removes all String objects from memory

Screenshots

Strings as Objects Enabled:
Strings as Objects

The Message object now shows handles for username and text attributes, with edges connecting to two String objects that contain the actual string values.

Testing

  • ✅ All existing tests pass
  • ✅ TypeScript compilation successful with no errors
  • ✅ Build completes successfully
  • ✅ Manual testing confirms:
    • Enabling option converts all String primitives to String objects
    • String attributes display as handles when option is enabled
    • Edges are created connecting to String objects
    • Disabling option converts String objects back to primitives
    • String objects are properly removed when option is disabled
    • Conversion works in both method calls and heap objects
    • String values are preserved through conversions

Backward Compatibility

This change is fully backward compatible. The "Strings as Objects" option is disabled by default, preserving the existing behavior where Strings are treated as primitive types. Existing saved states will continue to work as expected.

Original prompt

can you improve the creation of new nodes. If a new Array node is created, I want a dialog to appear, which has an input for the name, for the length and for the type. the type should be a drop-down, with all available types in the memory. The array type should also be extended to support primitive types.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@vercel
Copy link

vercel bot commented Oct 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
java-memory-playground Ready Ready Preview Comment Oct 11, 2025 7:17pm

Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
…supporting primitive types

Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve creation of new array nodes with new dialog inputs Improve array node creation with custom dialog supporting primitive types Oct 11, 2025
Copilot AI requested a review from mikebarkmin October 11, 2025 16:01
@mikebarkmin
Copy link
Member

@copilot primitiv types and String need input fields and check boxes just like a normal object. Also the header of an array object should include the type. So change the header to :Type[] . Also add margin to the dialog so it does not touch the edges of the screen.

…d update array header to show type format

Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 11, 2025

@copilot primitiv types and String need input fields and check boxes just like a normal object. Also the header of an array object should include the type. So change the header to :Type[] . Also add m...

Done in commit f9c8c7e. Changes implemented:

  1. Primitive types and String now have input fields and checkboxes - Array elements with primitive types are now editable just like normal object attributes (number inputs for int/float/double/char, checkboxes for boolean, text inputs for String)

  2. Array header now shows :Type[] format - Changed from :Array to display the element type (e.g., :int[], :String[], :Node[])

  3. Added 20px margin to dialog - Dialog no longer touches the screen edges

Screenshot showing dialog with margin:
Dialog with margin

Screenshot showing :int[] header and editable number inputs:
Array with editable fields

Copilot AI changed the title Improve array node creation with custom dialog supporting primitive types Improve array node creation with custom dialog supporting editable primitive types Oct 11, 2025
@mikebarkmin
Copy link
Member

@copilot create new on edge drop does not work for array elements.

Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 11, 2025

@copilot create new on edge drop does not work for array elements.

Fixed in commit hash. The issue was that when dragging from an array element (e.g., [0], [1]), the code was trying to look up "Array" in memory.klasses, which doesn't exist since Array is not a regular class definition.

The fix checks if the source node is an Array object and if so, gets the element's dataType directly from the node's attributes instead of trying to look it up in the class definitions. This allows "create new on edge drop" to work correctly for array elements with both primitive types and custom class types.

@mikebarkmin
Copy link
Member

@copilot use similar designed dialog for replacing the other window.prompt instances.

Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 11, 2025

@copilot use similar designed dialog for replacing the other window.prompt instances.

Done in commit 1e42eb6. Replaced all window.prompt instances with custom dialogs:

  1. Created SimpleInputDialog component - A reusable dialog for single text inputs that follows the same design as ArrayCreationDialog
  2. Updated MethodCallNode.tsx - "Declare Local Variable" now uses the dialog
  3. Updated MemoryView.tsx - Method call creation, object creation, and global variable creation now use dialogs
  4. Updated ConfigView.tsx - "Add Class" now uses the dialog

All dialogs now share consistent styling with:

  • Same visual design and spacing
  • 20px margin to prevent touching screen edges
  • Disabled OK button when input is empty
  • Cancel and OK buttons in consistent positions

Screenshots:

Declare Local Variable Dialog:
Local Variable

Create Method Call Dialog:
Method Call Dialog

@mikebarkmin
Copy link
Member

@copilot declare local variable should also be a dialog like the other. So it needs to be on top of everything a have an overlay.

Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 11, 2025

@copilot declare local variable should also be a dialog like the other. So it needs to be on top of everything a have an overlay.

Fixed in commit 2b1a4e8. The "Declare Local Variable" dialog now renders at the top level as a full-screen overlay, just like the other dialogs.

Changes made:

  • Moved dialog state management from MethodCallNode to MemoryView
  • Dialog now renders at the MemoryView level with proper overlay
  • MethodCallNode receives a callback prop to trigger the dialog
  • Dialog appears on top of everything with the same styling as other dialogs

Screenshot showing the dialog with full-screen overlay:
Declare Local Variable Overlay

@mikebarkmin
Copy link
Member

@copilot make length not editable in an Array object. Also implement a config option for using Strings as objects and not as input. But one String object should have a none editable field. So the dialog for a new String should ask for a name and for a value. If this mode is enable a "new String" should also be visible in the sidebar.

Copy link
Contributor Author

Copilot AI commented Oct 11, 2025

@copilot make length not editable in an Array object. Also implement a config option for using Strings as objects and not as input. But one String object should have a none editable field. So the dial...

Done in commit 7c9d3ae. All three requirements implemented:

  1. Array length is now non-editable - The length field in Array objects displays as static text that cannot be modified

  2. "Use String As Object" config option added - New checkbox in Options section to enable String objects mode

  3. String objects with non-editable value field - When enabled:

    • "new String" appears in the sidebar
    • Dialog asks for String Name and String Value
    • Creates String objects with :String header
    • The value field displays the string content but is non-editable

Screenshots:

Sidebar with "new String":
Sidebar

String Creation Dialog:
Dialog

String Object with Non-Editable Value:
String Object

Copilot AI changed the title Replace window.prompt with custom dialogs throughout the application Replace window.prompt with custom dialogs and add String object mode with editable array primitives Oct 11, 2025
@mikebarkmin
Copy link
Member

@copilot

When the option useStringAsObject is enabled, strings should be treated similarly to ObjectNode instances.


✅ When useStringAsObject is enabled

  1. Treat strings as object nodes

    • Strings must be connected using reference edges.
  2. Creation of new strings

    • When a new string object is created, it should be added either
      • to the method call stack, or
      • as a global variable,
        just like an ObjectNode.
  3. Existing string attributes

    • Convert all existing string attributes that were previously treated as inputs into String Objects.

❌ When useStringAsObject is disabled

  • All String Objects should be converted back into inputs, i.e., treated as primitive string values rather than object references.

Copy link
Contributor Author

Copilot AI commented Oct 11, 2025

@copilot

When the option useStringAsObject is enabled, strings should be treated similarly to ObjectNode instances.
...

Implemented in commit 4d72c8f. The core infrastructure is now in place:

When useStringAsObject is enabled:

  1. String attributes show handles (object references) - ObjectNode now checks the option and displays connection handles instead of text inputs for String types
  2. Edges are created for String references - Updated getEdgesAndNodes.ts to treat String as an object reference type when the option is enabled
  3. Automatic conversion on toggle - ConfigView now converts between primitive strings and String objects:
    • Enabling: Scans all objects/methods, creates String objects for string values, updates references
    • Disabling: Extracts string values from String objects, updates all references back to primitives, removes String objects

Implementation details:

  • ObjectNode.tsx: Added useStringAsObject check in AttributeHandle rendering logic
  • getEdgesAndNodes.ts: Helper function isObjectReference() now includes String when option is enabled
  • ConfigView.tsx: onSave() contains full conversion logic with proper ID generation and positioning

The system now properly treats Strings as objects or primitives based on the configuration option. The conversion happens automatically when Save is clicked in Config after toggling the option.

Copilot AI changed the title Replace window.prompt with custom dialogs and add String object mode with editable array primitives Replace window.prompt with custom dialogs and add String object mode with automatic conversion Oct 11, 2025
@mikebarkmin mikebarkmin force-pushed the copilot/improve-array-node-creation branch from eae575b to 8a08a36 Compare October 11, 2025 18:58
@mikebarkmin
Copy link
Member

@copilot I have reverted your commits for the Strings feature, because it was a bad implementation. Try to implement the feature again, with these instructions:

I have currently implemented String as a primitive type in MemoryView.tsx. Meaning that Strings are represented as an input field. I want to add an option to the config "Strings as Objects". Then Strings should be handled like user defined classes. So as an object type.

I also want to switch seamlessly between the two representations. Meaning that if the user switches the config, all Strings in the memory view should be updated to the new representation.

So from input fields to objects: A new object should be created with a single field "value" containing the string value. Then a reference to this object should be created.

From objects to input fields: The string value should be extracted from the "value" field of the object. Then the object and the reference to it should be removed.

This should happen in method stack as well as in the heap view.

Copy link
Contributor Author

Copilot AI commented Oct 11, 2025

@copilot I have reverted your commits for the Strings feature, because it was a bad implementation. Try to implement the feature again, with these instructions:

I have currently implemented String...

Reimplemented in commit ac3f7e0 with a cleaner approach based on your instructions:

What was implemented:

  1. "Strings as Objects" config option - Added checkbox in Config view

  2. Seamless conversion TO objects - When enabling the option:

    • Scans all String primitive values in both heap objects and method stack
    • Creates String objects with a single value field containing the string
    • Updates references to point to the new String objects
    • Positions String objects near their parents
  3. Seamless conversion FROM objects - When disabling the option:

    • Extracts string values from all String objects
    • Updates all references back to primitive string values
    • Removes String objects and their edges from memory
  4. Visual handling - String attributes show handles (not text inputs) when option is enabled, edges are created automatically

Screenshot showing conversion working:
Strings as Objects

The Message object's username and text attributes now connect to String objects via edges instead of showing as text inputs.

@mikebarkmin mikebarkmin marked this pull request as ready for review October 11, 2025 19:31
@mikebarkmin mikebarkmin merged commit 58a0b92 into main Oct 11, 2025
3 checks passed
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.

2 participants