#!/bin/bash
# Exit immediately on error, treat unset variables as errors, propagate pipe failures.
set -euo pipefail
# Load shared log/warn/skip helpers from the installer library.
source "$(dirname "${BASH_SOURCE[0]}")/../../lib/logging.sh"

# Open WebUI — browser UI for Ollama and other LLM backends.
# Ollama module should be installed first for full functionality.
log "Installing Open WebUI (AUR)..."
# open-webui is only in the AUR; yay builds and installs it with the standard flags.
yay -S --answerdiff None --answerclean All --noconfirm open-webui

log "Enabling Open WebUI service..."
# The systemd service proxies requests to Ollama at localhost:11434 and serves
# the web interface on port 8080; enable --now starts it without a reboot.
enable_service open-webui.service; start_service open-webui.service

log "Open WebUI running at http://localhost:8080"
