@@ -9,6 +9,10 @@ import { useSessionLayout } from "@/session/session-layout"
99import { createSessionOwnership } from "@/session/session-ownership"
1010import { useWorkspaceLocation } from "@/workspaces/location"
1111import { useData } from "@/runtime/server/current"
12+ import { useServerSDK } from "@/runtime/server/client"
13+ import { formatServerError } from "@/runtime/server/errors"
14+ import { showToast } from "@/shell/notifications/toast"
15+ import { toaster } from "@opencode/ui/toast"
1216
1317const withCategory = ( category : string ) => {
1418 return ( option : Omit < CommandOption , "category" > ) : CommandOption => ( {
@@ -26,12 +30,14 @@ export const useComposerCommands = (input: { model?: ModelSelection } = {}) => {
2630 const workspace = useWorkspaceLocation ( )
2731 const { sessionKey, params } = useSessionLayout ( )
2832 const data = useData ( )
33+ const sdk = useServerSDK ( )
2934 const sessionOwnership = createSessionOwnership ( sessionKey )
3035 const model = input . model ?? local . model
3136 const modelCommand = withCategory ( language . t ( "command.category.model" ) )
3237 const agentCommand = withCategory ( language . t ( "command.category.agent" ) )
3338 const providerCommand = withCategory ( language . t ( "command.category.provider" ) )
3439 const viewCommand = withCategory ( language . t ( "command.category.view" ) )
40+ const serverCommand = withCategory ( language . t ( "command.category.server" ) )
3541
3642 // Mirrors the TUI's `/connect`, which the Console's setup steps tell people to run.
3743 const connectProvider = async ( ) => {
@@ -40,6 +46,28 @@ export const useComposerCommands = (input: { model?: ModelSelection } = {}) => {
4046 void dialog . show ( ( ) => < DialogConnectProvider directory = { workspace ( ) . directory } selection = { model } /> )
4147 }
4248
49+ // Mirrors the TUI's `/reload`. The server rebuilds every loaded location and announces the changed agents,
50+ // commands, models and skills, so the data layer refreshes them without restarting the app.
51+ const reloadConfig = ( ) => {
52+ const pending = showToast ( {
53+ variant : "loading" ,
54+ title : language . t ( "command.config.reload.pending" ) ,
55+ persistent : true ,
56+ } )
57+
58+ void sdk . api . location
59+ . reload ( )
60+ . then ( ( ) => showToast ( { variant : "success" , title : language . t ( "command.config.reload.done" ) } ) )
61+ . catch ( ( error ) =>
62+ showToast ( {
63+ variant : "error" ,
64+ title : language . t ( "command.config.reload.failed" ) ,
65+ description : formatServerError ( error , language . t ) ,
66+ } ) ,
67+ )
68+ . finally ( ( ) => toaster . dismiss ( pending ) )
69+ }
70+
4371 const chooseModel = ( ) => {
4472 const Picker = settings . general . newModelPicker ( ) ? DialogSelectModelNext : DialogSelectModel
4573 sessionOwnership . capture ( ) . run ( ( ) => {
@@ -50,10 +78,12 @@ export const useComposerCommands = (input: { model?: ModelSelection } = {}) => {
5078 const viewUsage = async ( ) => {
5179 const { DialogUsage } = await import ( "@/usage/dialog" )
5280 const current = model . current ( )
81+
5382 // Console refuses with 402 only when the workspace can't pay, which the dialog explains.
5483 const last = params . id
5584 ? data . session . message . list ( params . id ) ?. findLast ( ( message ) => message . type === "assistant" )
5685 : undefined
86+
5787 void dialog . show ( ( ) => (
5888 < DialogUsage
5989 location = { workspace ( ) . ref }
@@ -93,6 +123,13 @@ export const useComposerCommands = (input: { model?: ModelSelection } = {}) => {
93123 slash : "connect" ,
94124 onSelect : connectProvider ,
95125 } ) ,
126+ serverCommand ( {
127+ id : "config.reload" ,
128+ title : language . t ( "command.config.reload" ) ,
129+ description : language . t ( "command.config.reload.description" ) ,
130+ slash : "reload" ,
131+ onSelect : reloadConfig ,
132+ } ) ,
96133 agentCommand ( {
97134 id : "agent.cycle" ,
98135 title : language . t ( "command.agent.cycle" ) ,
0 commit comments