Skip to content

Update Quickstart for Rust to v5#242

Merged
Aaron LaBeau (biozal) merged 17 commits into
mainfrom
da-138-update-v5-rust
May 27, 2026
Merged

Update Quickstart for Rust to v5#242
Aaron LaBeau (biozal) merged 17 commits into
mainfrom
da-138-update-v5-rust

Conversation

@biozal
Copy link
Copy Markdown
Contributor

@biozal Aaron LaBeau (biozal) commented Feb 17, 2026

This PR is for updating the Rust-Tui example QuickStart from v4 to v5.

Summary

  • SDK upgrade: dittolive-ditto = "4.13.1""=5.0.0" (pinned)
  • New init API: Ditto::builder().with_root().with_identity() is gone — replaced by DittoConfig::new(database_id, DittoConfigConnect::Server { url }) +
    Ditto::open_sync(config)
  • New auth refresh model: added a TokenHandler that implements DittoAuthExpirationHandler and is registered via ditto.auth()?.set_expiration_handler(...). Replaces the
    old "pass token to OnlinePlayground" flow.
  • Sync API moved to a sub-builder: every call site updated from ditto.start_sync() / ditto.is_sync_active() to ditto.sync().start() / ditto.sync().is_active() etc.
  • *_v2 suffixes dropped: register_subscription_v2, register_observer_v2, execute_v2 are now just register_subscription, register_observer, execute.
  • Removed v3 / strict-mode workaroundsdisable_sync_with_v3() and ALTER SYSTEM SET DQL_STRICT_MODE = false are no longer needed in v5.
  • Rust 2024 edition, toolchain pinned to 1.91.1 in CI.
  • Minor cleanup: dropped unused hashbrown dependency, deleted the empty src/input.rs, removed two unused fields from Todolist that were superseded by the existing
    TodoMode enum, fixed the edit dialog showing the wrong title, README rewording.

API migration cheat sheet

Before (v4.13) After (v5)
Ditto::builder().with_root().with_identity(OnlinePlayground::new(...))?.build()? `Ditto::open_sync(DittoConfig::new(database_id, DittoConfigConnect::Server { url
}).with_persistence_directory(...))?`
OnlinePlayground::new(root, app_id, token, false, Some(auth_url)) TokenHandler { token } registered via ditto.auth()?.set_expiration_handler(...)
app_id: AppId (parsed) database_id: String
ditto.start_sync() ditto.sync().start()?
ditto.stop_sync() ditto.sync().stop()
ditto.is_sync_active() ditto.sync().is_active()
ditto.disable_sync_with_v3() removed
ALTER SYSTEM SET DQL_STRICT_MODE = false removed
ditto.sync().register_subscription_v2(...) ditto.sync().register_subscription(...)
ditto.store().register_observer_v2(...) ditto.store().register_observer(...)
ditto.store().execute_v2((sql, args)) ditto.store().execute((sql, args))

Environment variable changes

Variable Status
DITTO_APP_ID Still required — value semantically renamed in docs to "Database ID"
DITTO_PLAYGROUND_TOKEN Required
DITTO_AUTH_URL Required
DITTO_WEBSOCKET_URL No longer required by docs (still read by code if set)
DITTO_CLIENT_NAME Optional, unchanged
DITTO_P2P_ENABLED Optional, unchanged

Files changed

File Change
rust-tui/Cargo.toml SDK to =5.0.0, edition 2024, drop hashbrown
rust-tui/Cargo.lock Regenerated
rust-tui/src/bin/main.rs New init flow, TokenHandler, sync API migration
rust-tui/src/bin/integration_test.rs Same migration applied to the integration binary
rust-tui/src/tui/todolist.rs API migration, removed dead create_task_title/edit_task fields, fixed edit-dialog title
rust-tui/src/tui/mod.rs Import ordering for edition 2024
rust-tui/src/term.rs Import ordering
rust-tui/src/input.rs Deleted (was unused)
rust-tui/README.md Reworded for v5 ("Database ID" terminology), dropped DITTO_WEBSOCKET_URL from required setup
.github/workflows/rust-tui-ci.yml Pin toolchain to 1.91.1 on all four jobs

