feat: init desktop app

This commit is contained in:
Maze Winther 2026-03-27 21:15:00 +01:00
parent f635403108
commit 8918a87c33
12 changed files with 7827 additions and 310 deletions

View File

@ -20,6 +20,7 @@ Thank you for your interest in contributing to OpenCut! This document provides g
- [Bun](https://bun.sh/docs/installation)
(for `npm` alternative)
- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/)
- Rust toolchain (only needed for `apps/desktop`)
> **Note:** Docker is optional, but it's essential for running the local database and Redis services. If you're planning to contribute to frontend features, you can skip the Docker setup. If you have followed the steps below in [Setup](#setup), you're all set to go!
@ -49,6 +50,10 @@ Thank you for your interest in contributing to OpenCut! This document provides g
> 1. Upgrade to a recent npm version (v9 or later), which has full workspace protocol support.
> 2. Use an alternative package manager such as **bun** or **pnpm**.
### Desktop setup
Only needed if you're working on `apps/desktop`. See [`apps/desktop/README.md`](../apps/desktop/README.md) — it's a two-step process: Rust toolchain first via `script/setup-rust`, then desktop native dependencies via `apps/desktop/script/setup`.
## What to Focus On
**🎯 Good Areas to Contribute:**
@ -140,6 +145,10 @@ If you're unsure whether your idea falls into the preview category, feel free to
5. Run database migrations: `bun run db:migrate`
6. Start the development server: `bun run dev`
### Desktop
Working on `apps/desktop`? See [`apps/desktop/README.md`](../apps/desktop/README.md) for setup. Web-only contributors can ignore this entirely.
## How to Contribute
### Reporting Bugs
@ -158,11 +167,13 @@ If you're unsure whether your idea falls into the preview category, feel free to
1. Create a new branch: `git checkout -b feature/your-feature-name`
2. Make your changes
3. Navigate to the web app directory: `cd apps/web`
4. Run the linter: `bun run lint`
5. Format your code: `bunx biome format --write .`
6. Commit your changes with a descriptive message
7. Push to your fork and create a pull request
3. Run the relevant checks for the area you touched:
- Web changes: from `apps/web`, run `bun run lint` and `bunx biome format --write .`
- Desktop changes: run `./apps/desktop/script/setup` if your environment isn't set up yet
4. Commit your changes with a descriptive message
5. Push to your fork and create a pull request
## Code Style

2
.gitignore vendored
View File

@ -20,3 +20,5 @@ bun.lockb
.cursor/
.open-next
target/

7215
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

5
Cargo.toml Normal file
View File

@ -0,0 +1,5 @@
[workspace]
resolver = "2"
members = [
"apps/desktop",
]

View File

@ -40,6 +40,7 @@ Thanks to [Vercel](https://vercel.com?utm_source=github-opencut&utm_campaign=oss
## Project Structure
- `apps/web/` Main Next.js web application
- `apps/desktop/` Native desktop app (in progress)
- `src/components/` UI and editor components
- `src/hooks/` Custom React hooks
- `src/lib/` Utility and API logic
@ -86,6 +87,12 @@ The application will be available at [http://localhost:3000](http://localhost:30
The `.env.example` has sensible defaults that match the Docker Compose config — it should work out of the box.
### Desktop setup
Desktop is opt-in. If you're only working on the web app, skip this entirely.
If you want to get ready for `apps/desktop`, see [`apps/desktop/README.md`](apps/desktop/README.md). It's a two-step setup: Rust toolchain first, then desktop native dependencies.
### Self-Hosting with Docker
To run everything (including a production build of the app) in Docker:
@ -110,6 +117,7 @@ See our [Contributing Guide](.github/CONTRIBUTING.md) for detailed setup instruc
- Fork the repo and clone locally
- Follow the setup instructions in CONTRIBUTING.md
- Working on `apps/desktop`? See [`apps/desktop/README.md`](apps/desktop/README.md) for setup
- Create a feature branch and submit a PR
## License

11
apps/desktop/Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "opencut-desktop"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "opencut"
path = "src/main.rs"
[dependencies]
gpui = "0.2.2"

47
apps/desktop/README.md Normal file
View File

@ -0,0 +1,47 @@
# Desktop
The native desktop app, built with [GPUI](https://gpui.rs).
## Getting started
**1. Install Rust:**
```bash
# Linux / macOS / WSL
./script/setup-rust
```
```powershell
# Windows
powershell -ExecutionPolicy Bypass -File .\script\setup-rust.ps1
```
Both scripts skip installation if Rust is already present. On Linux/macOS/WSL only: after a fresh install, reload your shell with `source "$HOME/.cargo/env"`
**2. Install native dependencies:**
```bash
# Linux / macOS / WSL
./apps/desktop/script/setup
```
```powershell
# Windows
powershell -ExecutionPolicy Bypass -File .\apps\desktop\script\setup.ps1
```
**3. Run:**
```bash
cargo run -p opencut-desktop
```
## Platform notes
**Linux:** supports apt (Debian/Ubuntu/Mint), dnf (Fedora/RHEL), and pacman (Arch).
**macOS:** installs Xcode Command Line Tools if missing.
**Windows:** the setup script checks for Visual Studio Build Tools. If missing, it prints the install link.
**WSL:** runs the same scripts as Linux. Window rendering works via WSLg on Windows 11 and Windows 10 22H2+. If you're on an older build, test on the host instead.

110
apps/desktop/script/setup Normal file
View File

@ -0,0 +1,110 @@
#!/usr/bin/env bash
# Installs the native system libraries GPUI needs to compile on Linux/macOS.
# Run script/setup-rust first if you don't have Rust installed yet.
set -euo pipefail
if [ "$(id -u)" -eq 0 ]; then
maysudo=''
else
maysudo="$(command -v sudo || command -v doas || true)"
fi
# Ubuntu, Debian, Mint, Pop!_OS, Kali, Raspbian, etc.
apt=$(command -v apt-get || true)
if [[ -n $apt ]]; then
deps=(
curl
build-essential
pkg-config
gcc
g++
make
libasound2-dev
libfontconfig-dev
libglib2.0-dev
libssl-dev
libva-dev
libvulkan1
libwayland-dev
libx11-xcb-dev
libxkbcommon-x11-dev
libzstd-dev
libsqlite3-dev
)
$maysudo "$apt" update
$maysudo "$apt" install -y "${deps[@]}"
echo "Desktop native dependencies installed."
exit 0
fi
# Fedora, RHEL, CentOS, Alma, etc.
dnf=$(command -v dnf || true)
if [[ -n $dnf ]]; then
deps=(
gcc
gcc-c++
make
pkg-config
alsa-lib-devel
fontconfig-devel
glib2-devel
openssl-devel
libva-devel
vulkan-loader
wayland-devel
libxcb-devel
libxkbcommon-x11-devel
libzstd-devel
sqlite-devel
curl
)
$maysudo "$dnf" install -y "${deps[@]}"
echo "Desktop native dependencies installed."
exit 0
fi
# Arch, Manjaro, etc.
pacman=$(command -v pacman || true)
if [[ -n $pacman ]]; then
deps=(
gcc
make
pkgconf
alsa-lib
fontconfig
glib2
openssl
libva
vulkan-loader
wayland
libxcb
libxkbcommon-x11
zstd
sqlite
curl
)
$maysudo "$pacman" -Syu --needed --noconfirm "${deps[@]}"
echo "Desktop native dependencies installed."
exit 0
fi
# macOS
if [[ "$(uname)" == "Darwin" ]]; then
if ! xcode-select -p &> /dev/null; then
echo "Installing Xcode Command Line Tools..."
xcode-select --install
echo "Re-run this script after the Xcode install completes."
exit 0
fi
echo "Desktop native dependencies installed."
exit 0
fi
echo "Unsupported platform. See apps/desktop/README.md for manual setup instructions."
exit 1

View File

@ -0,0 +1,27 @@
# Installs the native build tools GPUI needs to compile on Windows.
# Run script/setup-rust.ps1 first if you don't have Rust installed yet.
$ErrorActionPreference = "Stop"
function Check-VSBuildTools {
$vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
if (-not (Test-Path $vswhere)) {
return $false
}
$result = & $vswhere -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath
return $result -and $result.Trim().Length -gt 0
}
if (-not (Check-VSBuildTools)) {
Write-Output ""
Write-Output "Visual Studio Build Tools with 'Desktop development with C++' not found."
Write-Output ""
Write-Output "Install it from: https://visualstudio.microsoft.com/visual-cpp-build-tools/"
Write-Output "Check the 'Desktop development with C++' workload during setup, then re-run this script."
Write-Output ""
exit 1
}
Write-Output "Desktop native dependencies ready."

41
apps/desktop/src/main.rs Normal file
View File

@ -0,0 +1,41 @@
use gpui::{
App, Application, Bounds, Context, SharedString, Window, WindowBounds, WindowOptions, div,
prelude::*, px, rgb, size,
};
struct AppWindow {
title: SharedString,
}
impl Render for AppWindow {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.size_full()
.bg(rgb(0x0f0f0f))
.flex()
.justify_center()
.items_center()
.text_xl()
.text_color(rgb(0xffffff))
.child(self.title.clone())
}
}
fn main() {
Application::new().run(|cx: &mut App| {
let bounds = Bounds::centered(None, size(px(1280.), px(720.)), cx);
cx.open_window(
WindowOptions {
window_bounds: Some(WindowBounds::Windowed(bounds)),
..Default::default()
},
|_, cx| {
cx.new(|_| AppWindow {
title: "OpenCut".into(),
})
},
)
.unwrap();
cx.activate(true);
});
}

17
script/setup-rust Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Installs the Rust toolchain via rustup.
# Run this before any platform-specific setup script.
set -euo pipefail
CARGO_BIN="$HOME/.cargo/bin/rustup"
if command -v rustup &> /dev/null || [ -f "$CARGO_BIN" ]; then
echo "rustup already installed"
exit 0
fi
echo "Installing rustup..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "Rust installed. Reload your shell: source \"\$HOME/.cargo/env\""

23
script/setup-rust.ps1 Normal file
View File

@ -0,0 +1,23 @@
# Installs the Rust toolchain via rustup.
# Run this before any platform-specific setup script.
$ErrorActionPreference = "Stop"
if (Get-Command cargo -ErrorAction SilentlyContinue) {
Write-Output "rustup already installed: $(rustup --version)"
exit 0
}
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
$rustupExe = "$cargoHome\bin\rustup.exe"
if (-not (Test-Path $rustupExe)) {
Write-Output "Installing rustup..."
$installer = "$env:TEMP\rustup-init.exe"
Invoke-WebRequest -Uri "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe" -OutFile $installer
& $installer -y --default-toolchain stable
Remove-Item -Force $installer
}
$env:PATH = "$cargoHome\bin;$env:PATH"
Write-Output "Rust installed: $(& rustc --version)"