Commit Graph
630 Commits
Author SHA1 Message Date
ashim-hq 546cf52222 fix: install lock used server PID causing permanent stale lock
The lock file stored process.pid (Node server PID) which is always
alive. When releaseInstallLock wasn't called (e.g., error path),
the lock persisted forever, making the bundle stuck in "installing"
and blocking all future installs.

Fix: remove PID from lock entirely. Use simple file existence as
mutex. On server startup, unconditionally delete any lock file.
2026-04-18 11:39:20 +08:00
ashim-hq fa9c94f7ad fix: subscribe to bundles array reactively in ToolCard for download badge
The previous selector returned the isToolInstalled function reference
which never changes, so the component didn't re-render when bundles
loaded. Now subscribes to the bundles array directly via useMemo.
2026-04-18 11:34:22 +08:00
ashim-hq 46739a135e fix: use absolute path for install script (cwd is /app/apps/api in Docker) 2026-04-18 10:58:37 +08:00
ashim-hq 3eab3d5391 fix: tool page race condition on refresh and install error reporting
- Subscribe to features store reactively in ToolPage so refresh shows
  install prompt correctly instead of the tool UI
- Show loading state while features are being fetched for AI tools
- Capture stdout from install script for better error messages
- Keep last 20 stderr lines for error context instead of just exit code
- Clear install progress on success (was leaving stale state)
- Pass PIP_CACHE_DIR to install subprocess
2026-04-18 10:55:22 +08:00
ashim-hq 3b2612ac72 fix: don't send Content-Type: application/json with empty POST body 2026-04-18 10:48:20 +08:00
ashim-hq 2a94cdc024 fix: add FEATURE_NOT_INSTALLED guard to all 10 remaining AI tool routes
The guard was only present on restore-photo.ts and the createToolRoute
factory. All other AI tools used custom route handlers that bypassed
the check entirely, allowing requests to reach the Python sidecar even
when the feature bundle was not installed. This adds an early 501
response before any multipart parsing or file processing.
2026-04-18 10:23:14 +08:00
ashim-hq d7b6037b3d fix: use MODELS_PATH env var for AI model paths instead of hardcoded /opt/models
The on-demand feature download system stores models at /data/ai/models/
(set via MODELS_PATH env var), but all Python scripts hardcoded
/opt/models/ as the base path. Each script now reads MODELS_PATH and
falls back to /opt/models for backward compatibility.
2026-04-18 10:17:01 +08:00
ashim-hq 28462c8f60 test: add comprehensive feature bundle tests (e2e + unit edge cases)
E2E tests cover feature API responses, tool route 501 guards for all 11
AI tools, batch endpoint guards, and GUI interactions (install prompt,
settings panel, sidebar badges). Unit tests add edge cases for duplicate
tool detection, unknown bundle/tool lookups, and TOOL_BUNDLE_MAP integrity.
2026-04-18 03:01:18 +08:00
ashim-hq b259f765de feat: strip ML packages from Docker image, bootstrap AI venv on first run
Remove all ML pip installs (onnxruntime, rembg, realesrgan, paddlepaddle,
mediapipe, codeformer), model downloads, and post-install fixups from the
Dockerfile. The base image now ships only Node.js + Sharp + Python with
numpy/Pillow/opencv. AI features are installed on-demand at runtime via
the feature manifest and install_feature.py script.

Key changes:
- Remove SKIP_MODEL_DOWNLOADS build arg (no longer needed)
- Remove apt-get purge of build-essential (needed for runtime pip installs)
- Remove PaddleX symlinks and facexlib weight directory setup
- Add COPY of feature-manifest.json and install_feature.py
- Update PYTHON_VENV_PATH to /data/ai/venv, add MODELS_PATH and DATA_DIR
- Entrypoint bootstraps AI venv from /opt/venv on first container start
  with crash-safe temp directory pattern
