Commit Graph

80 Commits

Author SHA1 Message Date
Dmitry Bushev
858e646328
Start Ydoc with the language server (#9862)
- related #7954

Changelog:
- update: Ydoc starts with the language server on the `localhost:1234` by default. The hostname and ports can be configured by setting environment variables `LANGUAGE_SERVER_YDOC_HOSTNAME` and `LANGUAGE_SERVER_YDOC_PORT`
- update: by default `npm dev run` uses the node Ydoc server. You can control it with `POLYGLOT_YDOC_SERVER` env variable. For example,
```
env POLYGLOT_YDOC_SERVER='true' npm --workspace=enso-gui2 run dev
```
To connect to the Ydoc server running on the 1234 port (the one started with the language server)
⠀
```
env POLYGLOT_YDOC_SERVER='ws://127.0.0.1:1235' npm --workspace=enso-gui2 run dev
```
To connect to the provided URL. Can be useful for debugging when you start a separate Ydoc process.
- update: run `npm install` before the engine build. It is required to create the Ydoc JS bundle.
2024-05-28 13:51:42 +00:00
Paweł Grabarz
8edf49343f
Expose cloud event logging endpoint to GUI and render GUI editor as react component. (#9951)
fixes #9730

Added a `logEvent` method to remote backend implementation in dashboard. Added an always-present remote backend instance that can be used for logging even when running a local project (intentional behavior).

# Important Notes
Because the backend implementation requires access to always fresh session token, the logger needs to be periodically updated on GUI side, so it can continue to function. To accomplish that, I simplified the app loading logic to treat GUI as an ordinary react component, so its props can be updated with normal react rendering flow. That refactor also removed the dynamic GUI asset loading code that was only needed for Rust GUI.
2024-05-27 17:32:42 +00:00
Paweł Grabarz
ca916b823e
Generalize keyed local storage for more client side graph-editor data (#9990)
Fixes #9938

The documentation panel openness and size state are saved in localStorage. On initial graph entry, the documentation panel is automatically opened if the graph's function is documented.
2024-05-27 12:53:16 +00:00
Adam Obuchowicz
8ba12356fe
Rename function widget (#9959)
Fixes #9790

Adds a new widget type which allows renaming the called function - if we are able to do it.
2024-05-22 15:07:39 +00:00
Kaz Wesley
9601543de3
Fix adding nodes in collapsed functions (#10009)
Insert new nodes before the block's terminal expression-statement, if present.

Fixes #9963.

# Important Notes
- Fix a bug that caused any empty lines at the beginning of a module not to be printed.
- Remove a redundant data-property from `GraphNode`.
2024-05-21 17:38:51 +00:00
Kaz Wesley
8823a2aaa0
Track live selection (#9924)
* Track live selection
2024-05-16 09:24:17 -04:00
Ilya Bogdanov
cc8e5ae2d1
Place dropdown arrow under autoscoped identifier (#9945)
Place arrows below autoscoped identifier, also fixes issue with CSS.
2024-05-14 13:45:04 +00:00
Adam Obuchowicz
9faa1823ec
Fix visualization resizing (#9946)
* Fixes #9942
* Restores updating visualization size in metadata. Also, the height is also stored.
2024-05-14 11:49:37 +00:00
Kaz Wesley
4af33f077b
Documentation editor (#9910)
#### New documentation panel:
- Shows documentation of currently-entered method.
- Open/close with Ctrl+D or the extended menu.
- Renders markdown; supports WYSIWYG editing.
- Formatting can be added by typing the same markdown special characters that will appear in the source code, e.g.:
- `# Heading`
- `## Subheading`
- `*emphasis*`
- Panel left edge can be dragged to resize similarly to visualization container.

https://github.com/enso-org/enso/assets/1047859/6feb5d23-1525-48f7-933e-c9371312decf

#### Node comments are now markdown:
![image](https://github.com/enso-org/enso/assets/1047859/c5df13fe-0290-4f1d-abb2-b2f42df274d3)

#### Top bar extended menu improvements:
- Now closes after any menu action except +/- buttons, and on defocus/Esc.
- Editor/doc-panel buttons now colored to indicate whether editor/panel is open.

https://github.com/enso-org/enso/assets/1047859/345af322-c1a8-4717-8ffc-a5c919494fed

Closes #9786.

# Important Notes
New APIs:
- `DocumentationEditor` component: Lazily-loads and instantiates the implementation component (`MilkdownEditor`).
- `AstDocumentation` component: Connects a `DocumentationEditor` to the documentation of an `Ast` node.
- `ResizeHandles` component: Supports reuse of the resize handles used by the visualization container.
- `graphStore.undoManager`: Facade for the Y.UndoManager in the project store.
2024-05-10 17:23:16 +00:00
Kaz Wesley
01a2ca458b
Enso color picker (#9825)
New color picker, designed for Enso:

https://github.com/enso-org/enso/assets/1047859/c3eff168-6807-4825-b17b-053e3cd8b04c

- Colors never clash: OKLCH lightness and chroma are fixed.
- Easily match colors: Colors of other nodes in the current method are expanded to slices of the color wheel.

Closes #9613.
2024-05-06 17:37:13 +00:00
Dmitry Bushev
5995a00958
Run ydoc-server with GraalVM (#9528)
part of #7954

# Important Notes
The workflow is:
- `$ npm install` -- just in case
- `$ npm --workspace=enso-gui2 run build-ydoc-server-polyglot` -- build the `ydocServer.js` bundle
- `$ sbt ydoc-server/assembly` -- build the ydoc server jar
- `env POLYGLOT_YDOC_SERVER=true npm --workspace=enso-gui2 run dev` -- run the dev server with the polyglot ydoc server. Providing `POLYGLOT_YDOC_SERVER_DEBUG=true` env variable enables the chrome debugger
2024-05-02 06:28:57 +00:00
Kaz Wesley
12cbd900b4
Node creation improvements (#9781) 2024-04-25 09:18:38 -04:00
Ilya Bogdanov
717f6bb330
Display argument placeholders for autoscoped constructors (#9737)
Fixes #9635 

<img width="925" alt="Screenshot 2024-04-18 at 2 43 09 PM" src="https://github.com/enso-org/enso/assets/6566674/fbdce484-ac0b-4e30-8577-1c9dc419dffe">
2024-04-24 13:40:42 +02:00
Kaz Wesley
6426478c97
Copy/paste improvements (#9734)
Copying nodes:
- Multiple nodes supported.
- Node comments and user-specified colors included.
- Google Sheets data can be pasted to produce a `Table` node, handled the same way as Excel data.

# Important Notes
- Fix E2E tests on OS X.
- Add E2E and unit tests for clipboard.
- Use the lexer to test text escaping; fix text escaping issues and inconsistencies.
2024-04-19 16:33:51 +00:00
Adam Obuchowicz
de406c69fa
Automatic reconnect with Language Server. (#9691)
Fixes #8520

If the websocket is closed not by us, we automatically try to reconnect with it, and initialize the protocol again. **Restoring state (execution contexts, attached visualizations) is not part of this PR**.

It's a part of making IDE work after hibernation (or LS crash).

# Important Notes
It required somewhat heavy refactoring:
1. I decided to use an existing implementation of reconnecting websocket. Replaced (later discovered by me) our implementation.
2. The LanguageServer class now handles both reconnecting and re-initializing - that make usage of it simpler (no more `Promise<LanguageServer>` - each method will just wait for (re)connection and initialization.
3. The stuff in `net` src's module was partially moved to shared's counterpart (with tests). Merged `exponentialBackoff` implementations, which also brought me to
4. Rewriting LS client, so it returns Result instead of throwing, what is closer our desired state, and allows us using exponentialBackoff method without any wrappers.
2024-04-19 13:39:45 +00:00
Paweł Grabarz
4bf79776c5
Store graph viewport in client local storage (#9651)
Fixes #6250

With this change, I've also slightly refactored the graph editor component by grouping related functionality into neat block and moving already loosely coupled groups to separate files. Further work will be needed to simplify it, but it is a good first step.

https://github.com/enso-org/enso/assets/919491/fedce111-ea79-463f-a543-da3ecce28bf5
2024-04-09 12:02:11 +00:00
Kaz Wesley
5f464389bc
Hide errors from input nodes (#9633)
When a node has an error/warning/panic that exactly matches one of its input nodes, hide the message until the node is interacted with, showing an icon.

https://github.com/enso-org/enso/assets/1047859/4b1b5e3d-c236-40d7-a3e7-e6ab8182ecd5

# Important Notes
- New icon is used for panics.
- Opening circular menu now shifts any message out of the way, not just warnings.
2024-04-05 18:07:32 +00:00
Paweł Grabarz
9c2d25ea8d
Improve gui app disposal handling and close all network connections (#9579)
Fixes #8964

All GUI network connections are now closed after the application is unmounted.
2024-04-04 13:49:54 +00:00
Ilya Bogdanov
bef6f3a4f9
Color picker (#9570)
Closes #8680

The color picker is triggered by new Circular menu item or by keyboard shortcut (set to `Mod+Shift+C` for **C**olor).
The color picker affects *selected* nodes, so it works nicely both in cases when we use Circular menu on a single node a shortcut with multiple selected nodes.

Color is only changed when the user selects a new one inside the color picker, but there is no specific way to reset default color (you would have to recreate the node).

https://github.com/enso-org/enso/assets/6566674/a4497bea-f432-486d-85f8-f2772ba5694f
2024-04-02 11:27:13 +00:00
Adam Obuchowicz
2384fe851d
Fix undoing node removal (#9561)
Fixes #9314

The node deletion does not remove AST node from the module, only unpin it from its parent; so undoing does not add this node, just modify it, and thus we weren't informed about metadata change.
2024-03-29 16:31:00 +00:00
Kaz Wesley
22a2c208c0
Multi-select (part 1) (#9516)
* Multi-select
2024-03-25 12:05:20 -04:00
Kaz Wesley
0d34126b86
New JSON visualization (#9409)
* JSON viz with projections, colors, inlining

* Ensure GraphEditor receives keyboard events for newly-selected nodes

* Consider positioned, unsized nodes when positioning
2024-03-25 12:03:18 -04:00
Adam Obuchowicz
a6fc8cb932
Reimplement AI PoC from GUI1 (#9476)
Fixes #9313

[Screencast from 2024-03-22 09-09-07.webm](https://github.com/enso-org/enso/assets/3919101/6ad86145-6882-4bde-993d-b1270f1ec06c)

# Important Notes
* This is PoC, so I didn't spend time on polishing the visuals; the design will likely change.
* I modified the shortcut handler a bit, allowing making multiple actions for same binding - the action's handler will be called in unspecified order, until one of them handle the event (i.e. not return false).
* To make it working regardless of imports, I needed to export AI module in Standard.Visualization. Moreover, needed to remove build_ai_prompt for Any, because it was causing issues - expect a bug report soon.
2024-03-25 09:14:41 +00:00
Kaz Wesley
ef9f3cc11e
Fix uninterpolated-text newline-insertion case (#9513)
Fixes #9494.
2024-03-21 14:20:53 +00:00
Kaz Wesley
e1893b65af
Self-argument access chain ports are conditional (#9439)
Ports for `PropertyAccess` AST nodes that (transitively) contain a `WidgetSelfArgument` are not targets for a disconnected edge, unless the mod key is held.

https://github.com/enso-org/enso/assets/1047859/68ac1953-c8b1-4e51-8c4c-211595e0c034

(Video shows with and without mod key)
2024-03-18 03:24:22 +00:00
Kaz Wesley
39976be267
More type-checking for concrete children (#9375)
Introduce a concrete NodeChild subtype; use it to statically check for the kind of bug that #9357 fixed.
2024-03-12 13:44:00 +00:00
Adam Obuchowicz
a01aeab3a4
Fix AST spacing (#9366)
Fixes #9357

The main issue was the spread operator using at the wrong place in functions overriding spacing of nodes. The bug, to be visible, required copying AST node before, because during copying `whitespace` field was explicitly set to undefined (in opposite to being unset), what in turns make spread overriding the value set by those functions.

# Important Notes
* To enable VSCode debugging, added a workspace for vitest and fix any relative path to be working-dir independent.
2024-03-12 01:57:29 +00:00
Kaz Wesley
8e437fa52a
Ast.Vector (#9328)
Add `Vector` AST type, corresponding to the `RawAst.Tree.Array` type (name `Array` not used for obvious reasons).

This is the first step of #5138.

### Important Notes

- Switched some string-based vector construction to `Vector.new`, improving type-safety.
- The `Ast` changes are covered by the round-trip tests; the use-site changes have been tested manually.
2024-03-08 15:14:06 -05:00
Paweł Grabarz
b7a8909818
Vue dependency update, better selection performance, visible quotes in text inputs (#9204)
- Improved performance by batching simulatenous node edits, including metadata updates when dragging many selected nodes together.
- Updated Vue to new version, allowing us to use `defineModel`.
- Fixed #9161
- Unified all handling of auto-blur by making `useAutoBlur` cheap to register - all logic goes through a single window event handler.
- Combined all `ResizeObserver`s into one.
- Fixed the behaviour of repeated toast messages. Now only the latest compilation status is visible at any given time, and the errors disappear once compilation passes.
- Actually fixed broken interaction of node and visualization widths. There no longer is a style feedback loop and the visible node backdrop width no longer jumps or randomly fails to update.
2024-03-06 15:34:07 +00:00
Kaz Wesley
44a1d9138b
Create and edit comments (#9230)
* CodeEditor: Fix dynamic imports

* Doc editing: AST support

* Doc editing

* Button and comment creation

* Fix concrete syntax edge case

* Remove testing code

* Fix
2024-03-01 12:56:18 -05:00
Ilya Bogdanov
c44b7f2c2d
Small visualization fixes (#9130)
Closes #9009

- [x] Fixed big white space above full screen viz.
- [x] Escape closes the full screen visualization.
- [x] Viz shortcuts (Shift-Space for toggling fullscreen vis, Ctrl-Space for switching vis type) are implemented.
- [x] The width of visualizations is preserved across project reopens (do we need height as well?)

New video:


https://github.com/enso-org/enso/assets/6566674/d9036ce9-57a4-429b-9bd9-6392782136ea

Older videos:

https://github.com/enso-org/enso/assets/6566674/d7129307-0626-4343-8a76-b9bf764c6a5b


https://github.com/enso-org/enso/assets/6566674/0518d3d8-9ed1-4e6c-bbe0-b7ed00bf7db3

# Important Notes
- Metadata format changed in backward-compatible way
2024-02-29 16:37:40 +00:00
Kaz Wesley
d7e8f271eb
Ensure objects obtained from Y.Js are not modified (#9217)
Y.Js caches values it returns from getters, so they must not be modified. Use `DeepReadonly` to protect values returned from `Y.Map`s in AST logic.
2024-02-29 16:22:33 +00:00
Kaz Wesley
97033a2ff4
Represent documentation in AST, load into Node (#9205)
Part of #9162.

- Add support for representing and interpreting the full text-literal/documentation syntax (escape codes, platform-independent newlines, string interpolations); build on generalized operations for structured-fields that will simplify future representation of other types like `Vector`.
- Load parsed and interpreted node documentation into `Node`s.
2024-02-28 20:43:23 +01:00
Kaz Wesley
edb349f8fc
Allow setting CB viz type; determine default from suggestion type info. (#9196)
Fixes #8570.

- Visualization type can be set per suggestion entry.
- Default visualization type for each suggestion is determined by suggestion type info.

# Important Notes
Previewing non-default visualizations seems to be broken (#9194), but this PR updates the GUI to select visualization types appropriately.
2024-02-27 15:49:56 +00:00
Kaz Wesley
323d46ec4e
Add property test for textChangeToEdits and applyTextEdits. (#9131)
Add a test for some functionality introduced in #9055.
2024-02-21 21:48:37 +00:00
Paweł Grabarz
d415d133bb
Fix node edits (#9111)
* Prevent duplication of external IDs in syncTree

* trim component browser accepted value

* use flush post for visualization data watcher

* do not create empty nodes when closing component browser

* Lint

---------

Co-authored-by: Kaz <kaz@lambdaverse.org>
2024-02-20 16:40:50 -05:00
Kaz Wesley
c811a5ae8b
Enable the Code Editor, with new apply-text-edits algo. (#9055)
- Fix the UI problems with our CodeMirror integration (Fixed view stability; Fixed a focus bug; Fixed errors caused by diagnostics range exceptions; Fixed linter invalidation--see https://discuss.codemirror.net/t/problem-trying-to-force-linting/5823; Implemented edit-coalescing for performance).
- Introduce an algorithm for applying text edits to an AST. Compared to the GUI1 approach, the new algorithm supports deeper identity-stability for expressions (which is important for subexpression metadata and Y.Js sync), as well as reordered-subtree identification.
- Enable the code editor.
2024-02-19 23:57:42 +00:00
Ilya Bogdanov
6881bc844e
Fix eslints in the project (#9005)
When using `npm run lint`, there are a lot of warnings for the last couple of weeks, and it is really annoying because I keep skipping important warnings for my files.
2024-02-09 11:22:33 +01:00
Kaz Wesley
e0ba39ed3e
Introduce SourceDocument for text edit support (#8957)
Introduce `SourceDocument`, a reactive source code representation that can be synced from a `MutableModule`. `SourceDocument` replaces various logic for tracking source code and spans--most importantly, `ReactiveModule`. There is no longer any reactively-tracked `Module`, per-se: Changes to the `MutableModule` attached to the synchronized `ydoc` are pushed as Y.Js events to the `SourceDocument` and `GraphDb`, which are reactively tracked. This avoids a problem in the upcoming text-synchronization (next PR) that was caused by a reactive back channel bypassing the `GraphDb` and resulting in observation of inconsistent states.

Stacked on #8956. Part of #8238.
2024-02-06 16:44:24 +00:00
Kaz Wesley
06f18864f4
Refactoring before text edits (#8956)
Changes in preparation for #8238 features.

# Important Notes
Changed edit APIs:
- **`graph.astModule` is deprecated.** It will be removed in my next PR.
- Prefer `graph.edit` to start and commit an edit.
- Use `graph.startEdit` / `graph.commitEdit` if the edit can't be confined to one scope.
2024-02-06 14:43:17 +00:00
Kaz Wesley
343a644051
Syntactic synchronization, automatic parentheses, metadata in Ast (#8893)
- Synchronize Y.Js clients by AST (implements #8237).
- Before committing an edit, insert any parentheses-nodes needed for the concrete syntax to reflect tree structure (fixes #8884).
- Move `externalId` and all node metadata into a Y.Map owned by each `Ast`. This allows including metadata changes in an edit, enables Y.Js merging of changes to different metadata fields, and will enable the use of Y.Js objects in metadata. (Implements #8804.)

### Important Notes

- Metadata is now set and retrieved through accessors on the `Ast` objects.
- Since some metadata edits need to take effect in real time (e.g. node dragging), new lower-overhead APIs (`commitDirect`, `skipTreeRepair`) are provided for careful use in certain cases.
- The client is now bundled as ESM.
- The build script cleans up git-untracked generated files in an outdated location, which fixes lint errors related to `src/generated` that may occur when switching branches.
2024-02-02 10:22:18 +01:00
Kaz Wesley
f88bd90ebb
Refactor for YJs AST (#8840)
Some refactoring separated from #8825 for easier review.

# Important Notes
**ID types**

The new *synchronization IDs* will replace `ExprId` for `Ast` references in frontend logic. `ExprId` (now called `ExternalId`) is now used only for module serialization and engine communication. The graph database will maintain an index that is used to translate at the boundaries. For now, this translation is implemented as a type cast, as the IDs have the same values until the next PR.

- `AstId`: Identifies an `Ast` node.
- `NodeId`: A subtype of `AstId`.
- `ExternalId`: UUID used for serialization and engine communication.

**Other changes**:

- Immediate validation of `Owned` usage.
- Eliminate `Ast.RawCode`.
- Prepare to remove `IdMap` from yjsModel.
2024-01-24 19:22:05 +00:00
Paweł Grabarz
48a5599eb6
improve argument placeholder resolution for partial applications and … (#8794)
Fixes #8788

- Fixed missing argument lists on constructors, and improved handling for various cases of partially applied functions.
- Extended tests to check for correct `self` argument placeholders.
- Additionally reworked some questionable test code to maintain separation between server and client code.

<img width="1241" alt="image" src="https://github.com/enso-org/enso/assets/919491/5377f57f-18f0-4a50-a8ab-9331862ca547">
2024-01-18 13:13:31 +00:00
Adam Obuchowicz
2e7d71d459
Refactor widgets to handle dynamic config in input (#8624)
* Merged ArgumentAst and ArgumentPlaceholder into single class.
* Created `AnyWidget` input being a "general use" widget input. Most wigets try to match with it; the `Argument` input is now solely for WidgetArgument(Name) or those handling arguments in a specific way (like selector which want to show on arg name click).
* dynamic config is now part of widget input, and is properly propagated through vector editor/function widgets.

# Important Notes
The widgets still does not work perfectly:
* The chosen options often don't have argument placeholders - that's because we don't display them for constructors. Needs to be added on our side, or engine should send us methodCall info for constructors.
* There are issues with engine's messages sent to us. This makes widgets does not set up (so there is no drop-down, or vector adds `_` instead of default). I'm investigating them and going to fill issues.
2024-01-03 13:37:52 +00:00
Kaz Wesley
19d0707334
Preparing for AST-based synchronization (#8625)
Further AST integration and API refinement before introducing the new synchronization mechanism.

closes #8609

# Important Notes
API changes:
- Renamed `Ast.parseExpression` / `Ast.parse` to better reflect their usage:
- `Ast.parse` returns a block or a single expression, depending on its input; this is convenient for expressions expected to be single-line.
- `Ast.parseBlock` always treats its input as a block; this is suitable for parsing a file.
- `astExtended` is no longer needed to access span information. `Ast.span` provides access to the value when appropriate (the project's committed modules have spans; uncommitted changes or other parsed expressions don't).
- `SourceRange` is now used everywhere in place of `ContentRange`--the two types had the same definition.

Features:
- Fix CodeEditor viewing.

Implementation improvements:
- Updated widget update handlers (#8545) implementation to Ast API.
- Integrated `imports` more thoroughly with new AST APIs.
- More tests.
2024-01-02 15:18:11 +00:00
Paweł Grabarz
56657cc684
[GUI2] Widget update handlers (#8545)
Fixes #8258 #8267

Added a generic way of setting a new expression value from within a widget, and ability to intercept those update calls from the child widgets. Used that to implement function argument assignment and clearing.

https://github.com/enso-org/enso/assets/919491/513b823b-eb2c-45d8-88ac-4971ba061c59
2023-12-22 10:59:57 +00:00
Kaz Wesley
277dfb1991
Ast edits (#8576)
- The module is edited by changing the AST, not the text representation.
- `IdMap`s no longer need to be maintained in parallel with the module content; they are snapshots produced as needed from the ASTs.
- Simplistic synchronization is in place until #8237: Edits are never merged; if two edits are started from the same state, one will be overwritten.
2023-12-19 17:58:11 +00:00
somebody1234
cbf7248370
Fixes for Language Server sync server (#8514)
- Closes #8398

# Important Notes
- The original error caused by a failing `text/openFile` (`openTextFile`) is still present, but (seemingly?) harder to repro now
2023-12-19 05:41:14 +00:00
somebody1234
c60bf6e892
Fallback to default visualization based on type, when no viz has been explicitly set (#8389)
- Closes #8386
- Attempts to execute `<expr>.default_visualization` to query the engine for the *correct* fallback type
- If that is not possible, falls back to checking `inputType` - first for an exact match, then falling back to `Any` (i.e. the text/JSON visualization)
- Does not decide fallback based on the shape of the returned JSON

# Important Notes
Contains pretty significant refactors of `VisualizationMetadata` to allow it to be unset.
2023-12-01 12:41:24 +00:00
somebody1234
3de37bd7d3
Minor QoL improvements (#8422)
- Minor fixes for CodeMirror highlighting (the `!` to stop recursion was making the entire import line purple, and preventing strings inside operators from being highlighted)
- Change some icons that contain dark blue, to use `currentColor` instead
- Add execution time to hover tooltip (the LS is sending it, so might as well display it)

# Important Notes
None
2023-11-30 11:58:08 +00:00