Skip to content

Commit 239ab85

Browse files
authored
feat: replace VS Code integration with Code Server plugin (#1036)
1 parent 202b51d commit 239ab85

23 files changed

Lines changed: 574 additions & 608 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export default defineNuxtConfig({
150150
devtools: {
151151
// Enable devtools (default: true)
152152
enabled: true,
153-
//VS Code Server options
154-
vscode: {},
153+
//Coder code-server options (enabled by default)
154+
codeServer: {},
155155
// ...other options
156156
}
157157
})

‎docs/content/1.guide/0.getting-started.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ export default defineNuxtConfig({
104104
devtools: {
105105
// Enable devtools (default: true)
106106
enabled: true,
107-
//VS Code Server options
108-
vscode: {},
107+
//Coder code-server options (enabled by default)
108+
codeServer: {},
109109
// ...other options
110110
}
111111
})

‎docs/content/1.guide/1.features.md‎

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -112,79 +112,38 @@ Module authors who want to expose their own data can install [`@devframes/plugin
112112
The `getServerData` DevTools RPC that backed the old viewer is deprecated (`NDT_DEP_0009`). It still works as a compatibility shim but will be removed; use the Data Inspector panel instead.
113113
::
114114

115-
## VS Code Server
115+
## Code Server
116116

117-
The VS Code Server integration in Nuxt DevTools enhances your development experience by bringing the power of Visual Studio Code directly into your browser. With this feature, you can seamlessly edit and debug your Nuxt projects using the familiar interface of VS Code.
117+
The **Code Server** member in the Nuxt group embeds [Coder's `code-server`](https://coder.com/docs/code-server/install). It is enabled by default: Nuxt DevTools detects the local `code-server` binary during setup, but starts no process until you choose **Launch editor**. If the binary is missing, the member shows installation instructions instead.
118118

119-
Nuxt DevTools supports the following ways of integrating with VS Code:
120-
121-
### Connecting to an existing code-server instance
122-
123-
Set `reuseExistingServer` to true in runtime config for `devtools/vscode` and set the `port` option to specify a port (defalts to 3080):
124-
125-
```ts [nuxt.config.ts]
126-
exportdefaultdefineNuxtConfig({
127-
devtools: {
128-
vscode: {
129-
reuseExistingServer: true,
130-
port: 3090
131-
}
132-
}
133-
})
134-
```
135-
136-
### Running a code-server instance locally
137-
138-
You can use either the [Microsoft Visual Studio Code Server](https://code.visualstudio.com/docs/remote/vscode-server) (via the `code` or `code-server` cli tools) or the [Coder VS Code Server](https://coder.com/docs/code-server/latest/install) (via the `code-server` cli tool) by setting the `codeServer` parameter under `devtools/vscode` in the runtime configuration.
139-
140-
Options for the codeServer parameter are:
141-
142-
| Type | Option |
143-
| ----------------- | ------------------- |
144-
| MS Code CLI |`ms-code-cli`|
145-
| MS Code Server |`ms-code-server`|
146-
| Coder Code Server |`coder-code-server`|
147-
148-
You can set the `port` parameter to listen on a specific port (default 3080) and you can set the `host` parameter if you need to listen on a particular host interface (useful for devcontainers or docker containers that listen on ipv6 by default).
149-
150-
**Example**:
151-
152-
```ts [nuxt.config.ts]
153-
exportdefaultdefineNuxtConfig({
154-
devtools: {
155-
vscode: {
156-
codeServer: 'ms-code-server',
157-
host: '0.0.0.0',
158-
port: 3090
159-
}
160-
}
161-
})
162-
```
163-
164-
### Remotely via a MS VS Code server tunnel
165-
166-
Set the `mode` option in `devtools/vscode` runtime configuration to `tunnel`. You can set the name of the tunnel to connect to using the `tunnel` option under `devtools/vscode/tunnel` in runtime configuration)
119+
When launched, Code Server opens the Nuxt root directory by default, hands the generated authenticated session to the iframe, and streams process output to the built-in **Terminals** member. The process is also stopped when Nuxt closes.
167120

168121
```ts [nuxt.config.ts]
169122
exportdefaultdefineNuxtConfig({
170123
devtools: {
171-
vscode: {
172-
mode: 'tunnel',
173-
tunnel: {
174-
name: 'my-tunnel-name'
175-
}
176-
}
177-
}
124+
codeServer: {
125+
enabled: true,
126+
// All fields below are optional.
127+
bin: '/usr/local/bin/code-server',
128+
cwd: '/workspace/my-app',
129+
serverPort: 8080,
130+
host: '127.0.0.1',
131+
args: ['--disable-file-downloads'],
132+
env: { LOG_LEVEL: 'info' },
133+
cookieSuffix: 'my-app',
134+
startTimeout: 30_000,
135+
},
136+
},
178137
})
179138
```
180139

181-
### Code Server Installation Instructions
140+
The curated options are `enabled`, `bin`, `cwd`, `serverPort`, `host`, `args`, `env`, `cookieSuffix`, and `startTimeout`. When omitted, the upstream plugin defaults apply: the `code-server` binary, loopback host, a free port near Code Server's port 8080, and a 30-second startup timeout. Nuxt changes only the default `cwd`, setting it to the Nuxt root. Set `codeServer.enabled: false` to omit the member.
182141

183-
To get started with Microsoft VS Code Server, follow the installation instructions provided by [Microsoft Visual Studio Code Server](https://code.visualstudio.com/docs/remote/vscode-server)
142+
Nuxt DevTools owns authentication, so `args` cannot override `--auth`, `--bind-addr`, or `--cookie-suffix`, and `env` cannot set `PASSWORD` or `HASHED_PASSWORD`. Configure the bind host and cookie suffix through their dedicated fields.
184143

185-
To get started with Coder Code Server, follow the installation instructions provided by [Code Server Installation Guide](https://coder.com/docs/code-server/latest/install)
144+
The editor iframe connects directly to the Code Server port; Nuxt does not proxy it through `app.baseURL`. The browser must be able to reach that host and port, and an HTTPS page cannot embed an HTTP-only editor because of browser mixed-content rules. Binding to a non-loopback interface also exposes the port to that network, so apply the usual network controls.
186145

187-
For more information on the benefits and features of VS Code Server, refer to [the official Visual Studio Code blog](https://code.visualstudio.com/blogs/2022/07/07/vscode-server)
146+
This integration uses the experimental upstream `@devframes/plugin-code-server`. HTTPS, reverse proxies, containers, and remote port forwarding are governed by that plugin and your environment; Nuxt does not extend them or provide the removed Microsoft/tunnel/reuse modes.
188147

189148
## Hooks
190149

‎docs/content/2.module/3.migration-v4.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,37 @@ title: Migration to v4
33
description: 'Breaking changes and migration guide for Nuxt DevTools v4.'
44
---
55

6+
## `vscode` option removed {#ndt_dep_0008}
7+
8+
The bespoke `devtools.vscode` integration has been replaced by the Code Server
9+
Devframe plugin. Supplying `vscode` emits `NDT_DEP_0008`; the complete value is
10+
ignored and is not translated, because partially mapping the old modes would
11+
silently change their behavior.
12+
13+
```diff
14+
export default defineNuxtConfig({
15+
devtools: {
16+
- vscode: { enabled: true },
17+
+ codeServer: { enabled: true },
18+
},
19+
})
20+
```
21+
22+
The replacement supports only a locally installed Coder
23+
[`code-server`](https://coder.com/docs/code-server/install), detected at setup
24+
and started on demand. These legacy capabilities were removed:
25+
26+
- Microsoft `code serve-web` and Microsoft `code-server serve-local`;
27+
- VS Code tunnels;
28+
- reusing an existing server;
29+
- starting the server on boot;
30+
- installing the `vscode-server-controller` extension;
31+
- opening a specific file through that controller extension.
32+
33+
The generic open-in-editor feature remains available. For the new integration,
34+
configure only `enabled`, `bin`, `cwd`, `serverPort`, `host`, `args`, `env`,
35+
`cookieSuffix`, or `startTimeout` under `devtools.codeServer`.
36+
637
## `startSubprocess()` API Changes
738

839
The subprocess system has been migrated from `execa` to `tinyexec`.

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"@playwright/test": "catalog:cli",
3939
"@types/markdown-it": "catalog:types",
4040
"@types/node": "catalog:types",
41-
"@types/which": "catalog:types",
4241
"@types/ws": "catalog:types",
4342
"@unocss/eslint-config": "catalog:buildtools",
4443
"@vitejs/devtools-kit": "catalog:types",

‎packages/devtools-kit/src/_types/integrations.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,3 @@ export interface ComponentWithRelationships {
232232
dependencies?: string[]
233233
dependents?: string[]
234234
}
235-
236-
exportinterfaceCodeServerOptions{
237-
codeBinary: string
238-
launchArg: string
239-
licenseTermsArg: string
240-
connectionTokenArg: string
241-
}

‎packages/devtools-kit/src/_types/options.ts‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Import } from 'unimport'
22
importtype{ModuleCustomTab}from'./custom-tabs'
33
importtype{ServerRouteInfo,ServerRouteInput,ServerTaskInfo}from'./integrations'
44

5+
/** @deprecated Part of the removed `vscode` integration. */
56
exporttypeCodeServerType='ms-code-cli'|'ms-code-server'|'coder-code-server'
67

78
exportinterfaceModuleOptions{
@@ -19,8 +20,13 @@ export interface ModuleOptions {
1920
*/
2021
customTabs?: ModuleCustomTab[]
2122

23+
/** Code Server integration options. */
24+
codeServer?: CodeServerIntegrationOptions
25+
2226
/**
23-
* VS Code Server integration options.
27+
* Legacy VS Code Server integration options.
28+
*
29+
* @deprecated Use `codeServer`. Legacy modes are no longer supported.
2430
*/
2531
vscode?: VSCodeIntegrationOptions
2632

@@ -119,6 +125,40 @@ export interface ModuleOptions {
119125
telemetry?: boolean
120126
}
121127

128+
exportinterfaceCodeServerIntegrationOptions{
129+
/**
130+
* Enable the Code Server integration.
131+
*
132+
* @default true
133+
*/
134+
enabled?: boolean
135+
136+
/** Path or command name for Coder's `code-server` binary. */
137+
bin?: string
138+
139+
/** Workspace opened by Code Server. Defaults to the Nuxt root directory. */
140+
cwd?: string
141+
142+
/** Port for the Code Server process. Defaults to the plugin's free-port behavior. */
143+
serverPort?: number
144+
145+
/** Host for the Code Server process. Defaults to the plugin's loopback host. */
146+
host?: string
147+
148+
/** Additional safe arguments passed to `code-server`. */
149+
args?: string[]
150+
151+
/** Additional safe environment variables passed to `code-server`. */
152+
env?: Record<string,string>
153+
154+
/** Suffix used to isolate the authenticated Code Server session cookie. */
155+
cookieSuffix?: string
156+
157+
/** Milliseconds to wait for Code Server to become ready. */
158+
startTimeout?: number
159+
}
160+
161+
/** @deprecated Use {@link CodeServerIntegrationOptions}. */
122162
exportinterfaceVSCodeIntegrationOptions{
123163
/**
124164
* Enable VS Code Server integration
@@ -171,6 +211,7 @@ export interface VSCodeIntegrationOptions {
171211
host?: string
172212
}
173213

214+
/** @deprecated Tunnels are not supported by the Code Server integration. */
174215
exportinterfaceVSCodeTunnelOptions{
175216
/**
176217
* the machine name for port forwarding service

‎packages/devtools-kit/src/diagnostics.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ export const diagnosticCodes = {
6969
why: (p: DeprecationParams)=>`\`${p.api}\` is deprecated.`,
7070
fix: (p: DeprecationParams)=>`Use \`${p.replacement}\` instead.`,
7171
},
72-
// NDT_DEP_0008 is reserved for the removed `vscode` module option.
72+
/** Removed `vscode` module option → `codeServer`. */
73+
NDT_DEP_0008: {
74+
why: (p: DeprecationParams)=>`\`${p.api}\` is deprecated and its legacy modes are no longer supported.`,
75+
fix: (p: DeprecationParams)=>`Use \`${p.replacement}\` instead. The legacy value is ignored rather than partially translated.`,
76+
},
7377
/** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
7478
NDT_DEP_0009: {
7579
why: (p: DeprecationParams)=>`\`${p.api}\` is deprecated.`,

‎packages/devtools-kit/test/diagnostics.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe('diagnosticCodes', () => {
2929
'NDT_DEP_0005',
3030
'NDT_DEP_0006',
3131
'NDT_DEP_0007',
32+
'NDT_DEP_0008',
3233
'NDT_DEP_0009',
3334
])
3435
})

‎packages/devtools/client/pages/modules/open-graph.vue‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
importtype { NormalizedHeadTag } from'~/../src/types/ui-state'
33
import { computedAsync, until } from'@vueuse/core'
4+
import { resolveTags } from'unhead/utils'
45
import { computed, nextTick, ref } from'vue'
56
import { definePageMeta } from'#imports'
67
import { useClient, useClientHead, useClientRoute, useClientRouter } from'~/composables/client'
@@ -25,7 +26,7 @@ const head = useClientHead()
2526
const headTags =computedAsync(async () => {
2627
// eslint-disable-next-line ts/no-unused-expressions
2728
counter.value// for force refresh
28-
const tags =awaithead.value?.resolveTags()
29+
const tags =head.value?resolveTags(head.value) : []
2930
returntags.map((tag):NormalizedHeadTag=> {
3031
const props =tag.props|| {}
3132
if (tag.tag==='htmlAttrs'&&props.lang) {

0 commit comments

Comments
 (0)