refactor(ollama): remove download/install buttons — show plain install instructions only
This commit is contained in:
parent
0796297e8c
commit
9175faf0b4
@ -218,16 +218,6 @@ getAuditLogCmd(filter: AuditLogFilter) → AuditEntry[]
|
|||||||
```
|
```
|
||||||
Returns audit log entries. Filter by action, entity_type, date range.
|
Returns audit log entries. Filter by action, entity_type, date range.
|
||||||
|
|
||||||
### `install_ollama_from_bundle`
|
|
||||||
```typescript
|
|
||||||
installOllamaFromBundleCmd() → string
|
|
||||||
```
|
|
||||||
Copies the Ollama binary bundled inside the app resources to the system install path:
|
|
||||||
- **Linux/macOS**: `/usr/local/bin/ollama` (requires write permission — user may need to run app with elevated privileges or `sudo`)
|
|
||||||
- **Windows**: `%LOCALAPPDATA%\Programs\Ollama\ollama.exe`
|
|
||||||
|
|
||||||
Returns a success message with the install path. Errors if the bundled binary is not present in the app resources (i.e., the app was built without an Ollama bundle step in CI).
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Integration Commands
|
## Integration Commands
|
||||||
|
|||||||
@ -141,74 +141,3 @@ pub async fn get_audit_log(
|
|||||||
|
|
||||||
Ok(rows)
|
Ok(rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security note: the bundled binary's integrity is guaranteed by the CI release pipeline
|
|
||||||
// which verifies SHA256 checksums against Ollama's published sha256sums.txt before bundling.
|
|
||||||
// Runtime re-verification is not performed here; the app bundle itself is the trust boundary.
|
|
||||||
// On Unix, writing to /usr/local/bin requires elevated privileges. If the operation fails with
|
|
||||||
// PermissionDenied the caller receives an actionable error message.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn install_ollama_from_bundle(app: tauri::AppHandle) -> Result<String, String> {
|
|
||||||
use std::fs;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use tauri::Manager;
|
|
||||||
|
|
||||||
let resource_dir = app
|
|
||||||
.path()
|
|
||||||
.resource_dir()
|
|
||||||
.map_err(|e: tauri::Error| e.to_string())?;
|
|
||||||
|
|
||||||
let resource_path = resource_dir.join("ollama").join(if cfg!(windows) {
|
|
||||||
"ollama.exe"
|
|
||||||
} else {
|
|
||||||
"ollama"
|
|
||||||
});
|
|
||||||
|
|
||||||
if !resource_path.exists() {
|
|
||||||
return Err("Bundled Ollama not found in resources".to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defense-in-depth: verify resolved path stays within the resource directory.
|
|
||||||
let canonical_resource = resource_path.canonicalize().map_err(|e| e.to_string())?;
|
|
||||||
let canonical_dir = resource_dir.canonicalize().map_err(|e| e.to_string())?;
|
|
||||||
if !canonical_resource.starts_with(&canonical_dir) {
|
|
||||||
return Err("Resource path validation failed".to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
let install_path = PathBuf::from("/usr/local/bin/ollama");
|
|
||||||
#[cfg(windows)]
|
|
||||||
let install_path = {
|
|
||||||
let local_app_data = std::env::var("LOCALAPPDATA").map_err(|e| e.to_string())?;
|
|
||||||
PathBuf::from(local_app_data)
|
|
||||||
.join("Programs")
|
|
||||||
.join("Ollama")
|
|
||||||
.join("ollama.exe")
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(parent) = install_path.parent() {
|
|
||||||
fs::create_dir_all(parent).map_err(|e| e.to_string())?;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs::copy(&resource_path, &install_path).map_err(|e| {
|
|
||||||
if e.kind() == std::io::ErrorKind::PermissionDenied {
|
|
||||||
format!(
|
|
||||||
"Permission denied writing to {}. On Linux, re-run the app with elevated \
|
|
||||||
privileges or install manually: sudo cp \"{}\" /usr/local/bin/ollama",
|
|
||||||
install_path.display(),
|
|
||||||
resource_path.display()
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
e.to_string()
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
use std::os::unix::fs::PermissionsExt;
|
|
||||||
fs::set_permissions(&install_path, fs::Permissions::from_mode(0o755))
|
|
||||||
.map_err(|e| e.to_string())?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(format!("Ollama installed to {}", install_path.display()))
|
|
||||||
}
|
|
||||||
|
|||||||
@ -109,7 +109,6 @@ pub fn run() {
|
|||||||
commands::system::get_settings,
|
commands::system::get_settings,
|
||||||
commands::system::update_settings,
|
commands::system::update_settings,
|
||||||
commands::system::get_audit_log,
|
commands::system::get_audit_log,
|
||||||
commands::system::install_ollama_from_bundle,
|
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("Error running Troubleshooting and RCA Assistant application");
|
.expect("Error running Troubleshooting and RCA Assistant application");
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
"icons/icon.icns",
|
"icons/icon.icns",
|
||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
],
|
],
|
||||||
"resources": ["resources/ollama/*"],
|
"resources": [],
|
||||||
"externalBin": [],
|
"externalBin": [],
|
||||||
"copyright": "Troubleshooting and RCA Assistant Contributors",
|
"copyright": "Troubleshooting and RCA Assistant Contributors",
|
||||||
"category": "Utility",
|
"category": "Utility",
|
||||||
|
|||||||
@ -436,6 +436,3 @@ export const getIntegrationConfigCmd = (service: string) =>
|
|||||||
|
|
||||||
export const getAllIntegrationConfigsCmd = () =>
|
export const getAllIntegrationConfigsCmd = () =>
|
||||||
invoke<IntegrationConfig[]>("get_all_integration_configs");
|
invoke<IntegrationConfig[]>("get_all_integration_configs");
|
||||||
|
|
||||||
export const installOllamaFromBundleCmd = () =>
|
|
||||||
invoke<string>("install_ollama_from_bundle");
|
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import {
|
|||||||
deleteOllamaModelCmd,
|
deleteOllamaModelCmd,
|
||||||
listOllamaModelsCmd,
|
listOllamaModelsCmd,
|
||||||
getOllamaInstallGuideCmd,
|
getOllamaInstallGuideCmd,
|
||||||
installOllamaFromBundleCmd,
|
|
||||||
type OllamaStatus,
|
type OllamaStatus,
|
||||||
type HardwareInfo,
|
type HardwareInfo,
|
||||||
type ModelRecommendation,
|
type ModelRecommendation,
|
||||||
@ -44,7 +43,6 @@ export default function Ollama() {
|
|||||||
const [customModel, setCustomModel] = useState("");
|
const [customModel, setCustomModel] = useState("");
|
||||||
const [isPulling, setIsPulling] = useState(false);
|
const [isPulling, setIsPulling] = useState(false);
|
||||||
const [pullProgress, setPullProgress] = useState(0);
|
const [pullProgress, setPullProgress] = useState(0);
|
||||||
const [isInstallingBundle, setIsInstallingBundle] = useState(false);
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
@ -107,19 +105,6 @@ export default function Ollama() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInstallFromBundle = async () => {
|
|
||||||
setIsInstallingBundle(true);
|
|
||||||
setError(null);
|
|
||||||
try {
|
|
||||||
await installOllamaFromBundleCmd();
|
|
||||||
await loadData();
|
|
||||||
} catch (err) {
|
|
||||||
setError(String(err));
|
|
||||||
} finally {
|
|
||||||
setIsInstallingBundle(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDelete = async (modelName: string) => {
|
const handleDelete = async (modelName: string) => {
|
||||||
try {
|
try {
|
||||||
await deleteOllamaModelCmd(modelName);
|
await deleteOllamaModelCmd(modelName);
|
||||||
@ -184,33 +169,16 @@ export default function Ollama() {
|
|||||||
{status && !status.installed && installGuide && (
|
{status && !status.installed && installGuide && (
|
||||||
<Card className="border-yellow-500/50">
|
<Card className="border-yellow-500/50">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-lg flex items-center gap-2">
|
<CardTitle className="text-lg">
|
||||||
<Download className="w-5 h-5 text-yellow-500" />
|
|
||||||
Ollama Not Detected — Installation Required
|
Ollama Not Detected — Installation Required
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-4">
|
<CardContent>
|
||||||
<ol className="space-y-2 list-decimal list-inside">
|
<ol className="space-y-2 list-decimal list-inside">
|
||||||
{installGuide.steps.map((step, i) => (
|
{installGuide.steps.map((step, i) => (
|
||||||
<li key={i} className="text-sm text-muted-foreground">{step}</li>
|
<li key={i} className="text-sm text-muted-foreground">{step}</li>
|
||||||
))}
|
))}
|
||||||
</ol>
|
</ol>
|
||||||
<div className="flex flex-wrap gap-2">
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
onClick={() => window.open(installGuide.url, "_blank")}
|
|
||||||
>
|
|
||||||
<Download className="w-4 h-4 mr-2" />
|
|
||||||
Download Ollama for {installGuide.platform}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onClick={handleInstallFromBundle}
|
|
||||||
disabled={isInstallingBundle}
|
|
||||||
>
|
|
||||||
<Download className="w-4 h-4 mr-2" />
|
|
||||||
{isInstallingBundle ? "Installing..." : "Install Ollama (Offline)"}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user