Notable behavior changes

  • render_todo_prompt (formerly render_new_todo_prompt) now shows " New Todo " vs " Edit Todo " based on TodoMode. Previously the edit dialog incorrectly displayed
    "New Todo".
  • Removed dead state: Todolist::create_task_title: Option<String> and Todolist::edit_task: Option<(String, String)> were never read after the TodoMode refactor — now
    removed.
  • Stricter error propagation: ditto.start_sync() (which returned () and was discarded with _ =) is replaced by ditto.sync().start()?, so a failure to start sync now
    surfaces as an error instead of being silently swallowed. Same for disable_sync_with_v3() / strict-mode disable, which are simply gone.

Test plan

  • cargo build from rust-tui/ succeeds
  • cargo clippy --all-targets is clean
  • cargo fmt --check is clean
  • cargo run launches the TUI and connects to Big Peer (Database ID + Playground Token + Auth URL set in .env)
  • Create / edit / delete / toggle-done work end-to-end
  • s toggles sync; status indicator flips green ↔ red
Working-UI

@biozal Aaron LaBeau (biozal) added the enhancement New feature or request label Feb 17, 2026
@biozal Aaron LaBeau (biozal) marked this pull request as ready for review May 5, 2026 19:14
Copilot AI review requested due to automatic review settings May 5, 2026 19:14
@biozal Aaron LaBeau (biozal) changed the title Draft: Update Quickstart for Rust to v5 - DO NOT MERGE Update Quickstart for Rust to v5 May 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the rust-tui Ditto quickstart from Ditto SDK v4 to v5, adjusting initialization/auth flows and migrating sync/store API calls while keeping the TUI tasks app behavior intact.

Changes:

  • Bumps Rust quickstart to dittolive-ditto v5 and updates Ditto sync/store APIs (subscriptions, observers, execute, sync start/stop).
  • Refactors the TUI create/edit prompt rendering to be mode-driven.
  • Updates CI toolchain pinning and revises README instructions for setup.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
rust-tui/src/tui/todolist.rs Migrates Ditto v4 APIs to v5 and updates create/edit prompt rendering.
rust-tui/src/tui/mod.rs Minor import reorder while keeping TUI task orchestration unchanged.
rust-tui/src/term.rs Minor re-export ordering update for ratatui terminal backend/types.
rust-tui/src/input.rs Removes unused input helper module.
rust-tui/src/bin/main.rs Reworks Ditto initialization for v5 (DittoConfig, auth expiration handler, sync start/stop).
rust-tui/src/bin/integration_test.rs Migrates integration test Ditto initialization to v5 and updates sync control.
rust-tui/README.md Updates quickstart setup instructions and environment variable guidance.
rust-tui/Cargo.toml Bumps edition to 2024 and pins dittolive-ditto to v5.0.0; removes unused dependency.
rust-tui/Cargo.lock Lockfile updates for Ditto v5 and transitive dependency changes.
.github/workflows/rust-tui-ci.yml Pins Rust toolchain in CI and keeps clippy/fmt/test/integration-test steps.
Comments suppressed due to low confidence (1)

rust-tui/README.md:13

  • The README instructs copying .env.sample, but the command shown is cp .sample.env .env. In this repo the file is named .env.sample at the repo root, so the command should match or new users will fail setup.
From the repo root, copy the `.env.sample` file to `.env`, and fill in the fields with your DatabaseID, Online Playground Token, and Auth URL:

