Skip to content

Commit 37a3af8

Browse files
authored
Add WebSocket Terminal support (#1150)
1 parent c05c22e commit 37a3af8

File tree

6 files changed

+749
-2
lines changed

6 files changed

+749
-2
lines changed

docs/RunDebug.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,44 @@ The InterSystems ObjectScript Extension provides a [Webview](https://code.visual
121121

122122
## Troubleshooting Debugger Issues
123123

124-
If you are experiencing issues using the debugger, please follow these steps before opening an issue on GitHub:
124+
If you are experiencing issues using the debugger, please follow these steps before opening an issue on GitHub. Note that the trace global may contain confidential information, so you should review the contents and mask/remove anything that you want to keep private.
125125

126126
1. Open a terminal on your server and `zn` to the namespace containing the class or routine you are debugging.
127127
2. Run the command `Kill ^IRIS.Temp.Atelier("debug")`, then `Set ^IRIS.Temp.Atelier("debug") = 1` to turn on the Atelier API debug logging feature. If you are on Caché or Ensemble, the global is `^CacheTemp.ISC.Atelier("debug")`.
128128
3. In VS Code, start a debugging session using the configuration that produces the error.
129129
4. Once the error appears, copy the contents of the `^IRIS.Temp.Atelier("debug")` global and add it to your GitHub issue.
130130
5. After you capture the log, run the command `Kill ^IRIS.Temp.Atelier("debug")`, then `Set ^IRIS.Temp.Atelier("debug") = 0` to turn logging back off again.
131+
132+
{: #terminal}
133+
## Using the WebSocket Terminal
134+
135+
The InterSystems ObjectScript Extension provides support for a WebSocket-based command-line interface for executing ObjectScript commands on a connected server. The server can be on the same system as VS Code, or a remote system. This feature is only supported when connecting to InterSystems IRIS version 2023.2 or later.
136+
137+
The WebSocket terminal supports the following features:
138+
139+
- VS Code's [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) feature so your command history and output will be captured by VS Code and can be accessed by its UI.
140+
- Multi-line editing. An additional editable line will be added when the user presses `Enter` and there are unclosed `{` or `(` in the command input.
141+
- Syntax coloring for command input. (Toggleable using the `objectscript.webSocketTerminal.syntaxColoring` setting)
142+
- Syntax checking for entered command input with detailed error messages reported along with the standard `<SYNTAX>` error.
143+
- Many features of the [standard terminal](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GTER_intro), including:
144+
- The Read command
145+
- Interrupts (`Ctrl-C`)
146+
- Namespace switches
147+
- [Custom terminal prompts](https://irisdocs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic.cls?LIBRARY=%25SYS&CLASSNAME=%25SYSTEM.Process#TerminalPrompt) (except code 7)
148+
- Shells like SQL (`Do $SYSTEM.SQL.Shell()`) and Python (`Do $SYSTEM.Python.Shell()`)
149+
150+
The WebSocket terminal does not support [command-line debugging](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_debug) since the InterSystems ObjectScript Extension contains an interactive debugger. Users are also discouraged from using [routine editing commands](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_ZCOMMANDS) since VS Code with the InterSystems ObjectScript Extension Pack provides an excellent ObjectScript editing experience.
151+
152+
Note that the terminal process is started using the JOB command, so if you have a [`^%ZSTART` routine](https://docs.intersystems.com/iris20223/csp/docbook/Doc.View.cls?KEY=GSTU_customize_startstop) enabled the `JOB` subroutine will be called at the start of the process, not `LOGIN` like the standard terminal. Also, the [`ZWELCOME` routine](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GTER_intro#GTER_zwelcome) will not be run before the first command prompt is shown.
153+
154+
The WebSocket terminal can be opened from [the command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) using the `ObjectScript: Launch WebSocket Terminal` command. The WebSocket terminal connection will be established using the current server connection. A WebSocket terminal connection can also be opened from the [Terminal Profiles menu](https://code.visualstudio.com/docs/terminal/basics#_terminal-shells).
155+
156+
## Troubleshooting WebSocket Terminal Issues
157+
158+
If you are experiencing issues using the WebSocket terminal, please follow these steps before opening an issue on GitHub. Note that the trace global may contain confidential information, so you should review the contents and mask/remove anything that you want to keep private.
159+
160+
1. Open a standard terminal on your server and `zn` to the namespace containing the class or routine you are debugging.
161+
2. Run the command `Kill ^IRIS.Temp.Atelier("terminal")`, then `Set ^IRIS.Temp.Atelier("terminal") = 1` to turn on the Atelier API terminal logging feature.
162+
3. In VS Code, launch the WebSocket terminal and run the commands that produce the error.
163+
4. Once the error appears, copy the contents of the `^IRIS.Temp.Atelier("terminal")` global and add it to your GitHub issue.
164+
5. After you capture the log, run the command `Kill ^IRIS.Temp.Atelier("terminal")`, then `Set ^IRIS.Temp.Atelier("terminal") = 0` to turn logging back off again.

docs/SettingsReference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The extensions in the InterSystems ObjectScript Extension Pack provide many sett
8282
| `"objectscript.studioActionDebugOutput"` | Log in JSON format the action that VS Code should perform as requested by the server. | `boolean` | `false` | Actions will be logged to the `ObjectScript` Output channel. |
8383
| `"objectscript.suppressCompileErrorMessages"` | Suppress popup messages about errors during compile, but still focus on Output view. | `boolean` | `false` | |
8484
| `"objectscript.suppressCompileMessages"` | Suppress popup messages about successful compile. | `boolean` | `true` | |
85+
| `"objectscript.webSocketTerminal.syntaxColoring"` | Enable syntax coloring for command input in the InterSystems WebSocket Terminal. | `boolean` | `true` | |
8586

8687
{: #intersystems-servermanager}
8788
## InterSystems Server Manager

package.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
"onCommand:vscode-objectscript.newFile.dtl",
9090
"onCommand:vscode-objectscript.modifyWsFolder",
9191
"onCommand:vscode-objectscript.openErrorLocation",
92+
"onCommand:vscode-objectscript.launchWebSocketTerminal",
93+
"onTerminalProfile:vscode-objectscript.webSocketTerminal",
9294
"onLanguage:objectscript",
9395
"onLanguage:objectscript-int",
9496
"onLanguage:objectscript-class",
@@ -343,6 +345,10 @@
343345
{
344346
"command": "vscode-objectscript.openErrorLocation",
345347
"when": "vscode-objectscript.connectActive && workspaceFolderCount != 0"
348+
},
349+
{
350+
"command": "vscode-objectscript.launchWebSocketTerminal",
351+
"when": "vscode-objectscript.connectActive"
346352
}
347353
],
348354
"view/title": [
@@ -1119,6 +1125,11 @@
11191125
"category": "ObjectScript",
11201126
"command": "vscode-objectscript.openErrorLocation",
11211127
"title": "Open Error Location..."
1128+
},
1129+
{
1130+
"category": "ObjectScript",
1131+
"command": "vscode-objectscript.launchWebSocketTerminal",
1132+
"title": "Launch WebSocket Terminal"
11221133
}
11231134
],
11241135
"keybindings": [
@@ -1478,6 +1489,11 @@
14781489
"type": "boolean",
14791490
"default": true
14801491
},
1492+
"objectscript.webSocketTerminal.syntaxColoring": {
1493+
"description": "Enable syntax coloring for command input in the InterSystems WebSocket Terminal.",
1494+
"type": "boolean",
1495+
"default": true
1496+
},
14811497
"objectscript.showProposedApiPrompt": {
14821498
"description": "Controls whether a prompt to enable VS Code proposed APIs is shown when a server-side workspace folder is opened.",
14831499
"type": "boolean",
@@ -1624,7 +1640,16 @@
16241640
],
16251641
"priority": "option"
16261642
}
1627-
]
1643+
],
1644+
"terminal": {
1645+
"profiles": [
1646+
{
1647+
"id": "vscode-objectscript.webSocketTerminal",
1648+
"title": "InterSystems WebSocket Terminal",
1649+
"icon": "./images/fileIcon.svg"
1650+
}
1651+
]
1652+
}
16281653
},
16291654
"scripts": {
16301655
"vscode:prepublish": "webpack --mode production",

src/api/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ export class AtelierAPI {
150150
return `${proto}://${host}:${port}${pathPrefix}/api/atelier/v${apiVersion}/%25SYS/debug`;
151151
}
152152

153+
public terminalUrl(): string {
154+
const { host, https, port, apiVersion, pathPrefix } = this.config;
155+
return apiVersion >= 7
156+
? `${https ? "wss" : "ws"}://${host}:${port}${pathPrefix}/api/atelier/v${apiVersion}/%25SYS/terminal`
157+
: "";
158+
}
159+
153160
public async updateCookies(newCookies: string[]): Promise<void> {
154161
const cookies = this.cache.get("cookies", []);
155162
newCookies.forEach((cookie) => {

0 commit comments

Comments
 (0)