@@ -39,11 +39,7 @@ export const TerminalPage: React.FC<{
39
39
// a round-trip, and must be a UUIDv4.
40
40
const [ reconnectionToken ] = React . useState < string > ( ( ) => {
41
41
const search = new URLSearchParams ( location . search )
42
- let reconnect = search . get ( "reconnect" )
43
- if ( reconnect === null ) {
44
- reconnect = crypto . randomUUID ( )
45
- }
46
- return reconnect
42
+ return search . get ( "reconnect" ) ?? crypto . randomUUID ( )
47
43
} )
48
44
const [ terminalState , sendEvent ] = useMachine ( terminalMachine , {
49
45
actions : {
@@ -59,6 +55,8 @@ export const TerminalPage: React.FC<{
59
55
} ,
60
56
} )
61
57
const isConnected = terminalState . matches ( "connected" )
58
+ const { organizationsError, workspaceError, workspaceAgentError, workspaceAgent, websocketError } =
59
+ terminalState . context
62
60
63
61
// Create the terminal!
64
62
React . useEffect ( ( ) => {
@@ -150,17 +148,17 @@ export const TerminalPage: React.FC<{
150
148
terminal . options = {
151
149
disableStdin : true ,
152
150
}
153
- if ( terminalState . context . organizationsError instanceof Error ) {
154
- terminal . writeln ( Language . organizationsErrorMessagePrefix + terminalState . context . organizationsError . message )
151
+ if ( organizationsError instanceof Error ) {
152
+ terminal . writeln ( Language . organizationsErrorMessagePrefix + organizationsError . message )
155
153
}
156
- if ( terminalState . context . workspaceError instanceof Error ) {
157
- terminal . writeln ( Language . workspaceErrorMessagePrefix + terminalState . context . workspaceError . message )
154
+ if ( workspaceError instanceof Error ) {
155
+ terminal . writeln ( Language . workspaceErrorMessagePrefix + workspaceError . message )
158
156
}
159
- if ( terminalState . context . workspaceAgentError instanceof Error ) {
160
- terminal . writeln ( Language . workspaceAgentErrorMessagePrefix + terminalState . context . workspaceAgentError . message )
157
+ if ( workspaceAgentError instanceof Error ) {
158
+ terminal . writeln ( Language . workspaceAgentErrorMessagePrefix + workspaceAgentError . message )
161
159
}
162
- if ( terminalState . context . websocketError instanceof Error ) {
163
- terminal . writeln ( Language . websocketErrorMessagePrefix + terminalState . context . websocketError . message )
160
+ if ( websocketError instanceof Error ) {
161
+ terminal . writeln ( Language . websocketErrorMessagePrefix + websocketError . message )
164
162
}
165
163
return
166
164
}
@@ -174,6 +172,7 @@ export const TerminalPage: React.FC<{
174
172
terminal . focus ( )
175
173
terminal . options = {
176
174
disableStdin : false ,
175
+ windowsMode : workspaceAgent ?. operating_system === "windows" ,
177
176
}
178
177
179
178
// Update the terminal size post-fit.
@@ -185,10 +184,11 @@ export const TerminalPage: React.FC<{
185
184
} ,
186
185
} )
187
186
} , [
188
- terminalState . context . workspaceError ,
189
- terminalState . context . organizationsError ,
190
- terminalState . context . workspaceAgentError ,
191
- terminalState . context . websocketError ,
187
+ workspaceError ,
188
+ organizationsError ,
189
+ workspaceAgentError ,
190
+ websocketError ,
191
+ workspaceAgent ,
192
192
terminal ,
193
193
fitAddon ,
194
194
isConnected ,
0 commit comments