cp .sample.env .env


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust-tui/src/bin/main.rs
Comment thread rust-tui/src/bin/integration_test.rs
Comment thread rust-tui/README.md
Comment thread .github/workflows/rust-tui-ci.yml
Comment thread .github/workflows/rust-tui-ci.yml
Comment thread .github/workflows/rust-tui-ci.yml
Comment thread .github/workflows/rust-tui-ci.yml
Aaron LaBeau (biozal) and others added 3 commits May 5, 2026 14:24
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Aaron LaBeau (biozal) and others added 3 commits May 27, 2026 11:23
CI was failing because the seeded task wasn't visible within 15s of the
local peer connecting; 2786 other tasks did sync but the just-seeded one
hadn't propagated yet. Three changes:

- Bump max_attempts from 15s to 30s (matches cpp-tui's wait window).
- Explicitly call auth.login() before sync().start() so the first sync
  round always has a valid JWT, instead of racing the expiration handler
  to authenticate. Mirrors the javascript-tui v5 pattern.
- On failure, surface count + any rust-tui-seeded tasks visible locally
  to make future diagnosis less ambiguous.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The integration test relies on seeding a doc via Ditto Cloud's API v4
endpoint and then waiting for it to sync down to the local peer. The
seed step succeeds (HTTP 200) but the doc never propagates — Big Peer's
visible task set stays frozen at 2786 docs (the same snapshot since
~Oct 2025), and no rust-tui CI seed since run #167 has appeared.

This matches the pattern documented on other quickstarts
(javascript-tui, javascript-web, react-native, react-native-expo) which
all disabled their cloud-dependent tests with the same `if: false` and
the same comment, tracked as DEVX-759. Applying the same fix here so
this PR's CI can go green.

The integration_test.rs improvements from the prior commit (30s timeout,
explicit auth.login(), better diagnostics) stay in place — they're
still valuable when running locally and for when DEVX-759 is resolved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@biozal
Copy link
Copy Markdown
Contributor Author

@biozal Aaron LaBeau (biozal) merged commit ee8aec3 into main May 27, 2026
6 checks passed
@biozal Aaron LaBeau (biozal) deleted the da-138-update-v5-rust branch May 27, 2026 19:49
Brian Plattenburg (bplattenburg) added a commit that referenced this pull request May 28, 2026
Brings the Android Kotlin (#239), React Native (#267), and Rust TUI
(#242) v5 migrations into the offline branch, and re-applies the
DITTO_OFFLINE_LICENSE_TOKEN switch on top of each migrated app's new
v5 init code per docs/offline-mode-followup-for-v5-migration-prs.md.

Also pulls in PR #291 (java-server transport-config cleanup), which is
a no-op here since the offline branch already removed the same block in
commit 0231678.

Per-app notes:

- android-kotlin/TasksApplication.kt: rewritten on top of Aaron's v5
  init using DittoConfig + DittoHandler.initialize(...). Drops the
  v4-only updateTransportConfig websocket block since v5's
  serverConnect() handles it. Removes DITTO_WEBSOCKET_URL from
  BuildConfig and the env-vars required-for-online check.

- react-native/App.tsx: drops the explicit websocketURLs transport
  config (v4 leftover); the offline switch wraps the existing
  setExpirationHandler block from #267 with the offline-mode guard.
  env.d.ts loses DITTO_WEBSOCKET_URL, keeps DITTO_OFFLINE_LICENSE_TOKEN.

- react-native-expo/types/env.d.ts: keeps both DITTO_WEBSOCKET_URL and
  DITTO_OFFLINE_LICENSE_TOKEN — expo isn't migrated to v5 yet, so the
  existing transport-config block in App.tsx still references the URL.

- rust-tui/src/bin/main.rs: rewritten on top of Aaron's v5 init using
  DittoConfig::new + DittoConfigConnect::{Server, SmallPeersOnly}.
  Drops websocket_url from try_init_ditto entirely (no longer needed
  for v5 server connect). The websocket_url Cli arg stays because
  TuiTask still displays it.

Flutter #237 is still open upstream, so the flutter_app changes from the
offline branch remain on the v4 SDK path until that migration lands.

Verified builds: ./gradlew assembleDebug (android-kotlin), npx tsc
--noEmit (react-native), cargo test (rust-tui).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants