Google Project IDX, CodeServer and Gemini AI

Published: May 28, 2024 by Isaac Johnson

Recently at Google I/O, Google rolled out IDX, their new IDE meant to compete with the likes of Microsoft’s VS Code.

Once we agree to terms, we are presented with a rather simple start page

/content/images/2024/05/googleidx-01.png

We’ll start by trying my Forgejo instance

/content/images/2024/05/googleidx-02.png

Sadly they don’t like my URL, but do not really give a reason as to why. I tried Codeberg as well

/content/images/2024/05/googleidx-03.png

But that too is a no go.

It’s not that I have anything against Github, but it does seem a bit odd to ping themselves to their supposed competitor.

Not even Gitlab worked

/content/images/2024/05/googleidx-04.png

I’ll start with a simple private repo in Github

/content/images/2024/05/googleidx-05.png

It starts by setting up a workspace

/content/images/2024/05/googleidx-06.png

When I went to clone/update source I was prompted to auth in with a code

/content/images/2024/05/googleidx-07.png

Interestingly it was prompting me for VS Code auth so perhaps they are using the same code server i use

/content/images/2024/05/googleidx-08.png

Once authed, I could see it clone down

/content/images/2024/05/googleidx-09.png

The first warning I got was about too many active changes

/content/images/2024/05/googleidx-10.png

Most confusing to me was the initial staged changes appeared to be to wipe the repo out

/content/images/2024/05/googleidx-11.png

I found myself rather confuddled by the Source Control interface. I know other devs use it, but I tend to avoid it altogether - even in VS Code on the desktop. I opened a terminal and cleared out the staged issues and got back to main and all was well

/content/images/2024/05/googleidx-12.png

I think the problem really lies with me. I probably clicked something wrong or hit a key when setting my laptop down for a moment.

Can I use the terminal to get to Forgejo?

I cloned down a private Forgejo repo

/content/images/2024/05/googleidx-13.png

then ran ‘code .’ which launched a new browser window

/content/images/2024/05/googleidx-14.png

I confirmed that I wanted it to set up IDX

/content/images/2024/05/googleidx-15.png

I saw it create some files and prompt for a rebuild of the env

/content/images/2024/05/googleidx-16.png

I tried setting it to node and adding the idx files

/content/images/2024/05/googleidx-17.png

It seems to be set up to work

/content/images/2024/05/googleidx-18.png

I tried an inline chat and asked it to describe some actions

/content/images/2024/05/googleidx-19.png

I tried a few forms, but it always came up as an error

/content/images/2024/05/googleidx-20.png

No luck using the chat panel either

/content/images/2024/05/googleidx-21.png

A question about markdown was similarly rejected

/content/images/2024/05/googleidx-22.png

Even Javascript failed

/content/images/2024/05/googleidx-23.png

I’m questioning if this is because I forked to a new window - maybe that tripped things up.

Going back to my initial window, not only did it refresh to the Forgejo repo, I found the Gemini window was now working

/content/images/2024/05/googleidx-24.png

The inline chat did a marvelous job as well describing in simple terms a Gitea action

/content/images/2024/05/googleidx-25.png

I was then able to commit the change back to Forgejo without issue

/content/images/2024/05/googleidx-26.png

I did have to authenticate again so it’s not saving my credentials behind the scenes.

My next goal is to pause for a while and come back in the morrow on a different machine. Will my URL get me just to my blog checkout or also the Forgejo?

I came back several days later and with a new browser. I could see my project listed after logging in

/content/images/2024/05/googleidx-27.png

It again set up the workspace

/content/images/2024/05/googleidx-28.png

However, it dropped me right back to where I was before which was excellent.

/content/images/2024/05/googleidx-29.png

This means I have way to work outside the boundaries of Github which, at least for me, makes this a far more useful tool. I should be able to use Azure Repos, Github, Gitlab, Codeberg, Gitea, Forgejo all equally.

With the terminal, we should also mention we are getting a free micro Linux box to use as well with 2 vCPU and 8Gb of memory:

/content/images/2024/05/googleidx-30.png

We can use home to get back to the main Project IDX page

/content/images/2024/05/googleidx-31.png

Starting something new

Let’s try and create a new project. I’ll ask for a fresh NodeJS Express app

/content/images/2024/05/googleidx-32.png

We are dropped into a running Hello World express app

/content/images/2024/05/googleidx-33.png

Let’s look at editing together as well as initializing the repo

Let’s do a simple ask of Gemini. How might we insert the current date into the page?

/content/images/2024/05/googleidx-34.png

We can see a diff style inline suggestion we are prompted to accept

/content/images/2024/05/googleidx-35.png

Which seems good. I saved and refreshed the page and saw it working

/content/images/2024/05/googleidx-36.png

It’s now quite easy to commit our change and push to a fresh Forgejo repo

On Project IDX

About a year ago in August, a group of Google developers started the project built primarily on Code OSS (which we’ve written about before) and Codey, a generative AI model built on PaLM 2. They trained it on code and its been in private preview for some time.

An Inforworld Article confirmed that while it’s currently free, the Cloud Workstation would normally run between 0.16 and 9.36/hr (The one we see for our express example runs at 0.16 matching the class e2-standard-2).

Right now there really is nothing about cost on the Project page but I have to assume eventually they’ll shutter it or charge for it. I also have to wonder about using the OS variant of Microsoft’s Visual Studio code.

Code OS

As it’s been a while and I never did restore my Code OS instance after the big cluster rebuild, let’s do that quick.

It’s as simple as an A record (still there) and then a YAML manifest


$ cat prod-codeserver.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: code-server-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: code-server
  template:
    metadata:
      labels:
        app: code-server
    spec:
      containers:
      - name: code-server-container
        image: lscr.io/linuxserver/code-server:latest
        ports:
        - containerPort: 8443
        env:
        - name: PUID
          value: "1000"
        - name: PGID
          value: "1000"
        - name: PASSWORD
          value: "MyPasswordHere!"
        - name: SUDO_PASSWORD
          value: "MyOtherPasswordHere!"
        - name: TZ
          value: "America/Chicago"
        volumeMounts:
        - name: code-server-config
          mountPath: /config
      volumes:
      - name: code-server-config
        persistentVolumeClaim:
          claimName: code-server-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: code-server-pvc
spec:
  storageClassName: managed-nfs-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: v1
kind: Service
metadata:
  name: codeserver-service
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8443
  selector:
    app: code-server
  type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: "true"
    ingress.kubernetes.io/proxy-body-size: "0"
    ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.org/websocket-services: codeserver-service
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.org/client-max-body-size: "0"
    nginx.org/proxy-connect-timeout: "3600"
    nginx.org/proxy-read-timeout: "3600"
  labels:
    app.kubernetes.io/instance: codeingress
  name: codeingress
spec:
  rules:
  - host: code.freshbrewed.science
    http:
      paths:
      - backend:
          service:
            name: codeserver-service
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific
  tls:
  - hosts:
    - code.freshbrewed.science
    secretName: code-tls

which I can launch

$ kubectl apply -f ./codeserver.yaml
deployment.apps/code-server-deployment configured
persistentvolumeclaim/code-server-pvc unchanged
service/codeserver-service configured
ingress.networking.k8s.io/codeingress configured

Then login

/content/images/2024/05/googleidx-38.png

Which then prompts me

/content/images/2024/05/googleidx-39.png

I can then add Duet (Gemini) via the extensions

/content/images/2024/05/googleidx-40.png

It seemed to fail on the GCloud CLI install

/content/images/2024/05/googleidx-41.png

I tried to Ctrl-p and do the shortcut, but that just redirects to Gemini

/content/images/2024/05/googleidx-42.png

I installed directly on the container via the Terminal, then tried again - this time I said “use existing Google Cloud CLI”. It seemed to work

/content/images/2024/05/googleidx-43.png

I could then start the setup steps

/content/images/2024/05/googleidx-44.png

I logged into GCloud using the CLI in the terminal

/content/images/2024/05/googleidx-45.png

The Project Select button does nothing

/content/images/2024/05/googleidx-46.png

But I can get there using the settings

/content/images/2024/05/googleidx-47.png

I’ll also add some languages

/content/images/2024/05/googleidx-48.png

I could now see Duet/Gemini stepping in to offer suggestions on a fresh markdown file

/content/images/2024/05/googleidx-49.png

I can also get there via the right-click menu to Gemini Code Assist

/content/images/2024/05/googleidx-50.png

I was curious what a “Generate Code” would do in a Markdown file.

/content/images/2024/05/googleidx-51.png

It looks to just offer a lot of general Markdown options.

Summary

Today we took a look at Project IDX which has just recently been rolled out to the general public. Leveraging Code server, we have essentially a web-based VS Code with Gemini AI built-in.

While the current offering suggests it’s pinned to Github repos, we showed multiple ways to “jailbreak” into Forgejo and other GIT repo servers. We looked at some basic code generation and also data persistence.

Lastly, we relaunched an OS CodeServer instance and integrated with Duet AI/Google Gemini with Code Assist to essentially render the same thing on a self-hosted Kubernetes. This would allow us to have containers that reach internal resources at the consequence of ultimately needing to pay for API usage via our GCP Biling project.

Gemini GCP VSCode CodeServer ProjectIDX OpenSource Containers Kubernetes

Have something to add? Feedback? You can use the feedback form

Isaac Johnson

Isaac Johnson

Cloud Solutions Architect

Isaac is a CSA and DevOps engineer who focuses on cloud migrations and devops processes. He also is a dad to three wonderful daughters (hence the references to Princess King sprinkled throughout the blog).

Theme built by C.S. Rhymes