2026-04-18 02:57:47 +08:00
ashim-hq 645324cde6 feat: add AI Features settings panel for managing feature bundles 2026-04-18 02:54:44 +08:00
ashim-hq 6e9a79191a feat: add FeatureInstallPrompt component for uninstalled AI tool pages
Show an install prompt instead of the normal tool UI when an AI feature
bundle is not installed. Admins see a one-click install button with SSE
progress tracking and polling fallback; non-admins see a message to
contact their administrator.
2026-04-18 02:50:56 +08:00
ashim-hq fe1ae8436d feat: add download badge to uninstalled AI tools in tool grid
Show a download icon on AI tools that are not yet installed, and fetch
feature status on mount in both the sidebar tool panel and fullscreen
grid page.
2026-04-18 02:47:42 +08:00
ashim-hq 0b9c760e5e feat: add frontend features store and FEATURE_NOT_INSTALLED error handling
Add Zustand features store for tracking AI feature bundle state with
fetch, refresh, isToolInstalled, and getBundleForTool methods. Extend
parseApiError to return structured FeatureNotInstalledError objects
when the backend returns FEATURE_NOT_INSTALLED, and handle them in
both tool and pipeline processor hooks with user-friendly messages.
2026-04-18 02:45:43 +08:00
ashim-hq 494bb3d78b feat: add feature gating to Python sidecar dispatcher
Check installed.json before exec()-ing AI scripts so that requests
for uninstalled feature bundles return a structured error instead
of crashing with an ImportError. Also sets U2NET_HOME to the
bundled model directory when present.
2026-04-18 02:42:34 +08:00
ashim-hq 3c3aa74e98 feat: add FEATURE_NOT_INSTALLED guards to API tool routes
Return 501 with structured error when an AI tool's feature bundle
is not installed, preventing Python ImportError crashes. Guards
added to tool-factory, batch, pipeline (both validation loops),
and restore-photo custom route.
2026-04-18 02:40:16 +08:00
ashim-hq 7ffbd5e3c6 feat: add Python install script for on-demand AI feature bundles
Reads the feature manifest, installs pip packages (common + arch-specific),
downloads models in parallel with atomic rename, and writes installed.json.
Includes disk space pre-check, NCCL conflict handling, retry logic, and
progress reporting via stderr JSON lines. Also updates the feature route
to pass manifestPath and modelsDir as CLI arguments.
2026-04-18 02:37:43 +08:00
ashim-hq cadb0f8071 feat: add feature install/uninstall API routes with SSE progress 2026-04-18 02:34:21 +08:00
ashim-hq bf01f7169a feat: add backend feature status service for AI bundle tracking
Tracks which AI feature bundles are installed via /data/ai/installed.json
with atomic writes, in-memory caching, file-based install locks, and
startup recovery for interrupted installs.
2026-04-18 02:30:16 +08:00
ashim-hq 43a572adcf feat: add feature manifest with exact package versions and model URLs
Authoritative JSON manifest defining all 6 AI feature bundles with:
- Exact pip package versions and platform-specific variants (amd64/arm64)
- pip flags (--no-deps for codeformer, --extra-index-url for torch/paddle)
- postInstall re-pins (numpy==1.26.4 after codeformer)
- Model download entries (direct URL, rembg sessions, HuggingFace snapshots)
- Bundle-to-tool mapping matching shared/features.ts

Used by install_feature.py at runtime to install bundles on demand.
2026-04-18 02:26:54 +08:00
ashim-hq e906e41ff3 feat: add shared feature bundle definitions and tool-to-bundle mapping 2026-04-18 02:24:40 +08:00
ashim-hq 204fd14ad5 docs: update plan for recent Dockerfile, bridge, and Python changes
Remove unnecessary lazy import steps (base packages are always
installed). Update Dockerfile task for cuDNN base, node-bins stage,
pip cache mounts. Add parallel model downloads and NCCL conflict
handling to install script requirements.
2026-04-18 02:15:32 +08:00
ashim-hq ae411f2d72 chore(release): 1.15.9 [skip ci] v1.15.9 2026-04-17 23:26:26 +08:00
ashim-hq 31424d4356 docs: add crash recovery and robustness to spec and plan
Atomic model downloads (.downloading suffix + rename), file-based
install lock (survives container restart), atomic JSON writes,
startup recovery sequence, frontend double-click prevention,
SSE fallback polling, disk space pre-checks.
2026-04-17 23:08:35 +08:00
Ashim 08a7ffe403 Enhance logging and error handling across tools; add full tool audit and Playwright tests
- Added model mismatch warnings in colorize, enhance-faces, and upscale routes.
- Improved error handling in colorize, enhance_faces, remove_bg, restore, and upscale scripts with detailed logging.
- Updated Dockerfile to align NCCL versions for compatibility.
- Introduced a new full tool audit script to test all tools for functionality and GPU usage.
- Created Playwright E2E tests for GPU-dependent tools to ensure proper functionality and performance.
2026-04-17 23:06:31 +08:00
ashim-hq 51f60a8269 Refactor code structure for improved readability and maintainability 2026-04-17 17:07:31 +08:00
semantic-release-bot 95af281584 chore(release): 1.15.8 [skip ci]
## [1.15.8](https://github.com/ashim-hq/ashim/compare/v1.15.7...v1.15.8) (2026-04-17)

