@omercnet/paseo-omp 5.4.0 → 5.5.0-next.429.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +7 -1
- package/README.md +2 -1
- package/client/ast-edit.tsx +53 -0
- package/client/composer-pill-settings.tsx +0 -5
- package/client/config-sidebar.tsx +15 -0
- package/client/generated-image.tsx +79 -0
- package/client/lsp-diagnostics.tsx +69 -0
- package/client/omp-config-surface.tsx +438 -108
- package/client/omp-config-views.ts +32 -5
- package/client/omp-extensions-section.tsx +145 -0
- package/client/omp-local-models-section.tsx +215 -0
- package/client/omp-plugin-manager.tsx +198 -3
- package/client/omp-routing-editor.tsx +123 -2
- package/client/omp-rule-test.tsx +140 -0
- package/client/omp-rules-section.tsx +353 -0
- package/client/omp-security-section.tsx +99 -0
- package/client/omp-security-state.ts +14 -0
- package/client/omp-skills-section.tsx +195 -0
- package/client/omp-tool-config-section.tsx +204 -0
- package/client/omp-tool-policy-state.ts +101 -0
- package/client/omp-tool-policy.tsx +435 -0
- package/client/omp-update-row.tsx +87 -0
- package/client/provider-diagnostics-state.ts +38 -1
- package/client/provider-image.tsx +1 -1
- package/client/rule-notice.tsx +33 -0
- package/client/sidebar-compat.ts +0 -109
- package/client/web.ts +34 -0
- package/index.client.tsx +79 -46
- package/index.server.ts +77 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
- package/server/generated-images.ts +57 -0
- package/server/omp-agents.ts +170 -0
- package/server/omp-extensions.ts +235 -0
- package/server/omp-list-setting.ts +98 -0
- package/server/omp-local-models.ts +202 -0
- package/server/omp-models-file.ts +178 -0
- package/server/omp-plugins.ts +182 -0
- package/server/omp-prompt-files.ts +41 -0
- package/server/omp-rule-firings.ts +211 -0
- package/server/omp-rule-switch.ts +38 -0
- package/server/omp-rule-test.ts +82 -0
- package/server/omp-rules.ts +452 -0
- package/server/omp-security.ts +169 -0
- package/server/omp-settings.ts +92 -16
- package/server/omp-skills.ts +179 -0
- package/server/omp-tool-config.ts +144 -0
- package/server/omp-update.ts +203 -0
- package/server/package-version.ts +1 -1
- package/server/provider/connection.ts +1 -1
- package/server/provider/image-cache.ts +1 -1
- package/server/provider/omp-rpc-environment.ts +1 -1
- package/server/provider/session-descriptors.ts +3 -0
- package/server/provider-diagnostics.ts +26 -4
- package/server/regular-file.ts +30 -0
- package/server/rule-notices.ts +112 -0
- package/server/turn-rows.ts +59 -0
- package/server/turn-screenshots.ts +140 -0
- package/shared/ast-edit.ts +124 -0
- package/shared/composer-pill-settings.ts +0 -2
- package/shared/generated-image.ts +68 -0
- package/shared/lsp-diagnostics.ts +141 -0
- package/shared/omp-agents.ts +26 -0
- package/shared/omp-extensions.ts +45 -0
- package/shared/omp-local-models.ts +44 -0
- package/shared/omp-models-file.ts +30 -0
- package/shared/omp-plugins.ts +90 -0
- package/shared/omp-prompt-files.ts +24 -0
- package/shared/omp-rules.ts +134 -0
- package/shared/omp-security.ts +50 -0
- package/shared/omp-settings.ts +211 -2
- package/shared/omp-skills.ts +80 -0
- package/shared/omp-tool-config.ts +283 -0
- package/shared/omp-update.ts +27 -0
- package/shared/provider-image.ts +10 -3
- package/shared/rule-notices.ts +20 -0
- package/client/hub-sidebar.tsx +0 -99
- package/client/sessions-popover.tsx +0 -78
- package/server/sessions.ts +0 -58
- package/shared/sessions.ts +0 -24
|
@@ -4,6 +4,10 @@ export type OmpConfigSurfaceView =
|
|
|
4
4
|
| "mcps"
|
|
5
5
|
| "plugin"
|
|
6
6
|
| "plugins"
|
|
7
|
+
| "rules"
|
|
8
|
+
| "skills"
|
|
9
|
+
| "extensions"
|
|
10
|
+
| "security"
|
|
7
11
|
| "composer"
|
|
8
12
|
| "configuration"
|
|
9
13
|
| "diagnostics"
|
|
@@ -13,8 +17,12 @@ const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
|
|
|
13
17
|
{ id: "overview", label: "Overview" },
|
|
14
18
|
{ id: "accounts", label: "Accounts" },
|
|
15
19
|
{ id: "mcps", label: "MCPs" },
|
|
16
|
-
{ id: "plugin", label: "Plugin" },
|
|
20
|
+
{ id: "plugin", label: "Plugin provider" },
|
|
17
21
|
{ id: "plugins", label: "OMP plugins" },
|
|
22
|
+
{ id: "rules", label: "Rules" },
|
|
23
|
+
{ id: "skills", label: "Skills" },
|
|
24
|
+
{ id: "extensions", label: "Extensions" },
|
|
25
|
+
{ id: "security", label: "Security" },
|
|
18
26
|
{ id: "composer", label: "Composer" },
|
|
19
27
|
{ id: "configuration", label: "Configuration" },
|
|
20
28
|
{ id: "diagnostics", label: "Diagnostics" },
|
|
@@ -24,8 +32,27 @@ const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
|
|
|
24
32
|
/** Views that belong to the OMP store, not to a workspace's project settings. */
|
|
25
33
|
const STORE_ONLY_VIEWS: readonly OmpConfigSurfaceView[] = ["composer", "accounts", "mcps"];
|
|
26
34
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
/** Views about one project, which the global OMP screen has no project for. */
|
|
36
|
+
const WORKSPACE_ONLY_VIEWS: readonly OmpConfigSurfaceView[] = ["security"];
|
|
37
|
+
|
|
38
|
+
interface SurfaceScope {
|
|
39
|
+
workspaceScoped: boolean;
|
|
40
|
+
/** The plugin's own `omp-plugin` providers; the Plugin provider view only applies to them. */
|
|
41
|
+
pluginProviderEnabled: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function surfaceViewsForScope({ workspaceScoped, pluginProviderEnabled }: SurfaceScope) {
|
|
45
|
+
const hidden = workspaceScoped ? STORE_ONLY_VIEWS : WORKSPACE_ONLY_VIEWS;
|
|
46
|
+
return SURFACE_VIEWS.filter(
|
|
47
|
+
(candidate) =>
|
|
48
|
+
!hidden.includes(candidate.id) && (pluginProviderEnabled || candidate.id !== "plugin"),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A view the current scope or provider state hides falls back to Overview, never a blank screen. */
|
|
53
|
+
export function resolveSurfaceView(
|
|
54
|
+
views: readonly { id: OmpConfigSurfaceView }[],
|
|
55
|
+
selected: OmpConfigSurfaceView,
|
|
56
|
+
): OmpConfigSurfaceView {
|
|
57
|
+
return views.some((candidate) => candidate.id === selected) ? selected : "overview";
|
|
31
58
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import {
|
|
3
|
+
SettingsCard,
|
|
4
|
+
SettingsSection,
|
|
5
|
+
SettingsSwitch,
|
|
6
|
+
useToast,
|
|
7
|
+
} from "@getpaseo/plugin/client/ui";
|
|
8
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { Text, View } from "react-native";
|
|
11
|
+
import {
|
|
12
|
+
listOmpExtensions,
|
|
13
|
+
type OmpExtensionItem,
|
|
14
|
+
type OmpExtensionKind,
|
|
15
|
+
setOmpExtensionEnabled,
|
|
16
|
+
} from "../shared/omp-extensions";
|
|
17
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
18
|
+
import { ConfirmModal, describe } from "./omp-accounts-section";
|
|
19
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
20
|
+
import { ompStoreKey } from "./omp-store-state";
|
|
21
|
+
|
|
22
|
+
type Theme = PluginSurfaceProps["theme"];
|
|
23
|
+
|
|
24
|
+
const EXTENSIONS_KEY = ["paseo-omp", "extensions"] as const;
|
|
25
|
+
|
|
26
|
+
const GROUPS: readonly { kind: OmpExtensionKind; title: string }[] = [
|
|
27
|
+
{ kind: "extension", title: "Extensions" },
|
|
28
|
+
{ kind: "hook", title: "Hooks" },
|
|
29
|
+
{ kind: "tool", title: "Custom tools" },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const INFO =
|
|
33
|
+
"Read from the folders OMP documents: the workspace's .omp/ and OMP's agent directory (the agent directory itself is read even if it is a symlink; nothing below it is). OMP has no list command, so this is a close inventory, not OMP's own list: it does not read .gitignore or the extensions setting, it leaves out folders whose package.json declares entries (or cannot be read safely), declaration files, JSON and Markdown tool definitions and symlinked entries, and it shows one row where two files share a name. Turning one off adds it to disabledExtensions; in a workspace the whole list is saved to the project's .omp/config.yml, because a project list replaces the user list. Changes apply to new sessions. OMP does not report extension load errors for the built-in omp agents.";
|
|
34
|
+
|
|
35
|
+
const RESTART_HINT = "Turned on. An agent that is already running needs a restart to load it.";
|
|
36
|
+
|
|
37
|
+
/** Extensions and hooks can block or rewrite tool calls; a tool only adds one. */
|
|
38
|
+
function needsWarning(item: OmpExtensionItem): boolean {
|
|
39
|
+
return item.kind !== "tool";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function itemHint(item: OmpExtensionItem): string {
|
|
43
|
+
const level = item.level === "project" ? "Project" : "User";
|
|
44
|
+
return `${level} · ${item.path}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function OmpExtensionsSection({
|
|
48
|
+
theme,
|
|
49
|
+
styles,
|
|
50
|
+
cwd,
|
|
51
|
+
store,
|
|
52
|
+
}: {
|
|
53
|
+
theme: Theme;
|
|
54
|
+
styles: OmpConfigStyles;
|
|
55
|
+
cwd?: string;
|
|
56
|
+
store?: OmpStore;
|
|
57
|
+
}) {
|
|
58
|
+
const toast = useToast();
|
|
59
|
+
const queryClient = useQueryClient();
|
|
60
|
+
const load = useRpc(listOmpExtensions);
|
|
61
|
+
const setEnabled = useRpc(setOmpExtensionEnabled);
|
|
62
|
+
const [pendingOff, setPendingOff] = useState<OmpExtensionItem | null>(null);
|
|
63
|
+
const scope = cwd ? { cwd } : {};
|
|
64
|
+
const extensions = useQuery({
|
|
65
|
+
queryKey: [...EXTENSIONS_KEY, ompStoreKey(store), cwd ?? "global"],
|
|
66
|
+
queryFn: () => load({ store, ...scope }),
|
|
67
|
+
});
|
|
68
|
+
const toggle = useMutation({
|
|
69
|
+
mutationKey: [...EXTENSIONS_KEY, "toggle"],
|
|
70
|
+
mutationFn: (change: { id: string; enabled: boolean }) =>
|
|
71
|
+
setEnabled({ store, ...scope, ...change }),
|
|
72
|
+
onSuccess: async (result, change) => {
|
|
73
|
+
if (result.status === "error") toast.error(result.message);
|
|
74
|
+
else if (change.enabled) toast.show(RESTART_HINT, { variant: "success" });
|
|
75
|
+
await queryClient.invalidateQueries({ queryKey: EXTENSIONS_KEY });
|
|
76
|
+
},
|
|
77
|
+
onError: (error) => toast.error(describe(error)),
|
|
78
|
+
onSettled: () => setPendingOff(null),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
function flip(item: OmpExtensionItem) {
|
|
82
|
+
if (item.enabled && needsWarning(item)) setPendingOff(item);
|
|
83
|
+
else toggle.mutate({ id: item.id, enabled: !item.enabled });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const list = extensions.data;
|
|
87
|
+
return (
|
|
88
|
+
<View style={{ gap: 12 }}>
|
|
89
|
+
<SettingsSection title="Extensions, hooks and tools" info={INFO}>
|
|
90
|
+
<Text style={styles.muted}>
|
|
91
|
+
Code OMP runs for this {cwd ? "workspace" : "user"}. Turned-off items stay listed.
|
|
92
|
+
</Text>
|
|
93
|
+
</SettingsSection>
|
|
94
|
+
{extensions.isLoading ? <Text style={styles.muted}>Loading extensions...</Text> : null}
|
|
95
|
+
{extensions.error ? (
|
|
96
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
97
|
+
Could not list OMP's extensions.
|
|
98
|
+
</Text>
|
|
99
|
+
) : null}
|
|
100
|
+
{list?.status === "error" ? (
|
|
101
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
102
|
+
{list.message}
|
|
103
|
+
</Text>
|
|
104
|
+
) : null}
|
|
105
|
+
{list?.status === "ready" && list.items.length === 0 ? (
|
|
106
|
+
<Text style={styles.muted}>No extensions, hooks or custom tools found</Text>
|
|
107
|
+
) : null}
|
|
108
|
+
{list?.status === "ready"
|
|
109
|
+
? GROUPS.map((group) => {
|
|
110
|
+
const members = list.items.filter((item) => item.kind === group.kind);
|
|
111
|
+
if (members.length === 0) return null;
|
|
112
|
+
return (
|
|
113
|
+
<SettingsSection key={group.kind} title={group.title}>
|
|
114
|
+
<SettingsCard>
|
|
115
|
+
{members.map((item) => (
|
|
116
|
+
<SettingsSwitch
|
|
117
|
+
key={item.path}
|
|
118
|
+
label={item.name}
|
|
119
|
+
hint={itemHint(item)}
|
|
120
|
+
value={item.enabled}
|
|
121
|
+
disabled={toggle.isPending}
|
|
122
|
+
onValueChange={() => flip(item)}
|
|
123
|
+
/>
|
|
124
|
+
))}
|
|
125
|
+
</SettingsCard>
|
|
126
|
+
</SettingsSection>
|
|
127
|
+
);
|
|
128
|
+
})
|
|
129
|
+
: null}
|
|
130
|
+
{pendingOff ? (
|
|
131
|
+
<ConfirmModal
|
|
132
|
+
styles={styles}
|
|
133
|
+
theme={theme}
|
|
134
|
+
title={`Turn off ${pendingOff.name}?`}
|
|
135
|
+
body="It may be guarding or rewriting tool calls, such as a safety hook. Turning it off removes that protection for new sessions, for the terminal too."
|
|
136
|
+
confirmLabel="Turn off"
|
|
137
|
+
tone="danger"
|
|
138
|
+
busy={toggle.isPending}
|
|
139
|
+
onConfirm={() => toggle.mutate({ id: pendingOff.id, enabled: false })}
|
|
140
|
+
onCancel={() => setPendingOff(null)}
|
|
141
|
+
/>
|
|
142
|
+
) : null}
|
|
143
|
+
</View>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Pressable, Text, View } from "react-native";
|
|
5
|
+
import {
|
|
6
|
+
downloadOmpLocalModel,
|
|
7
|
+
listOmpLocalModels,
|
|
8
|
+
type OmpLocalModel,
|
|
9
|
+
withLocalModelRole,
|
|
10
|
+
} from "../shared/omp-local-models";
|
|
11
|
+
import { type OmpSettingsCatalog, updateOmpSettings } from "../shared/omp-settings";
|
|
12
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
13
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
14
|
+
import { ompStoreKey } from "./omp-store-state";
|
|
15
|
+
|
|
16
|
+
const POLL_MS = 3_000;
|
|
17
|
+
const ACTION_GROUP = { flexDirection: "row", flexWrap: "wrap", gap: 8 } as const;
|
|
18
|
+
|
|
19
|
+
const ROLES = [
|
|
20
|
+
{ role: "tiny", label: "titles" },
|
|
21
|
+
{ role: "memory", label: "memory" },
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
function Choice({
|
|
25
|
+
styles,
|
|
26
|
+
label,
|
|
27
|
+
accessibilityLabel,
|
|
28
|
+
selected,
|
|
29
|
+
disabled,
|
|
30
|
+
onPress,
|
|
31
|
+
}: {
|
|
32
|
+
styles: OmpConfigStyles;
|
|
33
|
+
label: string;
|
|
34
|
+
accessibilityLabel: string;
|
|
35
|
+
selected?: boolean;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
onPress(): void;
|
|
38
|
+
}) {
|
|
39
|
+
return (
|
|
40
|
+
<Pressable
|
|
41
|
+
accessibilityRole="button"
|
|
42
|
+
accessibilityLabel={accessibilityLabel}
|
|
43
|
+
accessibilityState={{ selected: selected === true }}
|
|
44
|
+
disabled={disabled}
|
|
45
|
+
onPress={onPress}
|
|
46
|
+
style={[styles.editorAction, selected ? styles.editorActionPrimary : null]}
|
|
47
|
+
>
|
|
48
|
+
<Text style={[styles.editorActionText, selected ? styles.editorActionTextPrimary : null]}>
|
|
49
|
+
{label}
|
|
50
|
+
</Text>
|
|
51
|
+
</Pressable>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function status(model: OmpLocalModel): string {
|
|
56
|
+
if (model.download === "running") return "Downloading...";
|
|
57
|
+
if (model.download === "failed") return `Download failed: ${model.error ?? "unknown error"}`;
|
|
58
|
+
return model.downloaded ? "Downloaded" : "Not downloaded";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** OMP's own on-device models for titles and memory. Not Paseo's Voice and Dictation models. */
|
|
62
|
+
export function OmpLocalModelsSection({
|
|
63
|
+
styles,
|
|
64
|
+
store,
|
|
65
|
+
modelRoles,
|
|
66
|
+
settingsRevision,
|
|
67
|
+
rolesPending,
|
|
68
|
+
onRolesChanged,
|
|
69
|
+
}: {
|
|
70
|
+
styles: OmpConfigStyles;
|
|
71
|
+
store: OmpStore | undefined;
|
|
72
|
+
modelRoles: Readonly<Record<string, unknown>>;
|
|
73
|
+
settingsRevision: string | undefined;
|
|
74
|
+
/** Unapplied edits to modelRoles would be overwritten by a role assignment made here. */
|
|
75
|
+
rolesPending: boolean;
|
|
76
|
+
onRolesChanged(catalog: OmpSettingsCatalog | undefined): void;
|
|
77
|
+
}) {
|
|
78
|
+
const list = useRpc(listOmpLocalModels);
|
|
79
|
+
const download = useRpc(downloadOmpLocalModel);
|
|
80
|
+
const update = useRpc(updateOmpSettings);
|
|
81
|
+
const queryClient = useQueryClient();
|
|
82
|
+
const [confirming, setConfirming] = useState<string | null>(null);
|
|
83
|
+
const queryKey = ["paseo-omp", "local-models", ompStoreKey(store)];
|
|
84
|
+
const models = useQuery({
|
|
85
|
+
queryKey,
|
|
86
|
+
queryFn: () => list(store ? { store } : {}),
|
|
87
|
+
refetchInterval: (query) =>
|
|
88
|
+
query.state.data?.models.some((model) => model.download === "running") ? POLL_MS : false,
|
|
89
|
+
});
|
|
90
|
+
const start = useMutation({
|
|
91
|
+
mutationKey: ["paseo-omp", "local-model-download"],
|
|
92
|
+
mutationFn: (key: string) => download({ ...(store ? { store } : {}), key }),
|
|
93
|
+
onSettled: () => queryClient.invalidateQueries({ queryKey }),
|
|
94
|
+
});
|
|
95
|
+
const assign = useMutation({
|
|
96
|
+
mutationKey: ["paseo-omp", "settings", ompStoreKey(store)],
|
|
97
|
+
mutationFn: async (next: Record<string, unknown>) => {
|
|
98
|
+
if (!settingsRevision) throw new Error("OMP settings cannot be edited without a revision.");
|
|
99
|
+
const input = updateOmpSettings.input.parse({
|
|
100
|
+
...(store ? { store } : {}),
|
|
101
|
+
revision: settingsRevision,
|
|
102
|
+
changes: [{ operation: "set", path: "modelRoles", value: next }],
|
|
103
|
+
});
|
|
104
|
+
return update(input);
|
|
105
|
+
},
|
|
106
|
+
onSuccess: (result) => onRolesChanged(result.catalog),
|
|
107
|
+
onError: () => onRolesChanged(undefined),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const busy = models.data?.models.some((model) => model.download === "running") === true;
|
|
111
|
+
const blocked = !settingsRevision || rolesPending || assign.isPending;
|
|
112
|
+
const failed = start.data && start.data.outcome !== "started";
|
|
113
|
+
|
|
114
|
+
function assignRole(role: string, selector: string | null) {
|
|
115
|
+
assign.mutate(withLocalModelRole(modelRoles, role, selector));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<View style={styles.card}>
|
|
120
|
+
<View style={styles.cardHeader}>
|
|
121
|
+
<Text style={styles.cardTitle}>OMP local models</Text>
|
|
122
|
+
</View>
|
|
123
|
+
<View style={styles.setting}>
|
|
124
|
+
<Text style={styles.settingDescription}>
|
|
125
|
+
Small models OMP runs on this machine for session titles and memory. They belong to OMP
|
|
126
|
+
only and are separate from Paseo's own Voice and Dictation models. Role changes apply to
|
|
127
|
+
new sessions or after a reload. A local titles role never falls back to an online model:
|
|
128
|
+
if the local model fails, the session stays untitled. The first download can also install
|
|
129
|
+
OMP's inference runtime, so it may take longer and use more disk than the model size.
|
|
130
|
+
</Text>
|
|
131
|
+
{models.error || (models.data && !models.data.available) ? (
|
|
132
|
+
<Text style={styles.error}>OMP could not list its local models.</Text>
|
|
133
|
+
) : null}
|
|
134
|
+
{start.error ? <Text style={styles.error}>Could not start the download.</Text> : null}
|
|
135
|
+
{failed ? (
|
|
136
|
+
<Text style={styles.error}>
|
|
137
|
+
{start.data?.outcome === "busy"
|
|
138
|
+
? "Another download is still running."
|
|
139
|
+
: "OMP could not start that download."}
|
|
140
|
+
</Text>
|
|
141
|
+
) : null}
|
|
142
|
+
{assign.error || (assign.data && (assign.data.conflict || assign.data.failed)) ? (
|
|
143
|
+
<Text style={styles.error}>
|
|
144
|
+
Could not change the role. Refresh the settings and try again.
|
|
145
|
+
</Text>
|
|
146
|
+
) : null}
|
|
147
|
+
</View>
|
|
148
|
+
{models.data?.models.map((model) => (
|
|
149
|
+
<View key={model.key} style={styles.setting}>
|
|
150
|
+
<View style={styles.settingHeader}>
|
|
151
|
+
<Text style={styles.cardTitle}>{model.label}</Text>
|
|
152
|
+
<Text style={styles.source}>{status(model)}</Text>
|
|
153
|
+
</View>
|
|
154
|
+
<Text selectable style={styles.settingPath}>
|
|
155
|
+
{model.key}
|
|
156
|
+
</Text>
|
|
157
|
+
<Text style={styles.settingDescription}>{model.description}</Text>
|
|
158
|
+
{confirming === model.key ? (
|
|
159
|
+
<View style={styles.recordList}>
|
|
160
|
+
<Text style={styles.settingDescription}>
|
|
161
|
+
Download {model.label}
|
|
162
|
+
{model.sizeMb ? ` (about ${model.sizeMb} MB)` : ""} to this machine? OMP shows no
|
|
163
|
+
progress, so this can take several minutes.
|
|
164
|
+
</Text>
|
|
165
|
+
<View style={ACTION_GROUP}>
|
|
166
|
+
<Choice
|
|
167
|
+
styles={styles}
|
|
168
|
+
label="Download"
|
|
169
|
+
accessibilityLabel={`Confirm download of ${model.label}`}
|
|
170
|
+
selected
|
|
171
|
+
disabled={busy || start.isPending}
|
|
172
|
+
onPress={() => {
|
|
173
|
+
setConfirming(null);
|
|
174
|
+
start.mutate(model.key);
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
<Choice
|
|
178
|
+
styles={styles}
|
|
179
|
+
label="Cancel"
|
|
180
|
+
accessibilityLabel={`Cancel download of ${model.label}`}
|
|
181
|
+
onPress={() => setConfirming(null)}
|
|
182
|
+
/>
|
|
183
|
+
</View>
|
|
184
|
+
</View>
|
|
185
|
+
) : (
|
|
186
|
+
<View style={ACTION_GROUP}>
|
|
187
|
+
<Choice
|
|
188
|
+
styles={styles}
|
|
189
|
+
label={model.downloaded ? "Download again" : "Download"}
|
|
190
|
+
accessibilityLabel={`Download ${model.label}`}
|
|
191
|
+
disabled={busy || start.isPending}
|
|
192
|
+
onPress={() => setConfirming(model.key)}
|
|
193
|
+
/>
|
|
194
|
+
{ROLES.map(({ role, label }) => {
|
|
195
|
+
const selector = `local/${model.key}`;
|
|
196
|
+
const assigned = modelRoles[role] === selector;
|
|
197
|
+
return (
|
|
198
|
+
<Choice
|
|
199
|
+
key={role}
|
|
200
|
+
styles={styles}
|
|
201
|
+
label={assigned ? `Using for ${label}` : `Use for ${label}`}
|
|
202
|
+
accessibilityLabel={`${assigned ? "Stop using" : "Use"} ${model.label} for ${label}`}
|
|
203
|
+
selected={assigned}
|
|
204
|
+
disabled={blocked}
|
|
205
|
+
onPress={() => assignRole(role, assigned ? null : selector)}
|
|
206
|
+
/>
|
|
207
|
+
);
|
|
208
|
+
})}
|
|
209
|
+
</View>
|
|
210
|
+
)}
|
|
211
|
+
</View>
|
|
212
|
+
))}
|
|
213
|
+
</View>
|
|
214
|
+
);
|
|
215
|
+
}
|