Skip to content

Commit 063b27e

Browse files
committed
statuses updates
1 parent c31cb7c commit 063b27e

File tree

4 files changed

+75
-41
lines changed

4 files changed

+75
-41
lines changed

src/commands.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -407,21 +407,22 @@ export class Commands {
407407
}
408408
}
409409

410-
public async openAISession(): Promise<void> {
411-
// Then launch an integrated terminal with screen session
412-
const terminal = vscode.window.createTerminal({
413-
name: "Claude Code Session",
414-
location: vscode.TerminalLocation.Panel
415-
})
410+
public async openAppStatus(app: {
411+
name?: string
412+
status?: string
413+
url?: string
414+
agent_name?: string
415+
}): Promise<void> {
416+
// Check if app has a URL to open
417+
if (app.url) {
418+
await vscode.env.openExternal(vscode.Uri.parse(app.url))
419+
return
420+
}
416421

417-
// Show the terminal and run the screen command
418-
terminal.show(true)
419-
420-
// Hide sidebar and maximize terminal panel
421-
// await vscode.commands.executeCommand("workbench.action.toggleSidebarVisibility")
422-
await vscode.commands.executeCommand("workbench.action.toggleMaximizedPanel")
423-
424-
terminal.sendText("screen -xRR claude-code")
422+
// If no URL, show information about the app status
423+
vscode.window.showInformationMessage(`${app.name || "Application"}: ${app.status || "Running"}`, {
424+
detail: `Agent: ${app.agent_name || "Unknown"}`,
425+
})
425426
}
426427

427428
/**

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
124124
vscode.commands.registerCommand("coder.logout", commands.logout.bind(commands))
125125
vscode.commands.registerCommand("coder.open", commands.open.bind(commands))
126126
vscode.commands.registerCommand("coder.openFromSidebar", commands.openFromSidebar.bind(commands))
127-
vscode.commands.registerCommand("coder.openAITask", commands.openAISession.bind(commands))
127+
vscode.commands.registerCommand("coder.openAppStatus", commands.openAppStatus.bind(commands))
128128
vscode.commands.registerCommand("coder.workspace.update", commands.updateWorkspace.bind(commands))
129129
vscode.commands.registerCommand("coder.createWorkspace", commands.createWorkspace.bind(commands))
130130
vscode.commands.registerCommand("coder.navigateToWorkspace", commands.navigateToWorkspace.bind(commands))

src/workspacesProvider.ts

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Api } from "coder/site/src/api/api"
2-
import { Workspace, WorkspaceAgent, WorkspaceAgentTask } from "coder/site/src/api/typesGenerated"
2+
import { Workspace, WorkspaceAgent } from "coder/site/src/api/typesGenerated"
33
import { EventSource } from "eventsource"
44
import * as path from "path"
55
import * as vscode from "vscode"
@@ -155,14 +155,26 @@ export class WorkspaceProvider implements vscode.TreeDataProvider<vscode.TreeIte
155155
showMetadata,
156156
)
157157

158-
// Fetch AI tasks for the workspace
158+
// Get app status from the workspace agents
159159
try {
160-
// Create a dummy emitter for logs
161-
const _emitter = new vscode.EventEmitter<string>()
160+
const agents = extractAgents(workspace)
161+
agents.forEach((agent) => {
162+
// Check if agent has apps property with status reporting
163+
if (agent.apps && Array.isArray(agent.apps)) {
164+
workspaceTreeItem.appStatus = agent.apps.map((app) => ({
165+
name: app.display_name || app.name || "App",
166+
status: app.status || "Running",
167+
icon: app.icon || "$(pulse)",
168+
url: app.url,
169+
agent_id: agent.id,
170+
agent_name: agent.name,
171+
}))
172+
}
173+
})
162174
} catch (error) {
163-
// Log the error but continue - we don't want to fail the whole tree if AI tasks fail
175+
// Log the error but continue - we don't want to fail the whole tree if app status fails
164176
this.storage.writeToCoderOutputChannel(
165-
`Failed to fetch AI tasks for workspace ${workspace.name}: ${errToStr(error, "unknown error")}`,
177+
`Failed to get app status for workspace ${workspace.name}: ${errToStr(error, "unknown error")}`,
166178
)
167179
}
168180

@@ -239,13 +251,24 @@ export class WorkspaceProvider implements vscode.TreeDataProvider<vscode.TreeIte
239251

240252
const items: vscode.TreeItem[] = []
241253

242-
// Add AI tasks section with collapsible header
243-
if (element.agent.tasks.length > 0) {
244-
const aiTasksSection = new SectionTreeItem(
245-
"AI Tasks",
246-
element.agent.tasks.map((task) => new AITaskTreeItem(task)),
254+
// Add app status section with collapsible header
255+
if (element.agent.apps && element.agent.apps.length > 0) {
256+
let needsAttention = []
257+
for (const app of element.agent.apps) {
258+
if (app.statuses && app.statuses.length > 0) {
259+
for (const status of app.statuses) {
260+
if (status.needs_user_attention) {
261+
needsAttention.push(new AppStatusTreeItem(status))
262+
}
263+
}
264+
}
265+
}
266+
267+
const appStatusSection = new SectionTreeItem(
268+
"Applications in need of attention",
269+
needsAttention,
247270
)
248-
items.push(aiTasksSection)
271+
items.push(appStatusSection)
249272
}
250273

251274
const savedMetadata = watcher?.metadata || []
@@ -346,18 +369,27 @@ class AgentMetadataTreeItem extends vscode.TreeItem {
346369
}
347370
}
348371

349-
class AITaskTreeItem extends vscode.TreeItem {
350-
constructor(public readonly task: WorkspaceAgentTask) {
351-
// Add a hand raise emoji (✋) to indicate tasks awaiting user input
352-
super(task.icon, vscode.TreeItemCollapsibleState.None)
353-
this.description = task.summary
354-
this.contextValue = "coderAITask"
372+
class AppStatusTreeItem extends vscode.TreeItem {
373+
constructor(
374+
public readonly app: {
375+
name?: string
376+
display_name?: string
377+
status?: string
378+
icon?: string
379+
url?: string
380+
agent_id?: string
381+
agent_name?: string
382+
},
383+
) {
384+
super(app.icon || "$(pulse)", vscode.TreeItemCollapsibleState.None)
385+
this.description = app.status || "Running"
386+
this.contextValue = "coderAppStatus"
355387

356-
// Add command to handle clicking on the task
388+
// Add command to handle clicking on the app
357389
this.command = {
358-
command: "coder.openAITask",
359-
title: "Open AI Task",
360-
arguments: [task],
390+
command: "coder.openAppStatus",
391+
title: "Open App Status",
392+
arguments: [app],
361393
}
362394
}
363395
}
@@ -409,14 +441,15 @@ class AgentTreeItem extends OpenableTreeItem {
409441
"coderAgent",
410442
)
411443

412-
if (agent.task_waiting_for_user_input) {
413-
this.label = "🙋 " + this.label
444+
if (agent.apps && agent.apps.length > 0) {
445+
// Add an icon to indicate this agent has running apps
446+
this.label = "🖐️ " + this.label
414447
}
415448
}
416449
}
417450

418451
export class WorkspaceTreeItem extends OpenableTreeItem {
419-
public aiTasks: { waiting: boolean; tasks: WorkspaceAgentTask[] }[] = []
452+
public appStatus: { name: string; status: string; icon?: string }[] = []
420453

421454
constructor(
422455
public readonly workspace: Workspace,

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ [email protected]:
15941594

15951595
"coder@https://github.com/coder/coder#main":
15961596
version "0.0.0"
1597-
resolved "https://github.com/coder/coder#8ea956fc115c221f198dd2c54538c93fc03c91cf"
1597+
resolved "https://github.com/coder/coder#3a243c111b9abb5c38328169ff70064025bbe2fe"
15981598

15991599
collapse-white-space@^1.0.2:
16001600
version "1.0.6"

0 commit comments

Comments
 (0)