Exafunction / codeium.nvim

A native neovim extension for Codeium
MIT License
639 stars 50 forks source link

add cross-platform solution to open the web app #169

Closed NONVME closed 2 months ago

NONVME commented 2 months ago

160 Done

CLAassistant commented 2 months ago

CLA assistant check
All committers have signed the CLA.

DajmondFM commented 2 months ago

Hey, you only add macos support can you also work about support for Windows. I was trying with start command but it was giving an error.

pqn commented 2 months ago

@DajmondFM what's the issue with using start that you saw?

DajmondFM commented 2 months ago

When trying to use :Codeium Chat it shows widnows error message

Windows cannot find the file 'http://127.0.0.1:50848?api_key=MY API KEY HERE'. Make sure the name is typed correctly, and then try again.

and when you manualy enter the url it shows Zrzut ekranu 2024-04-10 200633 with

{
  "url": "http://127.0.0.1:50848/",
  "connection": {
    "status": "CONNECTING",
    "error": {
      "name": "Error",
      "message": "Missing API key. Please make sure you are signed in to the Codeium plugin and close / reopen the chat window. If the problem persists, please restart the IDE."
    }
  },
  "isChatEnabled": false,
  "handshake": {},
  "params": {
    "ideTelemetryEnabled": false,
    "ready": false,
    "hasDevExtension": false,
    "hasEnterpriseExtension": false,
    "diffViewEnabled": false,
    "openFilePointerEnabled": false,
    "insertAtCursorEnabled": false
  },
  "data": {
    "numMessages": 0
  },
  "bridge": {
    "bridgeType": "null"
  },
  "health": {
    "checkStatus": null,
    "error": {
      "name": "TypeError",
      "message": "NetworkError when attempting to fetch resource."
    }
  }
}
pqn commented 2 months ago

@DajmondFM can I see your patch/branch which you tried this change out on?

DajmondFM commented 2 months ago

Of course

            local url = "http://127.0.0.1:"
                .. ports.chatClientPort
                .. "?api_key="
                .. api_key
                .. "&has_enterprise_extension="
                .. (config.options.enterprise_mode and "true" or "false")
                .. "&web_server_url=ws://127.0.0.1:"
                .. ports.chatWebServerPort
                .. "&ide_name=neovim"
                .. "&ide_version="
                .. versions.nvim
                .. "&app_name=codeium.nvim"
                .. "&extension_name=codeium.nvim"
                .. "&extension_version="
                .. versions.extension
                .. "&ide_telemetry_enabled=true"
                .. "&has_index_service="
                .. (config.options.enable_index_service and "true" or "false")
                .. "&locale=en_US"

            -- cross-platform solution to open the web app
            local os_info = io.get_system_info()
            if os_info.os == "linux" then
                os.execute("xdg-open '" .. url .. "'")
            elseif os_info.os == "macos" then
                os.execute("open '" .. url .. "'")
            elseif os_info.os == "windows" then
                os.execute("start '" .. url .. "'")
            else
                notify.error("Unsupported operating system")
            end
pqn commented 2 months ago

Can you try adding an extra empty argument to start before the URL? Like this SO answer: https://superuser.com/a/36730/171437

DajmondFM commented 2 months ago

You mean something like this? os.execute("start "" '" .. url .. "'")

pqn commented 2 months ago

Yes. If that works then maybe @NONVME can integrate into this PR.

DajmondFM commented 2 months ago

It's completely not working obraz

DajmondFM commented 2 months ago

Hey it's working. At least it's opening web app but I still get this error

{
  "url": "http://127.0.0.1:59021/?api_key=15be80b2-8251-4c9c-8056-16ea4abf4f81",
  "connection": {
    "status": "CONNECTING",
    "error": {
      "name": "Error",
      "message": "Missing chat language server URL. Please ensure that you are signed in to the Codeium plugin and close / reopen the chat window. If the problem persists, please restart the IDE."
    }
  },
  "isChatEnabled": false,
  "handshake": {},
  "params": {
    "ideTelemetryEnabled": false,
    "ready": true,
    "apiKey": "15be80b2-8251-4c9c-8056-16ea4abf4f81",
    "hasDevExtension": false,
    "hasEnterpriseExtension": false,
    "diffViewEnabled": false,
    "openFilePointerEnabled": false,
    "insertAtCursorEnabled": false
  },
  "data": {
    "numMessages": 0
  },
  "bridge": {
    "bridgeType": "null"
  },
  "health": {
    "checkStatus": null,
    "error": {
      "name": "TypeError",
      "message": "Failed to fetch"
    }
  }
}
NONVME commented 2 months ago

Hey it's working. At least it's opening web app but I still get this error

{
  "url": "http://127.0.0.1:59021/?api_key=15be80b2-8251-4c9c-8056-16ea4abf4f81",
  "connection": {
    "status": "CONNECTING",
    "error": {
      "name": "Error",
      "message": "Missing chat language server URL. Please ensure that you are signed in to the Codeium plugin and close / reopen the chat window. If the problem persists, please restart the IDE."
    }
  },
  "isChatEnabled": false,
  "handshake": {},
  "params": {
    "ideTelemetryEnabled": false,
    "ready": true,
    "apiKey": "15be80b2-8251-4c9c-8056-16ea4abf4f81",
    "hasDevExtension": false,
    "hasEnterpriseExtension": false,
    "diffViewEnabled": false,
    "openFilePointerEnabled": false,
    "insertAtCursorEnabled": false
  },
  "data": {
    "numMessages": 0
  },
  "bridge": {
    "bridgeType": "null"
  },
  "health": {
    "checkStatus": null,
    "error": {
      "name": "TypeError",
      "message": "Failed to fetch"
    }
  }
}

I think you have an authorization issue, and it is not related to this pr. You should use config like this

DajmondFM commented 2 months ago

Okey the issues is still here even after adding this build = ":Codeium Auth", but i will start new issue with it. And good job with this cross-platform support.

pqn commented 2 months ago

@NONVME just wanted to check that you're happy to merge this now before I go ahead and do so