Commit Graph

26 Commits

Author SHA1 Message Date
clockwork-labs-bot f83d41c75c docs: consolidate outstanding docs fixes (#5166)
## Summary

Consolidates the outstanding docs PRs opened by `clockwork-labs-bot` /
Docs Gremlin into one reviewable PR:

- #4958
- #5085
- #5089
- #5097
- #5112
- #5114
- #5117
- #5127
- #5138
- #5165
- #5175
- #5222

This combines docs updates for:

- getting-started links
- server-issued auth token reconnect behavior in the Unity tutorial
- C++ module/client language coverage
- Unreal client ticking / `FrameTick` guidance
- C# connection callback signatures and codegen language spelling
- deterministic schedule-table sample time
- client frame ticking troubleshooting
- corrected `spacetime generate` usage for Unreal bindings
- TypeScript framework integration reference updates for SolidJS and
current React query-builder tuple usage

## Validation

- `rg -n '^(<<<<<<<|=======|>>>>>>>)' docs crates skills`
- `git diff --check origin/master...HEAD`
- `pnpm --dir docs typecheck`
- `pnpm --dir docs build`

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: rain <rain@rain.local>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2026-06-05 15:43:27 +00:00
clockwork-labs-bot 14e691bd38 Rate-limit CLI update notices (#5184)
# Description of Changes

Fixes #5183.

This rate-limits the CLI update notice so the same advertised latest
version is printed at most once every 24 hours. It keeps the existing 24
hour release lookup cache and adds backward-compatible notice metadata
to the same cache file.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1. The change is local to the lightweight update notice cache path and
only affects how often the notice is printed.

# Testing

- [x] `cargo fmt --all`
- [x] `cargo test -p spacetimedb-update update_notice`
- [x] Manual binary check with `cargo run`:

```bash
tmpdir=$(mktemp -d)
mkdir -p "$tmpdir/config"
printf '{"last_check_secs":4102444800,"latest_version":"999.0.0"}' > "$tmpdir/config/.update_check_cache"

cargo build -p spacetimedb-cli -p spacetimedb-update
SPACETIMEDB_UPDATE_MULTICALL_APPLET=spacetime cargo run -p spacetimedb-update -- --root-dir="$tmpdir" help 2> /tmp/update-notice-1.err >/tmp/update-notice-1.out
SPACETIMEDB_UPDATE_MULTICALL_APPLET=spacetime cargo run -p spacetimedb-update -- --root-dir="$tmpdir" help 2> /tmp/update-notice-2.err >/tmp/update-notice-2.out

rg "A new version of SpacetimeDB is available" /tmp/update-notice-1.err
! rg "A new version of SpacetimeDB is available" /tmp/update-notice-2.err
```

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-06-02 22:06:10 +00:00
Zeke Foppa 8641c17e4e Client binaries from DigitalOcean -> AWS (#5077)
# Description of Changes

Use an AWS bucket for client binaries instead of DigitalOcean.

Note that this will effectively hamstring the DigitalOcean mirror for
any old clients (i.e. ones before this change is released). But it's
only a mirror, and they can "fix" it by upgrading to a version with this
change.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

- [x] Manually ran the package job on this PR and confirmed that some of
the resulting URLs are indeed downloadable from the AWS urls

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-05-20 18:57:20 +00:00
euxaristia a3ecae707c fix(update): check version exists before confirming uninstall (#4774)
## Summary

Prevents `spacetime version uninstall <ver>` from showing a confirmation
prompt when the version isn't installed, which previously resulted in a
cryptic "No such file or directory (os error 2)" error after the user
confirmed.

## Changes

### Bug fix
- Check if the version directory exists **before** showing the y/N
prompt
- Return a clear error message: `v{version} is not installed`

### Tests (4 unit tests)
- `test_uninstall_nonexistent_version_errors_before_prompt` — confirms
error fires before prompt for missing versions
- `test_uninstall_current_version_errors` — confirms you can't uninstall
the active version
- `test_uninstall_current_keyword_errors` — confirms the literal string
"current" is rejected
- `test_uninstall_existing_version_with_yes` — confirms normal uninstall
flow works

## Verification

```
cargo check -p spacetimedb-update
cargo clippy -p spacetimedb-update -- -D warnings
cargo test -p spacetimedb-update uninstall
```

## Reproduction

Before this fix:
```
$ spacetime version uninstall 2.0.3
Uninstall v2.0.3? yes
Error: No such file or directory (os error 2)
```

After this fix:
```
$ spacetime version uninstall 2.0.3
Error: v2.0.3 is not installed
```

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-05-04 21:50:50 +00:00
clockwork-labs-bot 5404126aba CLI - Notify users if there's an update available (#4363)
## Summary

Adds a version update check to the `spacetimedb-update` proxy, so users
are notified when a newer version of SpacetimeDB is available.

## Changes

Adds `crates/update/src/update_notice.rs` — a lightweight update check
that runs in the proxy path before exec'ing the CLI:

- **Cache-based**: Stores the last check result in
`~/.spacetime/.update_check_cache`. Only hits the network once every 24
hours.
- **Non-blocking on cache hit**: If the cache is fresh, it's a single
file read — no network, no delay.
- **Short timeout**: When the cache is stale, makes a single HTTP
request to GitHub releases API with a 5-second timeout. Uses the same
`SPACETIME_UPDATE_RELEASES_URL` env var as `spacetime version upgrade`.
- **Best-effort**: Any failure (network, parse, file I/O) is silently
ignored. The update check never interferes with the user's command.
- **Uses semver**: Proper version comparison via the `semver` crate
(already a dependency).

## Output

When a newer version is available:
```
A new version of SpacetimeDB is available: v2.1.0 (current: v2.0.0)
Run `spacetime version upgrade` to update.
```

# Testing
- [x] I get a warning if my local version is less than 2.0.2
- [x] If I have a cached update check, I get the same error even if I
have no network connection
- [x] if the cache is old, the next command checks again
- [x] if I'm not connected and the cache is stale, I'm still able to use
the CLI

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-05 22:20:57 +00:00
Noa e3582131fe Migrate to Rust 2024 (#3802)
# Description of Changes

It'd be best to review this commit-by-commit, and using
[difftastic](https://difftastic.wilfred.me.uk) to easily tell when
changes are minor in terms of syntax but a line based diff doesn't show
that.

# Expected complexity level and risk

3 - edition2024 does bring changes to drop order, which could cause
issues with locks, but I looked through [all of the warnings that
weren't fixed
automatically](https://gistcdn.githack.com/coolreader18/80485ae5c5f82de1784229cce2febb26/raw/ba80f3fecda66ceb34f4f7ad73b98ea02d4893a2/warnings.html)
and couldn't find any issues.

# Testing

n/a; internal code change
2026-03-03 11:06:52 +00:00
Alessandro Asoni 12f931e52c Sort version output of spacetime version list (#4250)
# Description of Changes

The output of `spacetime version list` is sorted in alphabetical order,
which is not the correct semver order.
This fixes the order printed, by sorting correctly.

Example before:
```
1.11.0
1.9.0
1.3.0
1.3.1
1.1.2
1.12.0 (current)
1.0.0
```

After:
```
1.12.0 (current)
1.11.0
1.9.0
1.3.1
1.3.0
1.1.2
1.0.0
```

# API and ABI breaking changes

Not an API or ABI breaking change

# Expected complexity level and risk

1

# Testing

Ran `spacetime version list` and `spacetime version list --all` with the
new code and confirmed that the result was correctly sorted.
I additionally tested that if the latest available version was not
installed that it would show with the upgrade hint command.
2026-02-12 20:03:43 +00:00
John Detter 2ffe174388 Download from Digital Ocean if Github download fails (#4265)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

Since Github has been going down *a lot* recently, we would like to add
support for downloading from our mirror instead. This PR updates:
- The install script for both windows and linux to try the mirror if
Github is down
- The `spacetime version install ...` to install a specific version
- The `spacetime upgrade` which grabs the latest version from Github.

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

None

# Expected complexity level and risk

3 - This is touching both the windows and linux/macos install scripts
which are quite sensitive. Proper manual testing is needed on this (see
Testing below)

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

For these tests I executed the respective install script locally. To
simulate github being down I set the github download to http instead of
https and then I spun up a local server which returns 500. I also added
a `127.0.0.1 github.com` entry to my hosts file (this works on both
Windows, linux and macOS).

Linux
- [x] Tested that the Github download works normally
- [x] Tested that if Github returns a 500 the digital ocean download
works normally

The download failed here and then it correctly retried with the mirror -
I wasn't able to capture the retry part because it's part of the
progress spinner so it just updates dynamically but this was the final
output:
```
boppy@geralt:~/clockwork/SpacetimeDB$ spacetime-install
The SpacetimeDB command line tool will now be installed:
        CLI configuration directory: /home/boppy/.config/spacetime/
        `spacetime` binary: /home/boppy/.local/bin/spacetime
        directory for installed SpacetimeDB versions: /home/boppy/.local/share/spacetime/bin
        database directory: /home/boppy/.local/share/spacetime/data
Would you like to continue? yes
Downloading latest version...
  Installing v1.12.0: done!                                                                                                                                                                                                                                 The `spacetime` command has been installed as /home/boppy/.local/bin/spacetime

The install process is complete; check out our quickstart guide to get started!
        <https://spacetimedb.com/docs/getting-started>
```

Windows
- [x] Tested that the Github download works normally
- [x] Tested that if Github returns a 500 the digital ocean download
works normally

This worked as well:
```
PS C:\Users\boppy\clockwork\SpacetimeDB\crates\update> .\spacetime-install.ps1
vcruntime140.dll is already installed at C:\WINDOWS\System32\vcruntime140.dll
Downloading installer...
Download failed, trying mirror...
We have added spacetimedb to your Path. You may have to logout and log back in to reload your environment.
```

macOS
- [x] Tested that the Github download works normally
- [x] Tested that if Github returns a 500 the digital ocean download
works normally

```
boppy@Johns-Laptop update % bash ./spacetime-install.sh
Downloading installer...
curl: (22) The requested URL returned error: 500
Download failed, trying mirror...
The SpacetimeDB command line tool will now be installed:
        CLI configuration directory: /Users/boppy/.config/spacetime/
        `spacetime` binary: /Users/boppy/.local/bin/spacetime
        directory for installed SpacetimeDB versions: /Users/boppy/.local/share/spacetime/bin
        database directory: /Users/boppy/.local/share/spacetime/data
Would you like to continue? yes
Downloading latest version...
  Installing v1.12.0: done!
The `spacetime` command has been installed as /Users/boppy/.local/bin/spacetime

The install process is complete; check out our quickstart guide to get started!
        <https://spacetimedb.com/docs/getting-started>
```
2026-02-12 03:48:05 +00:00
Tyler Cloutier ce543854e9 Unifies server module library and client SDK for TypeScript (and fixes several bugs) (#3559)
# Description of Changes

This PR is a very large change to the workings of the TypeScript SDK and
as such requires a higher bar of testing than other PRs. However, it
does several important things:

1. Unifies the API of the server and client so they not only have the
same API, but they actually implement it with the same TypeScript types.
This fixes several inconsistencies between them and fixes several small
bugs as well.
2. Closes https://github.com/clockworklabs/SpacetimeDB/issues/3365
3. Closes https://github.com/clockworklabs/SpacetimeDB/issues/3431
4. Closes https://github.com/clockworklabs/SpacetimeDB/issues/3435
5. Subsumes the work done in
https://github.com/clockworklabs/SpacetimeDB/pull/3447
6. Derives all type information on the client from a single
`RemoteModule` type which vastly cleans up the correctness of type
checking on the client and helped me to find several small bugs

It accomplishes this by changing code generation of TypeScript on the
client to code generation approximately what a developer would manually
write in their module. The ultimate goal would be to allow the developer
to use the types and functions that they define on in their module
directly on the client without needing to do any code generation at all,
provided they are using TypeScript on the server and client.

https://github.com/clockworklabs/SpacetimeDB/issues/3365 is resolved by
`.build()`ing the `DbConnection` inside a React `useEffect` rather than
doing it directly in line with the render of the provider. In order to
do that we needed to not expose the `DbConnection` directly to
developers by returning a different type from `useSpacetimeDB`.
`useSpacetimeDB` now returns a `ConnectionState` object which is stored
as React state and updates when any of the fields change. This change
also resolves https://github.com/clockworklabs/SpacetimeDB/issues/3431.

https://github.com/clockworklabs/SpacetimeDB/issues/3435 was the issue
that initially lead me down the rabbit hole of unifying the server and
the client because it was nearly impossible to track down all the
various type functions and how they connect to the values that we code
generate on the server. After several hours of attempting this, I
decided to clean up the types a bit to be more uniform.

Implementing the unification between the client and the server also
necessitated fully implemented parts of the API that were fully
implemented on the server, but were broken or missing on the client.

# API and ABI breaking changes

[Unification] -> Means that this is breaking behavior for the client
SDK, but that the new behavior is identical to the server's existing
behavior

## Breaking changes:

- Table accessor names and index accessor names are converted to
camelCase on the `ctx`, so `ctx.db.foo_bar` is now `ctx.db.fooBar`

- [Unification] On the client `my_table.iter()` returns
`IterableIterator` instead of an `Array`
- [Unification] `module_bindings` now export `TypeBuilder`s for all
types instead of a `type MyType` and object `MyType`, so instead of
using `MyType` as a type directly, you need to infer the type `MyType`
-> `Infer<typeof MyType>`.
- [Unification] We no longer generate and export `MyTypeVariants` for
sum types (these are now accessed by `Infer<typeof
MyType.variants.myVariant>`)
- [Unification] `MyType.getTypeScriptAlgebraicType()` has been replaced
with `MyType.algebraicType`

- `useSpacetimeDB()` no longer takes type parameters
- `useTable()` now takes a `TableDef` parameter and type params are
inferred
- `useTable()` now just returns an `Array` directly instead of a object
with `{ rows }`

- [Unification] `ctx.reducers.createPlayer(argA, argB)` ->
`ctx.reducers.createPlayer({ argA, argB })`
- [Unification] `ctx.reducers.onCreatePlayer(ctx, argA, argB)` ->
`ctx.reducers.onCreatePlayer(ctx, { argA, argB })`
- [Unification] `ctx.reducers.removeOnCreatePlayer(ctx, argA, argB)` ->
`ctx.reducers.removeOnCreatePlayer(ctx, { argA, argB })`
- [Unification] `myTable.count(): number` -> `myTable.count(): bigint`
 
## Additive changes:
- `Infer<>` now also does `InferTypeOfRow<>` if applicable
- Added a `useReducer()` React hook
- `module_bindings` now exports a `tables` object with references to all
the `TableDef`s
- `module_bindings` now exports a `reducers` object with references to
all the `ReducerDef`s
- Added a new `MyType.create('MyVariant', ...)` function in addition to
the `MyType.MyVariant(...)` constructors (this is private)

## Notable things that did not change:
- `MyType.serialize(writer: BinaryWriter, value: Infer<typeof MyType>)`
and `MyType.deserialize(reader: BinaryReader): Infer<typeof MyType>` are
still supported exactly as before.
- The `MyType.MyVariant(...)` constructor function on sum types is still
present, but implemented with the private `MyType.create('MyVariant',
...)`. We could choose to move away from this API later if we didn't
like the variants polluting the namespace


# Expected complexity level and risk

4 - This is a deep reaching an complex change for the SDK. For the
server, it is much less deep reaching since it reuses much of the same
machinery, although it does require thorough testing there as some of
the code was modified.

This change is fully localized to TypeScript and does not touch the host
(or other languages) at all, and therefore only impacts a beta aspect of
SpacetimeDB.

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [ ] Added regression test for
https://github.com/clockworklabs/SpacetimeDB/issues/3435
- [x] Manually tested `test-app` and `test-react-router-app`
- [ ] Add test cases for camelCase-ing

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Noa <coolreader18@gmail.com>
2025-11-19 02:53:41 +00:00
Zeke Foppa 79137b5016 Fix spacetime version list not showing current version (#2680)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-23 16:52:23 +00:00
Tyler Cloutier c30cdea2af Fixed compile errors and warnings on Windows (#2646) 2025-05-21 22:32:29 +00:00
Zeke Foppa 6ebb2abe34 spacetimedb-update self-install fails if the install fails. (#2642)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-04-21 18:47:25 +00:00
Zeke Foppa 2d0b4127c2 CI - Test spacetimedb-update self-install (#2637)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-04-19 01:44:20 +00:00
John Detter ae85f64bcb Fix error with the install script (#2635)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2025-04-18 18:51:48 +00:00
John Detter 84ac8119e1 Fix quickstart link (#2346)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2025-03-05 17:29:30 +00:00
Noa 51c833b95e Remove errant backslash that got into the 'please add to path' message (#2333) 2025-03-03 18:17:29 +00:00
Noa 43b4085e22 Print a message with a shell line to add bindir to PATH (#2327) 2025-02-28 20:33:23 +00:00
Noa 956b4f8e5b Add dockerfile for cli (#2312) 2025-02-27 20:24:43 +00:00
Tyler Cloutier e5cdda78ce Removed the EULA check in the CLI (#2315) 2025-02-27 18:44:35 +00:00
Noa b8ebe42484 Fix self-replace on windows (#2294) 2025-02-26 16:42:59 +00:00
Noa 30ba0f9d97 Use fixed term width for cli help test (#2293) 2025-02-21 20:18:26 +00:00
Noa 27a2afa2b8 Update install script (#2265)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2025-02-21 06:10:31 +00:00
Noa e6775eb93a Finish spacetimedb-update functionality (#2126) 2025-02-06 20:32:46 +00:00
Noa fbb5c9ecdc Fix ctrl-c handling (#2200) 2025-02-04 20:08:22 +00:00
Noa e47a8d796f Run smoketests on windows in ci (#2129) 2025-01-16 21:43:38 +00:00
Noa c24042609e Split binaries (#2011) 2025-01-15 18:45:14 +00:00