Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0fd3e02

Browse files
committed
Active Windows mode on Windows
1 parent3e1a0a4 commit0fd3e02

File tree

5 files changed

+30
-35
lines changed

5 files changed

+30
-35
lines changed

‎agent/agent.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, rawID string, conn ne
484484
}
485485
a.reconnectingPTYs.Store(id,rpty)
486486
gofunc() {
487+
// CommandContext isn't respected for Windows PTYs right now,
488+
// so we need to manually track the lifecycle.
487489
// When the context has been completed either:
488490
// 1. The timeout completed.
489491
// 2. The parent context was canceled.

‎site/src/api/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export interface WorkspaceResource {
8787
exportinterfaceWorkspaceAgent{
8888
id:string
8989
name:string
90+
operating_system:string
9091
}
9192

9293
exportinterfaceAPIKeyResponse{

‎site/src/pages/TerminalPage/TerminalPage.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ export const TerminalPage: React.FC<{
3939
// a round-trip, and must be a UUIDv4.
4040
const[reconnectionToken]=React.useState<string>(()=>{
4141
constsearch=newURLSearchParams(location.search)
42-
letreconnect=search.get("reconnect")
43-
if(reconnect===null){
44-
reconnect=crypto.randomUUID()
45-
}
46-
returnreconnect
42+
returnsearch.get("reconnect")??crypto.randomUUID()
4743
})
4844
const[terminalState,sendEvent]=useMachine(terminalMachine,{
4945
actions:{
@@ -59,6 +55,8 @@ export const TerminalPage: React.FC<{
5955
},
6056
})
6157
constisConnected=terminalState.matches("connected")
58+
const{ organizationsError, workspaceError, workspaceAgentError, workspaceAgent, websocketError}=
59+
terminalState.context
6260

6361
// Create the terminal!
6462
React.useEffect(()=>{
@@ -150,17 +148,17 @@ export const TerminalPage: React.FC<{
150148
terminal.options={
151149
disableStdin:true,
152150
}
153-
if(terminalState.context.organizationsErrorinstanceofError){
154-
terminal.writeln(Language.organizationsErrorMessagePrefix+terminalState.context.organizationsError.message)
151+
if(organizationsErrorinstanceofError){
152+
terminal.writeln(Language.organizationsErrorMessagePrefix+organizationsError.message)
155153
}
156-
if(terminalState.context.workspaceErrorinstanceofError){
157-
terminal.writeln(Language.workspaceErrorMessagePrefix+terminalState.context.workspaceError.message)
154+
if(workspaceErrorinstanceofError){
155+
terminal.writeln(Language.workspaceErrorMessagePrefix+workspaceError.message)
158156
}
159-
if(terminalState.context.workspaceAgentErrorinstanceofError){
160-
terminal.writeln(Language.workspaceAgentErrorMessagePrefix+terminalState.context.workspaceAgentError.message)
157+
if(workspaceAgentErrorinstanceofError){
158+
terminal.writeln(Language.workspaceAgentErrorMessagePrefix+workspaceAgentError.message)
161159
}
162-
if(terminalState.context.websocketErrorinstanceofError){
163-
terminal.writeln(Language.websocketErrorMessagePrefix+terminalState.context.websocketError.message)
160+
if(websocketErrorinstanceofError){
161+
terminal.writeln(Language.websocketErrorMessagePrefix+websocketError.message)
164162
}
165163
return
166164
}
@@ -174,6 +172,7 @@ export const TerminalPage: React.FC<{
174172
terminal.focus()
175173
terminal.options={
176174
disableStdin:false,
175+
windowsMode:workspaceAgent?.operating_system==="windows",
177176
}
178177

179178
// Update the terminal size post-fit.
@@ -185,10 +184,11 @@ export const TerminalPage: React.FC<{
185184
},
186185
})
187186
},[
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,
192192
terminal,
193193
fitAddon,
194194
isConnected,

‎site/src/testHelpers/entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export const MockWorkspace: Workspace = {
102102
exportconstMockWorkspaceAgent:WorkspaceAgent={
103103
id:"test-workspace-agent",
104104
name:"a-workspace-agent",
105+
operating_system:"linux",
105106
}
106107

107108
exportconstMockWorkspaceResource:WorkspaceResource={

‎site/src/xServices/terminal/terminalXService.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,20 @@ export const terminalMachine =
167167
constagentName=workspaceNameParts[1]
168168

169169
constresources=awaitAPI.getWorkspaceResources(context.workspace.latest_build.id)
170-
for(leti=0;i<resources.length;i++){
171-
constresource=resources[i]
172-
if(!resource.agents){
173-
continue
174-
}
175-
if(resource.agents.length<=0){
176-
continue
170+
171+
constagent=resources.map((resource)=>{
172+
if(!resource.agents||resource.agents.length<1){
173+
return
177174
}
178175
if(!agentName){
179176
returnresource.agents[0]
180177
}
181-
for(leta=0;a<resource.agents.length;a++){
182-
constagent=resource.agents[a]
183-
if(agent.name!==agentName){
184-
continue
185-
}
186-
returnagent
187-
}
178+
returnresource.agents.find((agent)=>agent.name===agentName)
179+
}).filter(a=>a)[0]
180+
if(!agent){
181+
thrownewError("no agent found with id")
188182
}
189-
thrownewError("noagent found with id")
183+
returnagent
190184
},
191185
connect:(context:TerminalContext)=>(send)=>{
192186
returnnewPromise<WebSocket>((resolve,reject)=>{
@@ -275,9 +269,6 @@ export const terminalMachine =
275269
}
276270
context.websocket.send(newTextEncoder().encode(JSON.stringify(event.request)))
277271
},
278-
readMessage:()=>{
279-
// Override this with the terminal writer!
280-
},
281272
disconnect:(context:TerminalContext)=>{
282273
// Code 1000 is a successful exit!
283274
context.websocket?.close(1000)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp