Skip to content

Show "Claudiu is already running" instead of starting a second app on one data folder - #118

Merged
m4rocks merged 1 commit into
mainfrom
one-app-per-data-folder
Nov 17, 2026
Merged

m4rocks merged 1 commit into
mainfrom
one-app-per-data-folder

Conversation

@m4rocks

@m4rocks m4rocks commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Summary

Two Claudiu apps on the same data folder raced each other. Both rewrote state.json, and whichever polled first took a session's request files, so an attach_github call made in one app could vanish in the other.

Startup now takes an OS file lock on claudiu.lock in the data folder, held until the app exits. A second app that can't get it within 5 seconds shows a small "Claudiu is already running" window and quits when it is closed. The wait covers an update or restart, where the new app starts while the old one is still closing. A debug build still runs beside the installed app, since it has its own data folder.

Evidence

  • New test a_second_app_cannot_take_a_data_folder_until_the_first_lets_go: a second lock on the same folder fails, another folder is free, and the folder is free again once the first lock is dropped.
  • Two debug builds started one after the other on Windows: the first opened as usual, and the second showed only the notice and exited when it was closed. The installed app, which has its own folder, kept running.
  • cargo test: 495 passed, 0 failed.

Screenshot of the notice (not attached, since gh can't upload images): "Claudiu is already running / Another Claudiu window uses the same data folder. Switch to it instead. [OK]".

Not checked: macOS and Linux, and a real Velopack update restart.

Risk

If an update's new app starts more than 5 seconds before the old one exits, it shows the notice instead of opening, and opening Claudiu again fixes it. If the lock can't be taken at all, for example on a read-only disk, startup goes on as before. Revert this commit to undo it.

Closes #84

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
claudiu Ready Ready Preview Nov 17, 2026 10:13am UTC

… one data folder

Two Claudiu apps on the same data folder raced each other: both rewrote state.json, and whichever polled first took a session's request files, so an attach_github call made in one app could vanish in the other. Startup now takes a lock on `claudiu.lock` in the data folder. A second app that can't get it within 5 seconds shows a small window saying Claudiu is already running, then quits when it is closed. The wait covers an update or restart, where the new app starts while the old one is still closing.

A debug build still runs beside the installed app, since it has its own data folder.

Closes #84
@m4rocks
m4rocks force-pushed the one-app-per-data-folder branch from a14d975 to 0c4831a Compare November 17, 2026 10:13
@m4rocks
m4rocks merged commit a37d6df into main Nov 17, 2026
5 checks passed
@m4rocks
m4rocks deleted the one-app-per-data-folder branch November 24, 2026 22:38

This branch was successfully deployed

1 active deployment
Preview — 0c4831a3 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two running Claudiu apps race on the shared data folder

1 participant