Repository navigation
Desktop: unsaved-edit warning, shortcuts, tray state, activity filters and zoom (after the redesign PRs) - #55
Open
Skyfuller1303 wants to merge 255 commits into
Open
Skyfuller1303 wants to merge 255 commits into
Skyfuller1303 wants to merge 255 commits into
Conversation
The API table and error codes in the design document, the password and sign-out commands, the live-connection delay of the command line and the rollout note (an older server refuses the newer database) in the server guide. Co-Authored-By: Claude <noreply@anthropic.com>
…evice A /changes long-poll that was waiting when its device was signed out through the API now ends at once, and one that wakes for any other reason looks the device up again before it answers, so a device signed out by the command line gets 401 instead of the next change set. The live endpoint listens for revocations and looks the device up before the upgrade, so a revoke between the sign-in check and the subscription is not missed. Co-Authored-By: Claude <noreply@anthropic.com>
change_password checks, inside its transaction, that the calling device is still signed in (it may have been revoked while the password was hashed) and answers 401 if not. A password that changed meanwhile is now 409 conflict instead of 400 invalid. Both are new MetaError variants mapped in the server. set_password_hash had no caller outside a test and is removed. A new test breaks the pairing deletes with a trigger and checks that a password change, an admin reset and a revoke-others undo everything on SQLite and Postgres. Co-Authored-By: Claude <noreply@anthropic.com>
The request used bare line feeds instead of CRLF, and an answer that is not HTTP at all was reported as a bad status. Send CRLF line endings and report "not an HTTP answer" unless the first word is an HTTP version. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The long-poll now listens for revocations and looks its device up before it waits, so a revoke between the sign-in check and the wait is not missed, and looks it up once more after the change set is fetched, as the last step before the answer, so a revoke during the fetch is not answered with changes. Co-Authored-By: Claude <noreply@anthropic.com>
…changes a password change_password locked the caller's device row and then the user's row, while revoke_other_devices from another device locked its own device and then the user's, and reset_password locked the user before the devices. On Postgres two of them at once could deadlock and fail with a database error. All of them now take the user's row first (a no-op update), then the devices, then the pairings. A new scenario runs password changes, sign-outs and an admin reset at the same moment, over and over, on both databases and expects only successes, conflicts and signed-out callers. The test trigger helper also drops its Postgres function. Co-Authored-By: Claude <noreply@anthropic.com>
An answer that stopped inside the status line ("HTTP/1.1 200" and then EOF) or
filled the 64 byte buffer without a line end counted as healthy or as a bad
status. Now only a status line that ends in CRLF is read, and the other cases
are errors. Tests cover a truncated line, a line that does not end and a bare
line feed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
When the server is down, Caddy's error log entry for a failed request carried the full request URI and headers, so an invite code (/join/<code>), a query or a bearer token could end up in the log. The default log now drops request>uri and request>headers. Caddy also skips installing its internal CA into the container, which only produced an error line. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
db-init exported PGPASSWORD, which put the superuser password in the environment of the shell and of psql. It now writes a mode 0600 password file on a tmpfs, passes only PGPASSFILE and removes the file on exit. The db-init service gets a small noexec tmpfs for it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…docs The server started before Caddy and was given 172.29.215.2, the address reserved for Caddy, so Caddy failed to start. The frontend network now hands out dynamic addresses from CC_FRONTEND_POOL (the upper half by default). The docs name the new setting, the error of a data directory with the wrong owner and what was tried with S3. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
render-config.sh read only the first line of a secret file, so a database password with a second line passed the check while db-init, which reads the whole file, set a different password than the one in config.toml. The whole file is read now, one trailing line feed is allowed and any other line feed is refused. The tests cover a second line, an empty second line and the allowed trailing line feed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Compose gives a container its secrets from .env when it is created. After `docker compose run --rm secrets-init`, a later `up -d db-init` started the original secrets-init container again, which wrote the old values back. The docs and the script comment now say to recreate it (`up -d --force-recreate secrets-init`) before restarting the services that read the files. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…-in adds a device redeem consumed the invite and then updated the user, while a password reset locks the user and then deletes the invite, so the two could deadlock on Postgres. redeem now finds the invite or pairing with a plain read, locks the account, and consumes the code again under the lock; a code that is gone by then is invalid_code. create_pairing locks the account first too. A password sign-in verified the password outside any transaction, so a reset or change that committed meanwhile could be followed by a new device. sign_in_device locks the account and compares the stored hash again before it creates the device; if it differs, login answers as for a wrong password. New scenarios run redeems, a sign-in, a pairing and a reset at the same moment on both databases and expect no database error and no live device once the reset is done. Co-Authored-By: Claude <noreply@anthropic.com>
The invite delete and the pairing update now name the account the plain read found, so a code hash removed and made again for another account between that read and the lock is refused as invalid_code instead of adding a device to the wrong account. Co-Authored-By: Claude <noreply@anthropic.com>
The admin API's server overview shows whether blobs are on disk, in S3 or in memory. A backend that does not say is reported as other, so nothing outside the store crate has to change. Co-Authored-By: Claude <noreply@anthropic.com>
New request and answer types for the routes under /api/v1/admin, with a redacting Debug for everything that holds a password or a code, and the error codes account_disabled and last_admin. The confirmation is a body with an optional password today, so an optional totp_code can join it later without breaking a client. Co-Authored-By: Claude <noreply@anthropic.com>
Migration 0008 adds the purpose of an invite (invite or reset), a quota per space and a removal mark per user. The new Meta methods for the admin API each re-check the acting admin inside their own transaction and take the locks in one order, with a transaction-wide lock before the last-admin count. Disabled accounts are refused by the token check, sign-in, redeem, pairing and device creation, decided under the account's row lock. A reset code always sets a new password, signs every device out and then signs the redeeming computer in. A space's quota replaces the server-wide cap in the preflight check and in the count that follows. Co-Authored-By: Claude <noreply@anthropic.com>
The require_admin layer and the routes under /api/v1/admin: counters, a paged and searchable user list, creating accounts, changing role and quota, disabling, enabling and removing, invites, password reset codes and a user's devices. Every change asks for the acting admin's password in its body. Sign-in and join answer account_disabled for a disabled account, and a redeemed reset code ends the live connections of the devices it signed out. Documents the API, the confirmation and the rollout in the design document and the server guide. Co-Authored-By: Claude <noreply@anthropic.com>
Limiter::count added the attempt before comparing it with the maximum, so tries refused at the limit still raised the count. A refund of an attempt that had been accepted at the same moment then left the key above its limit with fewer wrong passwords than allowed. A refused try now leaves the count alone. Co-Authored-By: Claude <noreply@anthropic.com>
Disabling and enabling an account leaves the password hash as it was, so a sign-in that verified the password before the disable could still create a usable device after the enable. Users get an auth_gen counter (migration 0008) that a disable, an enable, a removal and every password change or reset bump. The sign-in reads it with the hash and sign_in_device compares both under the account's lock. The server's refunds test covers the limiter change. Co-Authored-By: Claude <noreply@anthropic.com>
Compaction asks a replica for a snapshot of a live document at an older version. Loro's SnapshotAt export checks the document out at that version, and on a long text history that needs many GiB: the live_documents test an_app_that_misbehaves_is_refused_or_dropped_and_the_rest_go_on, whose app sends 60 updates of 200,000 characters, ran out of a 16 GiB limit (itrycodinganditsbad#15). snapshot_at now exports the operations up to the version, imports them into a fresh document and takes that document's snapshot: the same history and state, with memory linear in the history. A version whose operations need others past it is refused instead of silently widened, a shallow document is refused at once (Loro can't fork one at a version), and a scratch document that Loro panicked in is let go of without being dropped. Co-Authored-By: Claude <noreply@anthropic.com>
The typed details of a security event, an event, a page of them and the last line of the NDJSON export. Every field of the details is a closed list of words or a number, and fields a later release adds are ignored. Co-Authored-By: Claude <noreply@anthropic.com>
Migration 0009 adds audit_events, with no foreign keys so that an event outlives its account. Every change that the log names writes its event in its own transaction before the commit, so a change whose event cannot be written is not made. A change that changes nothing writes none. A failed sign-in is one row per account and minute whose counter goes up, written in a transaction of its own. The values of an event are typed and come from closed lists, never from what a client typed. Old events are pruned in batches outside those transactions. Meta methods that had no way to say who asked get one: revoke_device_by takes the origin, and admin_enable_user and admin_revoke_invite take the time. Co-Authored-By: Claude <noreply@anthropic.com>
GET /account/activity, GET /admin/audit and the streamed GET /admin/audit/export; a failed sign-in is written after the answer is decided and never changes it. [audit] retention_days (1 to 3650, default 365) and audit list and audit prune on the command line. The export reads fixed pages through a bounded channel up to a fixed end of the log and ends with a line that says complete or truncated, or breaks the connection. Co-Authored-By: Claude <noreply@anthropic.com>
The routes and events in the design, and the retention, the personal data and the upgrade note in the server guide. Co-Authored-By: Claude <noreply@anthropic.com>
…in the export, reword the append-only note The account's own activity no longer shows the details (the device an admin signed out, roles, counts) of an event about another account, which a former administrator would otherwise keep seeing. The export validates before_ms like the list and applies it to every page and the probe besides its fixed end. The docs now say the append-only choice is a design decision, not that SQLite has no triggers. Co-Authored-By: Claude <noreply@anthropic.com>
aes-gcm 0.10.3 (MIT OR Apache-2.0, pure Rust) seals the stored TOTP secrets. hmac 0.13, sha1 0.11, subtle 2.6 and zeroize 1.9 were in the lockfile already as transitive packages and become direct dependencies of the server: HMAC-SHA-1 makes the codes authenticator apps speak, subtle compares them in constant time, zeroize wipes secrets. The server's tests also turn on its own test-support feature, to move its clock. Co-Authored-By: Claude <noreply@anthropic.com>
Migration 0009 adds the secret and recovery-code tables, the sign-in challenges and the invites' reset_two_factor flag. Everything that issues a device or uses a proof up locks the account's row first and checks again, under the lock, the device, the password hash, auth_gen, the account's current two-factor state and the challenge. A time step is accepted once and only a later one after it, a recovery code once, and a wrong proof is counted in a transaction of its own after the refused one rolled back, so the counters survive; ten in a row lock the second factor for 15 minutes, doubling up to 24 hours. Turning it on, off or resetting it ends what an earlier check let through (auth_gen, challenges, invite, pairings, devices). Redeeming an invite or reset code of an account that has it takes the second factor in the same transaction; the admin's reset of another account's two-factor sign-in, the reset_two_factor flag of reset codes and the admin's own two-factor state are part of the admin changes. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
The desktop app asks the agent for each suite app's shared recents when the Files tab opens or is refreshed, merges them newest first, and lists them with app, computer and time. Open hands a file that exists in the synced folder on this computer to the OS's default program; the path is joined and checked against the folder first, and programs and scripts are never started. The overview links to the page.
…ccount pages in the new layout The admin landing page gets Accounts, Storage and Audit log tabs. The Storage tab shows the server's room as one number and a bar, with a row for the server's disk and one for the store, built from the optional capacity fields of the storage overview. Every number an older server, Postgres or S3 leaves out reads as a dash or a one-line hint. The warning starts at 90 percent, the line the server uses for an account near its quota. The accounts are a table that scrolls sideways in its own area, and the account, new account and shown-code pages use the same panels.
…r capacity, and review fixes A disk store's all storage line and bar now use the store's filesystem numbers, because the accounts' stored total counts per account and can pass the disk's size. A capacity set on a disk is a second measure with its own warning, and the tags say which one is near (disk 92 %, capacity 95 %). A store with only a capacity (S3) shows the accounts' total against it, said to be an upper bound. The bars carry a label with their share, a disk store without numbers stays a disk, the hint about S3 is only shown for S3, an account shows every state it is in, and the server's own counters stay when the storage call fails.
… names its account and says whether it is destructive
…cells, segmented switcher with the audit log inside, panels for new account, invite, confirmation and account detail, storage table with flexible bars and over-capacity)
…other computers is asked for
…w their content down and are kept per account
…pened, show it in its folder Open used a deny-list of program extensions, which missed whatever the OS runs that was not on it. It is now an allow-list: the Craft suite's own formats, office documents without macros, PDF, text, images, audio, video, fonts, 3D and CAD interchange, and archives an opener only lists. A name without an extension, one ending in a bundle suffix (.app, .pkg, .mpkg, .prefPane, .workflow, .saver, .bundle, .framework, .plugin) in any path part, and on Unix any file with an exec bit are refused. Such a file shows "Open it from its folder" on the disabled Open, and a new Folder button shows the file in its folder, for any file that is here. Open also looks at the disk again when it is clicked, off the UI thread, requires the file to be here still and opens the path that was checked, so a file swapped for a link after the list was placed is not followed.
…re dropped A tab, another account, the list, the audit log, Sign out or Quit asked for while the account page holds a typed role or quota that was not saved now shows the page's inline question, "Discard the unsaved changes?", with Discard and Keep editing. The question's cancel button is a parameter of the confirmation panel now.
Ctrl+1 to Ctrl+9 go to the visible tabs in the header's order (Cmd on macOS), Ctrl+R does what the page's Refresh does, and Ctrl+F puts the cursor in the page's search field. A locked page keeps its tabs locked. A tab's hover text names its shortcut. Esc still closes a confirmation or a menu.
The tray's menu starts with a disabled line in the words of the window's footer, such as "Online · Up to date", and the line follows the state on Windows, macOS and Linux (the D-Bus menu sends a layout update when it changes).
…ivity Both tables get a menu of the kinds of event (sign-in, computers, account, admin), a menu of the computers the loaded events name (by the names the app knows) and a search of the event's words. They narrow the events already loaded and ask the server for nothing, which the page says under the controls: "Filters the loaded events".
The scale goes from 80 % to 160 % in steps of 10 %. It is kept by the model for the session: the app has no settings of its own and eframe's storage is not built in, so it starts at 100 % again.
Every name of the API's list already has its words; the compression change, which the server writes once its setting is in, now reads "Compression level changed" instead of the raw name. A test keeps the list and the labels together.
The audit log inside the admin pages' switcher had Refresh on a row of its own. It sits on the switcher's row now, as it does on the Accounts and Storage parts.
… branches changed The Computers and admin branches drew their narrow-window snapshots before the Files tab existed. The merged stack has it, so the tab row of the smallest-window snapshots differs; nothing else on those pages changed.
The question "Discard the unsaved changes?" was asked for a tab, another account, Sign out and Quit, but not when the window's close button ends the app (no tray) or when the Linux tray process's Exit does. Both are now held back like the others: the event stays pending, the window is shown for the question and nothing is carried out until Discard.
The menu's host takes the first underscore of a dbusmenu label as the mark of a keyboard shortcut and drops it. The labels (the state line and the entries) now send `_` as `__`.
…does (macOS looks at the fonts)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge after #47 (Files), #50 (Computers), #49 (Admin) and #48 (first start). The diff of this PR alone: desktop-files...desktop-extras. The branch starts from the Files branch and merges the other three, so the compare lists their commits too; the new part is the commits after those merges (listed under "What").
Small things the redesigned desktop app was missing: a warning before typed admin edits are lost, keyboard shortcuts, a state line in the tray menu, filters for the activity tables and a zoom. Two follow-ups from the redesign review are in as well. Desktop crate only (
apps/craft-cloud-desktop); no server, API or agent change.What
Online · Up to date), and it follows the state. Windows and macOS set the item's text throughtray-icon; on Linux the D-Bus menu sends a layout update when the line changes. Every platform can update the label at runtime. I could only build and run the Windows side here: the Linux and macOS code is written to the same trait and checked by reading, and the D-Bus test of the menu is updated but needsdbus-daemon, so CI will run it. Underscores in the labels are sent as__, since the D-Bus menu's host takes the first_as a shortcut mark (a pure test of the escape; the D-Bus test itself still needsdbus-daemon).persistencefeature is not built in (it would bringserdeandron), so I did not add a settings file in this PR. It starts at 100 % again.admin.compression_changedreads "Compression level changed". Every name inAUDIT_ACTIONSalready had its words; a test keeps the two together.Commits after the merges, in order: the join-password test from the integration branch, the five items above and the two follow-ups, a commit that closes a test the merge of the Computers branch left open (two test blocks met at a conflict),
rustfmt, and the snapshots. The merges' snapshot conflicts took the Computers and admin branches' images; their narrow-window ones predate the Files tab, so the last commit redraws the ones whose tab row differs.Checks
On Windows, through a memory-limited runner:
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test -p craft-cloud-desktop --lockedcargo +1.95 check --workspace --all-targets --locked(MSRV)New tests: the dirty flag and what leaves a page with unsaved edits (every kind of leaving, Keep editing, Discard, locked pages); tab numbers (visible tabs, member and admin, locked page), the page each Refresh is for, which pages have a search field; the tray's first line against the footer; the filters by kind, computer and word (every name of the API's list is of exactly one kind); the zoom limits and reset; the audit labels. Kittest: the question's three answers and Esc, Ctrl+number and Ctrl+R reaching the model, Ctrl+F taking the focus, the zoom keys, the filter controls' edits. New snapshots: the unsaved-edits question, the filtered activity tables (by kind, by computer, nothing matching, Security with a computer and a word) and the overview at 125 %.
Latest check of this head
Checked on Windows with Postgres 17, SeaweedFS 4.48 (S3) and
CRAFT_CLOUD_REQUIRE_BACKENDS=1under a 16 GiB memory limit atfec9369:cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --locked -- -D warningspass;cargo test --workspace --locked --no-fail-fast: 1946 passed, 0 failed, 2 ignored.Not in this PR