### Bug Fixes

* copy Node.js from official image instead of apt-get install ([536125e](https://github.com/ashim-hq/ashim/commit/536125ec9fbc5758bdd3e8f0f4c44253de2231c7))
v1.15.8
2026-04-17 07:36:40 +00:00
ashim-hq 536125ec9f fix: copy Node.js from official image instead of apt-get install
Ubuntu mirrors (security.ubuntu.com) are frequently unreachable from
GitHub Actions runners, causing all amd64 Docker builds to fail.

Instead of installing Node.js via NodeSource apt repo (which requires
working Ubuntu mirrors for the initial apt-get update), copy the Node
binary and modules directly from the official node:22-bookworm image.

Also add retry with backoff to the system deps apt-get update.
2026-04-17 15:36:05 +08:00
semantic-release-bot caa2160ef8 chore(release): 1.15.7 [skip ci]
## [1.15.7](https://github.com/ashim-hq/ashim/compare/v1.15.6...v1.15.7) (2026-04-17)

### Bug Fixes

* add retry with backoff for apt-get update on CUDA base image ([3d6db5a](https://github.com/ashim-hq/ashim/commit/3d6db5a32d3f9292d5476e9bd80c1f06624fa316))
v1.15.7
2026-04-17 07:04:40 +00:00
ashim-hq 3d6db5a32d fix: add retry with backoff for apt-get update on CUDA base image
Ubuntu security mirrors can be unreachable from GitHub Actions runners.
Add a retry loop with exponential backoff (15s, 30s, 45s) around
apt-get update in the Node.js install step for the CUDA base image.
2026-04-17 15:04:03 +08:00
semantic-release-bot 23dae8d152 chore(release): 1.15.6 [skip ci]
## [1.15.6](https://github.com/ashim-hq/ashim/compare/v1.15.5...v1.15.6) (2026-04-17)

### Performance Improvements

* parallelize model downloads and switch to registry cache ([79c4ed6](https://github.com/ashim-hq/ashim/commit/79c4ed6a359b008dedeb154a55e2764ee0e3d9fa))
v1.15.6
2026-04-17 06:55:08 +00:00
ashim-hq 79c4ed6a35 perf: parallelize model downloads and switch to registry cache
- Parallelize all 14 model downloads using ThreadPoolExecutor (6 workers)
  Downloads were sequential (~30 min), now concurrent (~5-10 min)
- Switch Docker cache from type=gha to type=registry (GHCR)
  GHA cache has 10 GB limit causing blob eviction and corrupted builds
  Registry cache has no size limit and persists across runner instances
- Add pip download cache mounts to all pip install layers
  Prevents re-downloading packages when layers rebuild
2026-04-17 14:54:23 +08:00
semantic-release-bot 2fd0c00564 chore(release): 1.15.5 [skip ci]
## [1.15.5](https://github.com/ashim-hq/ashim/compare/v1.15.4...v1.15.5) (2026-04-17)

### Bug Fixes

* exclude e2e-docker tests from Vitest runner ([8df18c5](https://github.com/ashim-hq/ashim/commit/8df18c56a6c69e2a188cf0e7c97e692cd4c0e7ec))
v1.15.5
2026-04-17 06:41:05 +00:00
ashim-hq d148229d03 chore: remove docs/superpowers from tracking
Already in .gitignore — this removes the file that was committed before
the ignore rule was added.
2026-04-17 14:38:50 +08:00
ashim-hq 94db94cb28 docs: align spec with recent error handling and testing changes
Reference new parseApiError, formatZodErrors, global error handler,
and playwright.docker.config.ts infrastructure. Remove stale
partialTools concept since every tool maps to exactly one bundle.
2026-04-17 14:35:36 +08:00
ashim-hq 8df18c56a6 fix: exclude e2e-docker tests from Vitest runner
The Playwright-based Docker e2e tests use test.describe() which is
incompatible with Vitest. Exclude tests/e2e-docker/ from Vitest's
test discovery, matching the existing tests/e2e/ exclusion.
2026-04-17 14:24:14 +08:00
semantic-release-bot 3dc98374e2 chore(release): 1.15.4 [skip ci]
## [1.15.4](https://github.com/ashim-hq/ashim/compare/v1.15.3...v1.15.4) (2026-04-17)

### Bug Fixes

* verbose error handling, batch processing, and multi-file support ([3223960](https://github.com/ashim-hq/ashim/commit/32239600ae6ce30628e77e61a805ca0a167b5068))
* verbose errors, batch processing, multi-file support ([#1](https://github.com/ashim-hq/ashim/issues/1)) ([8b87cf8](https://github.com/ashim-hq/ashim/commit/8b87cf888c6194e2af427a180607d7c53a1d15b9))
v1.15.4
2026-04-17 06:21:10 +00:00
ashim-hq 8b87cf888c fix: verbose errors, batch processing, multi-file support (#1)
- Eliminate [object Object] errors across all 20+ API routes
- Global Fastify error handler with full stack traces
- Image-to-PDF auth fix (Object.entries → headers.forEach)
- OCR verbose fallbacks with engine reporting
- Split multi-file with per-image subfolders in ZIP
- Batch support for blur-faces, strip-metadata, edit-metadata, vectorize
- Docker LOG_LEVEL=debug, PYTHONWARNINGS=default
- 20 Playwright e2e tests pass against Docker container
2026-04-17 14:19:57 +08:00
ashim-hq 32239600ae fix: verbose error handling, batch processing, and multi-file support
- Replace [object Object] errors with readable messages across all 20+ API
  routes by normalizing Zod validation errors to strings (formatZodErrors)
- Add parseApiError() on frontend to defensively handle any details type
- Add global Fastify error handler with full stack traces in logs
- Fix image-to-pdf auth: Object.entries(headers) → headers.forEach()
- Fix passport-photo: safeParse + formatZodErrors, safe error extraction
- Fix OCR silent fallbacks: log exception type/message when falling back,
  include actual engine used in API response and Docker logs
- Fix split tool: process all uploaded images, combine into ZIP with
  subfolders per image
- Fix batch support for blur-faces, strip-metadata, edit-metadata,
  vectorize: add processAllFiles branch for multi-file uploads
- Docker: LOG_LEVEL=debug, PYTHONWARNINGS=default for visibility
- Add Playwright e2e tests verifying all fixes against Docker container
2026-04-17 14:15:27 +08:00
ashim-hq 2e2dbbb8e0 docs: strict one-bundle-per-tool, lock full tools, docker-only testing
Revised bundles so every tool belongs to exactly one bundle with no
partial functionality. OCR and noise-removal fully locked until
their bundle is installed. passport-photo includes mediapipe in the
Background Removal bundle. restore-photo gets its own bundle.
Development/testing always via Docker container.
2026-04-17 13:01:14 +08:00
ashim-hq 959ece3a35 docs: improve on-demand AI features spec with architectural fixes
Address single-venv strategy (avoid two-venv fragility), shared
package uninstall via reference counting, tool route registration
for uninstalled features (501 instead of 404), multi-bundle tool
graceful degradation, frontend feature status propagation, and
local development compatibility.
2026-04-17 12:13:50 +08:00
ashim-hq b9fbf9db67 docs: add design spec for on-demand AI feature downloads
Reduce Docker image from ~30GB to ~5-6GB by making AI features
downloadable post-install. Users cherry-pick feature bundles
(Background Removal, OCR, etc.) from the UI after pulling.
2026-04-17 11:31:35 +08:00
semantic-release-bot b76b9a1878 chore(release): 1.15.3 [skip ci]
## [1.15.3](https://github.com/ashim-hq/ashim/compare/v1.15.2...v1.15.3) (2026-04-16)

### Bug Fixes

* retry apt-get update on transient mirror sync errors (Acquire::Retries=3) ([cec7163](https://github.com/ashim-hq/ashim/commit/cec71632d0c868c3a413b813ff15baccc8fa8cdd))
v1.15.3
2026-04-16 19:46:27 +00:00
ashim-hq cec71632d0 fix: retry apt-get update on transient mirror sync errors (Acquire::Retries=3) 2026-04-17 03:45:42 +08:00
semantic-release-bot 59e6f2f28c chore(release): 1.15.2 [skip ci]
## [1.15.2](https://github.com/ashim-hq/ashim/compare/v1.15.1...v1.15.2) (2026-04-16)

### Bug Fixes

* use GHCR_TOKEN with write:packages scope for GHCR login ([e14414f](https://github.com/ashim-hq/ashim/commit/e14414f3061981b1454dc7d4504c64ec01db945e))
v1.15.2
2026-04-16 18:13:08 +00:00
ashim-hq e14414f306 fix: use GHCR_TOKEN with write:packages scope for GHCR login 2026-04-17 02:12:32 +08:00
ashim-hq 62f0a2a238 chore: fall back to latest tag when semantic-release finds no new commits
Allows re-triggering the release workflow after a Docker push failure
without needing new commits. If semantic-release produces no new version
the workflow now uses the latest existing git tag for the Docker build.
2026-04-17 00:21:55 +08:00
semantic-release-bot fd1eb9c781 chore(release): 1.15.1 [skip ci]
## [1.15.1](https://github.com/ashim-hq/ashim/compare/v1.15.0...v1.15.1) (2026-04-16)

### Bug Fixes

* **docker:** create /opt/models unconditionally so chown works in CI ([93ce289](https://github.com/ashim-hq/ashim/commit/93ce2891cc26afc93f01168d008927d3d356c1a9))
* **docker:** run frontend builder on BUILDPLATFORM to fix esbuild crash under QEMU ([6a3ad0d](https://github.com/ashim-hq/ashim/commit/6a3ad0d496e291b30a3f719ca079c43ce7aab705))
* resolve runtime model path mismatch for non-root Docker user ([f28792a](https://github.com/ashim-hq/ashim/commit/f28792a5ed78221f38cf2f3c80cae9f24cd7f5e3))
v1.15.1
2026-04-16 15:46:06 +00:00
ashim-hq 1de0dd12bf docs: add --name ashim to all docker run commands
Ensures the container is named ashim in Docker Desktop on all
platforms instead of getting a random name.
2026-04-16 23:45:11 +08:00
ashim-hq 1553a2445d chore: add .gitattributes to enforce LF line endings
Prevents git on Windows (core.autocrlf=true) from checking out shell
scripts and Dockerfiles with CRLF line endings, which causes a
bad interpreter error when Docker runs entrypoint.sh on Windows.
2026-04-16 23:45:07 +08:00
ashim-hq f28792a5ed fix: resolve runtime model path mismatch for non-root Docker user
Set U2NET_HOME=/opt/models/rembg so rembg models pre-downloaded at
build time as root are found at runtime by the non-root ashim user.
Without this every fresh container re-downloaded the 973 MB BiRefNet
models on first background-removal request.

Apply the same fix to PaddleOCR: download to /opt/models/paddlex and
symlink into both /root/.paddlex and /app/.paddlex so PaddleX finds
models regardless of which HOME gosu resolves at runtime.

Fall back to per-request spawning in bridge.ts when the persistent
dispatcher crashes mid-request (e.g. OOM loading a large ONNX model),
so the operation succeeds instead of surfacing "Python dispatcher
exited unexpectedly" to the user.

Improve entrypoint.sh permission warning to mention Windows bind mounts
as the likely cause.
2026-04-16 23:45:02 +08:00