Skip to content

Conversation

@siddhantk232
Copy link
Contributor

@siddhantk232 siddhantk232 commented Jul 1, 2025

  • launch an empty window
  • download and save the package somewhere
  • run fastn serve <package-name> in a background thread
  • go to server url in the tauri window
  • make mac .app
  • show kulfi url on fastn serve
  • change kulfi:// to fastn://
  • compile to android
  • compile to windows
  • compile to ios
  • fix: cli help info is wrong
  • fix: cmd: fastn does not launch UI

There are two ways to invoke fastn now, copied from help text:

```bash
Usage: fastn [OPTIONS] <package_name>
       fastn [OPTIONS] <COMMAND>
```

Running with `package_name` required arg will launch a native window. On
platforms where cli is not the entrypoing (phones, macos.app) the UI
will launch with a default value for `package_name`.
Break the fastn crate into a lib and a main binary. Most of the
functions in main.rs have been moved into lib.rs.

The tauir.rs deals with tauri specific stuff and contains the entrypoint
for mobile build of fastn.

The assets and configs are generated using `cargo tauri init`
The initial tauri setup is working.
Remove some crates and traits from fastn-core
The cli entrypoint conditionally launches if `package_slug` flag is
passed

The app entrypoint always launches UI with a default slug
("design-system" for now).

The app entrypoint is not tested yet. The UI launches from cli just
fine.

The default slug will be replaced with "lets-os" when it's ready.
fastn/src/lib.rs Outdated
#[tracing::instrument]
pub async fn fastn_ui(slug: &str) -> fastn_core::Result<()> {
let pkg_dir = {
let mut data_dir = dirs::data_dir().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Need some note on this. Where are these packages getting cloned? Can I run more than once instance of a package, eg checkout them twice, as each checkout will have its sqlite file for example. And if our file upload feature uploads files in the same folder, the two instances will have different files also going forward. Our editor may also modify these files etc.

Actually for every package we should have a template package that should be checked out, as that is what most people want to do.

Copy link
Contributor Author

@siddhantk232 siddhantk232 Jul 3, 2025

Choose a reason for hiding this comment

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

Need some note on this. Where are these packages getting cloned?

at https://docs.rs/dirs/latest/dirs/fn.data_dir.html. I could not find a crate that provides android and ios paths. tauri does have a fs plugin that might help. This is what I am going to look into next. Package this for all platform and see what works and what needs tweaking.

Can I run more than once instance of a package, eg checkout them twice, as each checkout will have its sqlite file for example.

No. Every invocation of fastn design-system will launch the same design-system that is downloaded on disk. We can add support for running multiple packages in future by adding aliases. Like fastn design-system my-design-sytem and future invocations will do fastn my-design-system, this will store some metadata of what was the source package for this alias and we can update the aliased package using that.

@amitu
Copy link
Contributor

amitu commented Jul 3, 2025

fastn [OPTIONS] <package_name>

Should be:

fastn [OPTIONS] [<package_name>]

(<package_name> is optional, and defaults to lets-os). How do we update our help text to make this clear?

@siddhantk232
Copy link
Contributor Author

I am focusing on running the current version as a GUI only app for mac and android. This part has a lot of unknowns (does fastn-core even compile for android/arm?) so it's better to do this first.

The code has been changed quite a lot to let the tauri window open first
and then spawn an actix server in the background. This is required for
android where we want to launch the app first and then spawn a server in
background.
This allows us to run the server inside a `tokio::spawn`. The code still
compiles with this change and it also let's us compile the android part
that was not compiling before.
@siddhantk232
Copy link
Contributor Author

The android app is stil not working. It launches and shows the loading screen and the http server runs in the background. But, the server crashes with a stack overfllow when a request is received.

The generated code is supposed to be checked in to git. There's a
gitignore file inside that ignored build artifacts.

See: tauri-apps/tauri#8323
@amitu
Copy link
Contributor

amitu commented Jul 9, 2025

I guess it's the same issue or related to fastn not working in dev builds with stack overflow error. We really have to solve this someday. Not sure how to debug tho.

@siddhantk232
Copy link
Contributor Author

I guess it's the same issue or related to fastn not working in dev builds with stack overflow error. We really have to solve this someday. Not sure how to debug tho.

Yes! After writing this comment I noticed that the tauri cli is building the crate in debug mode when I did cargo tauri android dev. There's a --release option, that'll probably work.

@amitu
Copy link
Contributor

amitu commented Jul 10, 2025

Can we find out if fastn works on Android?

@siddhantk232
Copy link
Contributor Author

Can we find out if fastn works on Android?

It probably does, I have been able to run the http server with fastn serve till now. The release build requires that I sign the apk before it'll let me run it so I'm figuring that out right now.

I might have to bring the tauri plugin back but it does not seem
necessary at this point.
The debug build does not work because fastn-core crashes with stack
overflow. Things work fine in release builds.

The catch is, tauri is forcing to sign the release apk before it can run
it in the emulator. I have create a dev signing script for this. This
will have to change and we have to create a signing key when releasing
it through github releases.
The cache_it function depends on a cache dir which it can't fetch on
android. The path to the cache dir has to come from tauri, this requires
changing params of some functions so I'm simply avoiding it for now.

FWIW we don't ever read from this cache (the code is commented out) so
caching it is just extra work with no benefits. I could be wrong tho and
we might be reading from this cache in some other place but it does not
seem like it from my quick inspection.
@siddhantk232
Copy link
Contributor Author

Can we find out if fastn works on Android?

https://youtu.be/BT9QuvR48vc It's working :)

We're moving HTTP stuff to pista_lib. The pista_lib in future will
provide more capabilities like p2p networking and sqlite store with
automerge(CRDTs) so it makes sense to have the driver like code (http
server and tauri app code) in there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants