Task 17: iced application shell and login screen (#17) #53
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/17-ui-shell-login"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this builds
fluxer_ui::run(snapshot: watch::Receiver<Arc<App>>, events: mpsc::Sender<CoreEvent>) -> iced::Result: the iced application. It draws the latest snapshot, sends user actions into the runtime's event queue (try_send, falling back to an awaited send when the queue is full), and exits when the snapshot channel or the queue closes. Tab / Shift+Tab move the keyboard focus; the login (or code) field is focused when its step opens.UiMessage { Core, Snapshot, Login, Main, Settings, Window }andview(&App, &Local)routing byapp.session.auth. Until Task 18, a logged-in session shows a placeholder (user name, connection state, "Log out").screens::login:model(&App) -> LoginModel { instance, show_totp, error_text, busy, status_text },view(&LoginModel, &Form),update(&mut Form, Message, &App) -> Vec<UserAction>emittingSetInstance(only when the instance field was edited to another URL),SubmitLogin,SubmitTotp, andLogoutfor "Back to sign-in". Enter submits from every field. One text perAuthError; the captcha one is the plan's sentence (login::CAPTCHA_MESSAGE, Review Focus 3).widgets::buttonandwidgets::text_inputwith the metrics of the web app'sButton.module.cssandFormInput.module.css; the card followsLoginPage.module.css,AuthLoginEmailPasswordForm.module.cssandMfaScreen.module.css. Colours are tokens only.apps/fluxer/src/main.rs: starts the effect runtime on its own tokio runtime and runs the window on the main thread. Closing the window, Ctrl-C or the runtime stopping all end inHandle::shutdown.How it was tested
crates/fluxer-ui/tests/login_view.rs(13 tests), written first and seen failing: the two the plan names (login_view_shows_totp_field_when_awaiting_totp,login_view_shows_captcha_message) drive the real store throughSubmitLogin, thewell_known.json/login_mfa.jsonfixtures and anEffectFailed(CaptchaRequired); the rest cover everyAuthErrortext, the busy state, the instance prefill from the loaded settings, whatSubmitemits (and does not emit with missing or invalid fields, or while busy), the TOTP step, and thatDebugoutput never contains the password.fluxer --devserverlogs in as demo, "Log out" shows the login screen with the devserver's URL prefilled, logging in asmfaopens the TOTP step,111111shows "Invalid or expired code.",000000logs in and the gateway reaches ready; Ctrl-C exits with status 0.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally.Screenshots of the native client:
docs/screenshots/login.png,docs/screenshots/login-totp.png. There is no Electron side-by-side: the web app's login is a multi-step flow (instance, method, credentials) against a live instance, which this task may not touch.Deviations from the plan
screens::main::Messageandscreens::settings::Messageare empty placeholder enums declared inline inscreens/mod.rs, so thatUiMessagehas the shape the plan gives; Tasks 18 and 22 replace them with their modules.WindowEventis not specified by the plan; it is{ Focused, Unfocused, FocusNext, FocusPrevious, Close }.Closeis what the snapshot stream emits when the runtime is gone.LoginModel::instancecomes fromapp.session.instance, not fromapp.settings: the session takes the settings' instance at the startup load and--instance/--devserveroverride it, so it is the URL a login really goes to.apps/fluxer/Cargo.toml(+fluxer-ui),crates/fluxer-ui/Cargo.toml(+fluxer-core,tokiofor the channel types ofrun,secrecy,url; dev:fluxer-proto,serde_json,uuid; all already workspace dependencies), both READMEs,docs/screenshots/.UserActionfor it yet.fluxer_ui::runfails and it exits with status 1 after shutting the runtime down.Stacked on: task/16-ui-theme-fonts-icons, task/14-app-runtime
Closes #17
🤖 Generated with Claude Code
Independent review: Task 17 (ui-shell-login) at
9e1bc0aScope:
git diff 8bef1dd..origin/task/17-ui-shell-login(17 files).1. Tests named by the plan — OK
login_view_shows_totp_field_when_awaiting_totp: drives the real store withlogin_mfa.jsonand assertsmodel.show_totp.login_view_shows_captcha_message: fails the login effect withCoreError::CaptchaRequired, assertserror_text == CAPTCHA_MESSAGE, pins the constant to the plan's exact string, and asserts the form is no longer busy and not on the TOTP step.2. Interfaces — OK
fluxer_ui::run(snapshot: watch::Receiver<Arc<App>>, events: mpsc::Sender<CoreEvent>) -> iced::Result,UiMessage { Core, Snapshot, Login, Main, Settings, Window },view(app: &App, local: &Local) -> Element<UiMessage>routing onapp.session.auth,screens::login::model(&App) -> LoginModel { show_totp, error_text, .. }all exist as written. Login emitsSetInstance(only when changed, beforeSubmitLogin),SubmitLogin,SubmitTotp; Enter submits from every field.3. Invariants — OK
fluxer-uidoes no I/O: tokio is used for thewatch/mpsctypes only (workspace features arert-multi-thread, macros, sync, time; no net/fs). Nounwrap/expect/panic!in the new non-test code.fluxer-coreis untouched. No secrets: the password is held in the view-localForm, redacted inDebugfor bothFormandMessage, cleared onLoggedIn; the only token-shaped string in the tree is the existing scrubbed fixture.4. Review Focus 3 (captcha) — OK. Clear message, form re-enabled, no hang; covered by the test above.
5.
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin the review worktree: all steps passed (remote runners not checked).Findings
apps/fluxer/src/main.rssupervise(): when the runtime stops on its own, the UI exits viaWindowEvent::Closeandmainsendswindow_closed; the supervisor'sselect!can then seewindow_closedandsnapshots.changed()ready together and pick the former at random, returningtrue(exit 0) instead of the documented exit 1. Usebiased;with thechanged()arm first, or re-checksnapshots.has_changed().is_err()after the loop.crates/fluxer-ui/src/screens/login.rsForm::sync: the password stays in the form while on the TOTP step and after "Back to sign-in" (intended, mirrors the web app), but the instance field keeps the user's raw text after a successfulSetInstance; harmless, noted only becauseLoginModel.instanceis then never shown again for that window.docs/screenshots/login.pngandlogin-totp.png. Window size/position is read but not persisted back (noUserActionfor it); the non-captcha error wording is the implementer's own. These want afollow-upissue rather than a change here.screens::main::Message/screens::settings::Messageare empty placeholder enums inscreens/mod.rs; Tasks 18 and 22 must replace the inline modules (expected by the plan, flagged so those tasks do not add a second definition).Verdict: APPROVE — zero blocking findings, local ci green.