unplugin / unplugin-turbo-console

🚀 Improve the Developer Experience of console
https://utc.yuy1n.io
MIT License
526 stars 12 forks source link

Jump to editor for devcontainers #33

Open xiki808 opened 7 months ago

xiki808 commented 7 months ago

Clear and concise description of the problem

In my local environment I'm using vscode devcontainers, hence I'm loading my code from within a docker container. The jump to editor link is not working with this setup, any chance to add this feature?

Suggested solution

Jump to editor within a devcontainer setup

Alternative

No response

Additional context

No response

Validations

yuyinws commented 7 months ago

Thanks for your report. With the latest version. You can pass specifiedEditor option to launch editor for vscode devcontainers:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import TurboConsole from 'unplugin-turbo-console/vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    TurboConsole({
      specifiedEditor: 'code'
    })
  ],
})
xiki808 commented 7 months ago

I tested with the new version, the launch link now takes me to a new tab, which displays this:

image

I haven't seen any difference when running with specifiedEditor: 'code'

On checking the /inspect I see this:

image

For my docker setup, I do have a port forward for 3070

yuyinws commented 7 months ago

Please follow these steps on your devcontainers to troubleshooting:

  1. Make sure code command has installed.
  2. Make sure your local(outside devcontainers) dev environment no 3070 ports are occupied.
  3. Clone this repo and run node test.js, and check jump editor whether normal.
  4. Clone this repo and run pnpm dev, click the output on the console panel and and check jump editor whether normal.

At the same time, please pay attention to whether the terminal prints out some errors.

xiki808 commented 7 months ago

Hi @yuyinws, thanks will test it out today. I'm guessing I should run the tests on the container right?

I missed to mention I'm using WSL2 too

yuyinws commented 7 months ago

Yes, run the tests on the container.

xiki808 commented 7 months ago

Within the container I cloned launch editor, ran npm install and on node test.js it opens the packages/launch-editor/index.js file successfully in the current window.

Within the container I cloned vite turbo console, ran pnpm install and then pnpm dev. I get the following output:

image

Clicking on the local link it redirects to the browser but with URL: http://0.0.0.0:10104/. That port is the correct port that is mapped to 5173 within the container. The browser doesn't know about 0.0.0.0, but only localhost. http://localhost:10104/ would work

Clicking on Turbo console, it opens this url: http://localhost:3070/inspect and I get the empty inspect as I demonstrated above.

xiki808 commented 7 months ago

I tried mapping port 3070:3070 from host to container, but when I run vite turbo console and clicking on the turbo console link, I'm redirected to http://0.0.0.0:3070/inspect, which since of 0.0.0.0 the browser does not know about.

If I change the url to http://localhost:3070/inspect, I still get an empty inspect

yuyinws commented 7 months ago

I simulate your development environment and it works normal. I think this may be due to port mapping.

(check below gif)

Kapture 2024-04-26 at 22 42 16

xiki808 commented 6 months ago

I think the issue could be that my vite port mapping is a different fixed port, for example in my case: 10107:5173

Would be nice to have a config to specify that port 🙏

xiki808 commented 6 months ago

Gave it a test so vite port mapping was the same 5173:5173 as you can see below

image

Unfortunately only partial success, inspect page shows me the file, but on the launcher link click, it only opens the "everything is normal" new tab, rather than redirecting to the editor

image