Finding the right Contributions to hook into

New to theia and followed the docs so now have a working local ide.
I’m struggling a little to find what I think I need. I thought I’d outline what I’m trying to do and then ask some questions.

Background

We have a service where we allow devs. to write a GraphQL Schema and we provide APIs on the fly based on it.
Currently using CodeMirror with a custom folder like navigator to edit the GraphQL schema and Velocity templates.

Theia usage idea

Looking to adopt theia to replace custom editor.
From what I’ve gathered so far I figured something like this could work

  1. Add a backend contribution which accepted some params to identify the schema/templates i.e. workspace that needs to be edited

  2. Use auth token from those params to fetch the schema/templates via our API and write them to a unique dir

  3. Tell theia to change to this directory

  4. Add GraphQL and Velocity LSP support e.g. using https://github.com/graphql/graphiql/blob/master/packages/graphql-language-service

  5. Prevent navigation outside the root of this unique dir

  6. Hook into theia to replace the save handling, on save, as well as letting theia write to disk, make an API call also sync the changed files to our service

  7. Package theia in Docker and theia via an iframe passing in auth token and other params from 1 as query string params

Questions

  1. How do you generally find Contributions in the theia code base that you want to use? There’s no extensive list + their purpose as far as I’ve found so I assume the source is the best place to use as docs

  2. Does the outline above sound reasonable? What existing contributions would you recommend I start looking at to achieve each of those steps

  3. Is LSP required to get syntax highlighting for GraphQL/Velocity…for the first attempt, syntax highlighting may be sufficient

  4. If I don’t include the terminal extension is there another way for someone to navigate out of the folder I start them in? Can I pin a session to a root dir?

  5. This one’s more a capacity planning thing but what’s the general expectation for the number of users a single theia instance can serve? Ballpark figure is enough e.g. is it a scale of 10 parallel users, 100, 1000 etc

Thanks in advance

[original thread by Courtney Robinson]

[Courtney Robinson]

I should mention this is the plan for the first phase of this project. We have a number of features we want to add from in editor API querying/testing through to a visual GraphQL designer so the above is testing the waters and using Theia isn’t overkill when put in context of the rest of our roadmap.

Sorry for delay. I try to answer your questions other can correct me:

  1. Unfortunately we don’t have API usages docs yet. You can find a widget in Theia which does what you want and study how it works. After that do by analogy. You can also look for usages of bindContributionProvider to see explicit contribution points.

2.1 to add backend contribution, use BackendApplicationContribution

2.2 To write to a disk from the frontend use FileSystem, from the backend use node.js modules. See also about usages of URIs/paths in Theia: https://github.com/eclipse-theia/theia/wiki/Coding-Guidelines#uripath It’s important to support different operating systems.

2.3 Use WorkspaceService to access or change current workspace and its roots

2.4 For GraphQL, you can either wrap a LS into the theia extension, see @theia/python by analogy for example. Otherwise, you can put it into VS Code extension or reuse existing. Please follow for VS Code extensions: https://github.com/eclipse-theia/theia/wiki/Testing-VS-Code-Extensions

2.5 You can remove commands allowing a user to open other folders. User still will be able to escape using terminals. The best would be to give each user own isolated environment, i.e. Docker container, then users cannot access and affect each other in any way.

2.6 You can listen to save events with MonacoWorkspace.on(Will|Did)SaveTextDocument to sync with your filesystem.

2.7 See https://github.com/theia-ide/theia-apps for example docker images. We don’t have example of running Theia in iframe, but it was done before.

  1. For syntax higlighting, it is enough to register language and textmate grammar. Look at @theia/textmate for examples or use VS Code extension instead.

Is LSP required to get syntax highlighting for GraphQL/Velocity…for the first attempt, syntax highlighting may be sufficient

LSP is not required, you can register a Monaco language and textmate grammar. Look at @theia/textmate or use VS Code extension to contribute them.

If I don’t include the terminal extension is there another way for someone to navigate out of the folder I start them in? Can I pin a session to a root dir?

Only by completely isolating users on system level via docker containers for example.

This one’s more a capacity planning thing but what’s the general expectation for the number of users a single theia instance can serve? Ballpark figure is enough e.g. is it a scale of 10 parallel users, 100, 1000 etc

Generally Theia does not support multi-tenancy: You can allow multiple users to use the same backend but then they share all system resources and can affect each other.

Scaling even for single user with multiple windows depend on extensions which you use, size of your projects and your infrastructure. If you open a big project in several windows and run some memory hungry language server for each window, on slow machines you could get issues for a single user as well.

As far as I know, Gitpod is capable to run up to 20 isolated users on the same machine working on projects of different sizes, but there infrastructure is pretty good.