File tree Expand file tree Collapse file tree
src/main/kotlin/com/ashotn/opencode/relay/actions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com.ashotn.opencode.relay.actions
22
33import com.ashotn.opencode.relay.OpenCodePlugin
4+ import com.ashotn.opencode.relay.ServerState
45import com.ashotn.opencode.relay.settings.OpenCodeSettings
56import com.ashotn.opencode.relay.util.applyStrings
67import com.intellij.icons.AllIcons
@@ -17,9 +18,9 @@ class McpServersAction(private val project: Project) : AnAction() {
1718 override fun getActionUpdateThread (): ActionUpdateThread = ActionUpdateThread .BGT
1819
1920 override fun update (e : AnActionEvent ) {
20- val running = OpenCodePlugin .getInstance(project).isRunning
21+ val ready = OpenCodePlugin .getInstance(project).serverState == ServerState . READY
2122 e.presentation.icon = AllIcons .Nodes .Plugin
22- e.applyStrings(ActionStrings .MCP_SERVERS , running )
23+ e.applyStrings(ActionStrings .MCP_SERVERS , ready )
2324 }
2425
2526 override fun actionPerformed (e : AnActionEvent ) {
Original file line number Diff line number Diff line change 11package com.ashotn.opencode.relay.actions
22
33import com.ashotn.opencode.relay.OpenCodePlugin
4+ import com.ashotn.opencode.relay.ServerState
45import com.ashotn.opencode.relay.toolwindow.OpenCodeToolWindowPanel
56import com.ashotn.opencode.relay.tui.OpenCodeTuiClient
67import com.ashotn.opencode.relay.util.applyStrings
@@ -31,8 +32,8 @@ class NewSessionAction(private val project: Project? = null) : AnAction() {
3132 e.applyStrings(ActionStrings .NEW_SESSION , false )
3233 return
3334 }
34- val running = OpenCodePlugin .getInstance(proj).isRunning
35- e.applyStrings(ActionStrings .NEW_SESSION , running )
35+ val ready = OpenCodePlugin .getInstance(proj).serverState == ServerState . READY
36+ e.applyStrings(ActionStrings .NEW_SESSION , ready )
3637 }
3738
3839 override fun actionPerformed (e : AnActionEvent ) {
Original file line number Diff line number Diff line change 11package com.ashotn.opencode.relay.actions
22
33import com.ashotn.opencode.relay.OpenCodePlugin
4+ import com.ashotn.opencode.relay.ServerState
45import com.ashotn.opencode.relay.settings.OpenCodeSettings
56import com.ashotn.opencode.relay.util.applyStrings
67import com.ashotn.opencode.relay.util.serverUrl
@@ -17,9 +18,9 @@ class OpenBrowserAction(private val project: Project) : AnAction() {
1718 override fun getActionUpdateThread (): ActionUpdateThread = ActionUpdateThread .BGT
1819
1920 override fun update (e : AnActionEvent ) {
20- val running = OpenCodePlugin .getInstance(project).isRunning
21+ val ready = OpenCodePlugin .getInstance(project).serverState == ServerState . READY
2122 e.presentation.icon = AllIcons .Toolwindows .WebToolWindow
22- e.applyStrings(ActionStrings .OPEN_BROWSER , running )
23+ e.applyStrings(ActionStrings .OPEN_BROWSER , ready )
2324 }
2425
2526 override fun actionPerformed (e : AnActionEvent ) {
Original file line number Diff line number Diff line change 11package com.ashotn.opencode.relay.actions
22
33import com.ashotn.opencode.relay.OpenCodePlugin
4+ import com.ashotn.opencode.relay.ServerState
45import com.ashotn.opencode.relay.settings.OpenCodeSettings
56import com.ashotn.opencode.relay.util.applyStrings
67import com.ashotn.opencode.relay.util.showNotification
@@ -20,10 +21,10 @@ class OpenTerminalAction(private val project: Project) : AnAction() {
2021
2122 override fun update (e : AnActionEvent ) {
2223 val plugin = OpenCodePlugin .getInstance(project)
23- val running = plugin.isRunning
24+ val ready = plugin.serverState == ServerState . READY
2425 val hasExecutable = ! plugin.openCodeInfo?.path.isNullOrBlank()
2526 e.presentation.icon = AllIcons .Debugger .Console
26- e.applyStrings(ActionStrings .OPEN_TERMINAL , running && hasExecutable)
27+ e.applyStrings(ActionStrings .OPEN_TERMINAL , ready && hasExecutable)
2728 }
2829
2930 override fun actionPerformed (e : AnActionEvent ) {
Original file line number Diff line number Diff line change 11package com.ashotn.opencode.relay.actions
22
33import com.ashotn.opencode.relay.OpenCodePlugin
4+ import com.ashotn.opencode.relay.ServerState
45import com.ashotn.opencode.relay.tui.OpenCodeTuiClient
56import com.ashotn.opencode.relay.util.applyStrings
67import com.ashotn.opencode.relay.util.showNotification
@@ -30,11 +31,11 @@ class SendFileAction : AnAction() {
3031
3132 override fun update (e : AnActionEvent ) {
3233 val project = e.project
33- val running = project != null && OpenCodePlugin .getInstance(project).isRunning
34+ val ready = project != null && OpenCodePlugin .getInstance(project).serverState == ServerState . READY
3435 val hasFile = resolveFiles(e).isNotEmpty()
3536 e.presentation.isVisible = hasFile
3637 e.presentation.icon = AllIcons .FileTypes .Any_type
37- e.applyStrings(ActionStrings .SEND_FILE , running && hasFile)
38+ e.applyStrings(ActionStrings .SEND_FILE , ready && hasFile)
3839 }
3940
4041 override fun actionPerformed (e : AnActionEvent ) {
Original file line number Diff line number Diff line change 11package com.ashotn.opencode.relay.actions
22
33import com.ashotn.opencode.relay.OpenCodePlugin
4+ import com.ashotn.opencode.relay.ServerState
45import com.ashotn.opencode.relay.tui.OpenCodeTuiClient
56import com.ashotn.opencode.relay.util.applyStrings
67import com.ashotn.opencode.relay.util.showNotification
@@ -29,14 +30,14 @@ class SendFolderAction : AnAction() {
2930
3031 override fun update (e : AnActionEvent ) {
3132 val project = e.project
32- val running = project != null && OpenCodePlugin .getInstance(project).isRunning
33+ val ready = project != null && OpenCodePlugin .getInstance(project).serverState == ServerState . READY
3334 val folders = resolveFolders(e)
3435 // Only show this action when there is at least one directory selected and we are
3536 // NOT in an editor (editor sends files, not folders)
3637 val inEditor = e.getData(CommonDataKeys .EDITOR ) != null
3738 e.presentation.isVisible = ! inEditor && folders.isNotEmpty()
3839 e.presentation.icon = AllIcons .Nodes .Folder
39- e.applyStrings(ActionStrings .SEND_FOLDER , running && folders.isNotEmpty())
40+ e.applyStrings(ActionStrings .SEND_FOLDER , ready && folders.isNotEmpty())
4041 }
4142
4243 override fun actionPerformed (e : AnActionEvent ) {
Original file line number Diff line number Diff line change 11package com.ashotn.opencode.relay.actions
22
33import com.ashotn.opencode.relay.OpenCodePlugin
4+ import com.ashotn.opencode.relay.ServerState
45import com.ashotn.opencode.relay.tui.OpenCodeTuiClient
56import com.ashotn.opencode.relay.util.applyStrings
67import com.ashotn.opencode.relay.util.showNotification
@@ -32,12 +33,12 @@ class SendSelectionAction : AnAction() {
3233 override fun update (e : AnActionEvent ) {
3334 val project = e.project
3435 val editor = e.getData(CommonDataKeys .EDITOR )
35- val running = project != null && OpenCodePlugin .getInstance(project).isRunning
36+ val ready = project != null && OpenCodePlugin .getInstance(project).serverState == ServerState . READY
3637
3738 // Hide entirely when invoked outside an editor context (e.g. tool window, global shortcut)
3839 e.presentation.isVisible = editor != null
3940 e.presentation.icon = AllIcons .Actions .Upload
40- e.applyStrings(ActionStrings .SEND_SELECTION , running )
41+ e.applyStrings(ActionStrings .SEND_SELECTION , ready )
4142 }
4243
4344 override fun actionPerformed (e : AnActionEvent ) {
You can’t perform that action at this time.
0 commit comments