Skip to content

Commit 538a972

Browse files
Merge pull request anomalyco#420 from different-ai/feat/settings-server-reload
Add manual engine reload in settings
2 parents 29b70f8 + d736556 commit 538a972

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎packages/app/src/app/app.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,6 +3921,10 @@ export default function App() {
39213921
updateOpenworkServerSettings,
39223922
resetOpenworkServerSettings,
39233923
testOpenworkServerConnection,
3924+
canReloadWorkspace: canReloadWorkspace(),
3925+
reloadWorkspaceEngine,
3926+
reloadBusy: reloadBusy(),
3927+
reloadError: reloadError(),
39243928
activeWorkspaceDisplay: activeWorkspaceDisplay(),
39253929
workspaceSearch: workspaceStore.workspaceSearch(),
39263930
setWorkspaceSearch: workspaceStore.setWorkspaceSearch,

‎packages/app/src/app/pages/dashboard.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ export type DashboardViewProps = {
9393
updateOpenworkServerSettings: (next: OpenworkServerSettings) => void;
9494
resetOpenworkServerSettings: () => void;
9595
testOpenworkServerConnection: (next: OpenworkServerSettings) => Promise<boolean>;
96+
canReloadWorkspace: boolean;
97+
reloadWorkspaceEngine: () => Promise<void>;
98+
reloadBusy: boolean;
99+
reloadError: string | null;
96100
keybindItems: KeybindSetting[];
97101
onOverrideKeybind: (id: string, keybind: string | null) => void;
98102
onResetKeybind: (id: string) => void;
@@ -975,6 +979,11 @@ export default function DashboardView(props: DashboardViewProps) {
975979
openworkServerCapabilities={props.openworkServerCapabilities}
976980
openworkServerDiagnostics={props.openworkServerDiagnostics}
977981
openworkServerWorkspaceId={props.openworkServerWorkspaceId}
982+
clientConnected={props.clientConnected}
983+
canReloadWorkspace={props.canReloadWorkspace}
984+
reloadWorkspaceEngine={props.reloadWorkspaceEngine}
985+
reloadBusy={props.reloadBusy}
986+
reloadError={props.reloadError}
978987
openworkAuditEntries={props.openworkAuditEntries}
979988
openworkAuditStatus={props.openworkAuditStatus}
980989
openworkAuditError={props.openworkAuditError}

‎packages/app/src/app/pages/settings.tsx‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,18 @@ export type SettingsViewProps = {
5858
openworkServerCapabilities: OpenworkServerCapabilities | null;
5959
openworkServerDiagnostics: OpenworkServerDiagnostics | null;
6060
openworkServerWorkspaceId: string | null;
61+
clientConnected: boolean;
62+
canReloadWorkspace: boolean;
6163
openworkAuditEntries: OpenworkAuditEntry[];
6264
openworkAuditStatus: "idle" | "loading" | "error";
6365
openworkAuditError: string | null;
6466
opencodeConnectStatus: OpencodeConnectStatus | null;
6567
engineInfo: EngineInfo | null;
6668
openwrkStatus: OpenwrkStatus | null;
6769
owpenbotInfo: OwpenbotInfo | null;
70+
reloadWorkspaceEngine: () => Promise<void>;
71+
reloadBusy: boolean;
72+
reloadError: string | null;
6873
updateOpenworkServerSettings: (next: OpenworkServerSettings) => void;
6974
resetOpenworkServerSettings: () => void;
7075
testOpenworkServerConnection: (next: OpenworkServerSettings) => Promise<boolean>;
@@ -941,6 +946,18 @@ export default function SettingsView(props: SettingsViewProps) {
941946
}
942947
});
943948

949+
const reloadAvailabilityReason = createMemo(() => {
950+
if (!props.clientConnected) return "Connect to this workspace to reload.";
951+
if (!props.canReloadWorkspace) {
952+
return "Reloading is only available for local workspaces or connected OpenWork servers.";
953+
}
954+
return null;
955+
});
956+
957+
const reloadButtonLabel = createMemo(() => (props.reloadBusy ? "Reloading..." : "Reload engine"));
958+
const reloadButtonTone = createMemo(() => (props.anyActiveRuns ? "danger" : "secondary"));
959+
const reloadButtonDisabled = createMemo(() => props.reloadBusy || Boolean(reloadAvailabilityReason()));
960+
944961
const engineStatusLabel = createMemo(() => {
945962
if (!isTauriRuntime()) return "Unavailable";
946963
return props.engineInfo?.running ? "Running" : "Offline";
@@ -1927,6 +1944,38 @@ export default function SettingsView(props: SettingsViewProps) {
19271944
</div>
19281945
</Show>
19291946
</div>
1947+
1948+
<div class="bg-gray-2/30 border border-gray-6/50 rounded-2xl p-5 space-y-4">
1949+
<div>
1950+
<div class="text-sm font-medium text-gray-12">Engine reload</div>
1951+
<div class="text-xs text-gray-10">Restart the OpenCode server for this workspace.</div>
1952+
</div>
1953+
1954+
<div class="flex items-center justify-between bg-gray-1 p-3 rounded-xl border border-gray-6 gap-3">
1955+
<div class="min-w-0 space-y-1">
1956+
<div class="text-sm text-gray-12">Reload now</div>
1957+
<div class="text-xs text-gray-7">Applies config updates and reconnects your session.</div>
1958+
<Show when={props.anyActiveRuns}>
1959+
<div class="text-[11px] text-amber-11">Reloading will stop active tasks.</div>
1960+
</Show>
1961+
<Show when={props.reloadError}>
1962+
<div class="text-[11px] text-red-11">{props.reloadError}</div>
1963+
</Show>
1964+
<Show when={reloadAvailabilityReason()}>
1965+
<div class="text-[11px] text-gray-9">{reloadAvailabilityReason()}</div>
1966+
</Show>
1967+
</div>
1968+
<Button
1969+
variant={reloadButtonTone()}
1970+
class="text-xs h-8 py-0 px-3 shrink-0"
1971+
onClick={props.reloadWorkspaceEngine}
1972+
disabled={reloadButtonDisabled()}
1973+
>
1974+
<RefreshCcw size={14} class={props.reloadBusy ? "animate-spin" : ""} />
1975+
{reloadButtonLabel()}
1976+
</Button>
1977+
</div>
1978+
</div>
19301979
</div>
19311980
</div>
19321981
</Match>

0 commit comments

Comments
 (0)