Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/apps/desktop/src/api/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl AppState {
.map(|workspace| workspace.root_path);

if let Some(workspace_path) = initial_workspace_path.clone() {
bitfun_core::infrastructure::set_workspace_path(Some(workspace_path.clone()));
miniapp_manager
.set_workspace_path(Some(workspace_path.clone()))
.await;
Expand Down
12 changes: 5 additions & 7 deletions src/apps/desktop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,13 +766,11 @@ fn start_event_loop_with_transport(

if !batch.is_empty() {
for envelope in batch {
let router = event_router.clone();
let env_clone = envelope.clone();
tokio::spawn(async move {
if let Err(e) = router.route(env_clone).await {
log::warn!("Internal event routing failed: {:?}", e);
}
});
// Route to internal subscribers (e.g. RemoteSessionStateTracker)
// sequentially so that text chunks are appended in order.
if let Err(e) = event_router.route(envelope.clone()).await {
log::warn!("Internal event routing failed: {:?}", e);
}

if let Err(e) = transport.emit_event("", envelope.event).await {
log::error!("Failed to emit event: {:?}", e);
Expand Down
5 changes: 1 addition & 4 deletions src/apps/relay-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ WebSocket relay server for BitFun Remote Connect. Bridges desktop (WebSocket) an
```bash
# One-click deploy
bash deploy.sh

# With mobile web client rebuild
bash deploy.sh --build-mobile
```

### What URL should I fill in BitFun Desktop?
Expand Down Expand Up @@ -123,7 +120,7 @@ Only desktop clients connect via WebSocket. Mobile clients use the HTTP endpoint

1. Clone the repository
2. Navigate to `src/apps/relay-server/`
3. Run `bash deploy.sh --build-mobile`
3. Run `bash deploy.sh`
4. Configure DNS/firewall as needed
5. In BitFun desktop, select "Custom Server" and enter your server URL

Expand Down
27 changes: 4 additions & 23 deletions src/apps/relay-server/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env bash
# BitFun Relay Server — one-click deploy script.
# Usage: bash deploy.sh [--build-mobile] [--skip-build] [--skip-health-check]
# Usage: bash deploy.sh [--skip-build] [--skip-health-check]
#
# Prerequisites: Docker, Docker Compose

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"

BUILD_MOBILE=false
SKIP_BUILD=false
SKIP_HEALTH_CHECK=false

Expand All @@ -21,7 +19,6 @@ Usage:
bash deploy.sh [options]

Options:
--build-mobile Build mobile-web static files before deploy
--skip-build Skip docker compose build, only restart services
--skip-health-check Skip post-deploy health check
-h, --help Show this help message
Expand All @@ -46,7 +43,6 @@ check_docker_compose() {

for arg in "$@"; do
case "$arg" in
--build-mobile) BUILD_MOBILE=true ;;
--skip-build) SKIP_BUILD=true ;;
--skip-health-check) SKIP_HEALTH_CHECK=true ;;
-h|--help)
Expand All @@ -65,31 +61,16 @@ echo "=== BitFun Relay Server Deploy ==="
check_command docker
check_docker_compose

# Build mobile web static files if requested
if [ "$BUILD_MOBILE" = true ] && [ -d "$PROJECT_ROOT/src/mobile-web" ]; then
check_command npm
echo "[1/3] Building mobile web client..."
cd "$PROJECT_ROOT/src/mobile-web"
npm ci
npm run build
mkdir -p "$SCRIPT_DIR/static"
cp -r dist/* "$SCRIPT_DIR/static/"
cd "$SCRIPT_DIR"
echo " Mobile web built → $SCRIPT_DIR/static/"
else
echo "[1/3] Skipping mobile web build (use --build-mobile to include)"
fi

# Build and start containers
cd "$SCRIPT_DIR"
if [ "$SKIP_BUILD" = true ]; then
echo "[2/3] Skipping Docker build (--skip-build)"
echo "[1/2] Skipping Docker build (--skip-build)"
else
echo "[2/3] Building Docker images..."
echo "[1/2] Building Docker images..."
docker compose build
fi

echo "[3/3] Starting services..."
echo "[2/2] Starting services..."
docker compose up -d

if [ "$SKIP_HEALTH_CHECK" = false ]; then
Expand Down
5 changes: 4 additions & 1 deletion src/apps/relay-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ pub fn build_relay_router(
.route("/health", get(routes::api::health_check))
.route("/api/info", get(routes::api::server_info))
.route("/api/rooms/:room_id/pair", post(routes::api::pair))
.route("/api/rooms/:room_id/command", post(routes::api::command))
.route(
"/api/rooms/:room_id/command",
post(routes::api::command).layer(DefaultBodyLimit::max(10 * 1024 * 1024)),
)
.route(
"/api/rooms/:room_id/upload-web",
post(routes::api::upload_web).layer(DefaultBodyLimit::max(10 * 1024 * 1024)),
Expand Down
3 changes: 2 additions & 1 deletion src/apps/relay-server/src/routes/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ pub async fn websocket_handler(
ws: WebSocketUpgrade,
State(state): State<AppState>,
) -> Response {
ws.on_upgrade(move |socket| handle_socket(socket, state))
ws.max_message_size(64 * 1024 * 1024)
.on_upgrade(move |socket| handle_socket(socket, state))
}

async fn handle_socket(socket: WebSocket, state: AppState) {
Expand Down
Loading