Skip to content
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Experimental.
>
> #### what's in the oven ‍‍👩🏿‍🍳?
>
> - `mltools` base.
> - This is where supporting platform for ML based features will go.
> - Our first feature!
> - Agent sandboxing/orchestration.
## 🌞 Daybook

Expand Down
10 changes: 5 additions & 5 deletions docs/DEVDOC/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

## Stack

- [ ] Good and local document classification
- [ ] Receipt parsing
- [ ] Collators
- [ ] Sync panel
- [ ] P2P
- [x] iroh
Expand All @@ -35,24 +38,21 @@
- [ ] Blobs server
- [x] Iroh blobs?
- [x] Chunked hashing for transfers
- [ ] Good and local document classification
- [ ] Receipt parsing
- [ ] Collators
- [ ] daybook_server
- [ ] Decide on wrpc vs json
- [ ] DrawerScreen
- [ ] Search FAB
- [ ] Press again to change views
- [ ] Mltools config should be per device
- [ ] Processors should only run on device that created the doc
- [ ] use a env var or an env! var to set global multipliers for our test timeouts
- [x] use a env var or an env! var to set global multipliers for our test timeouts
- [ ] File locks on repo
- [ ] Store plugin info in drawer??
- [ ] Js execution
- [ ] https://json-render.dev/ based display
- [ ] DocEditor
- [x] Progress system
- [ ] Blob download
- [x] Blob download
- [x] Overhaul bottom bar
- [ ] Change color when in different modes.
- [ ] Experiment with floating bottom bar
Expand Down
3 changes: 3 additions & 0 deletions src/am_utils_rs/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub use changes::{
};
pub use samod_core::ChangeOrigin as BigRepoChangeOrigin;

const SQLITE_POOL_ACQUIRE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(90);

#[derive(Debug, Clone)]
pub struct BigRepoConfig {
pub sqlite_url: String,
Expand Down Expand Up @@ -151,6 +153,7 @@ impl BigRepo {
.create_if_missing(true);
let state_pool = sqlx::sqlite::SqlitePoolOptions::new()
.max_connections(1)
.acquire_timeout(SQLITE_POOL_ACQUIRE_TIMEOUT)
.connect_with(connect_options)
.await
.wrap_err("failed connecting big repo sqlite")?;
Expand Down
1 change: 1 addition & 0 deletions src/daybook_cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,7 @@ mod lazy {
let (rt, stop) = daybook_core::rt::Rt::boot(
daybook_core::rt::RtConfig {
device_id: "main_TODO_XXX".into(),
startup_progress_task_id: None,
},
ctx.doc_app.document_id().clone(),
format!("sqlite://{}", ctx.layout.sqlite_path.display()),
Expand Down
74 changes: 34 additions & 40 deletions src/daybook_compose/composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.Exec
import org.gradle.api.tasks.Sync
import org.gradle.process.CommandLineArgumentProvider
import java.io.File

Expand Down Expand Up @@ -385,55 +386,48 @@ fun registerRustAndroidCopyTask(
) =
run {
val destDir = File(project.projectDir, "src/androidMain/jniLibs/$targetAbi")
val destSoFile = File(destDir, "libdaybook_ffi.so")
val destLibcxxFile = File(destDir, "libc++_shared.so")

tasks.register<Copy>(taskName) {
group = "build"
description = "Copy Rust daybook_ffi and libc++_shared.so to Android jniLibs"

dependsOn(buildTaskName)

val sourceSoFile = File(cargoTargetDir, sourceLibPath.removePrefix("target/"))
val ortLibDir = ortLibLocation?.let(::File)
val ortSharedLibs =
if (ortPreferDynamicLink && ortLibDir != null && ortLibDir.exists()) {
ortLibDir
.listFiles()
?.filter { it.isFile && it.name.contains(".so") }
?.toList()
?: emptyList()
} else {
emptyList()

tasks.register<Sync>(taskName) {
group = "build"
description = "Sync Rust daybook_ffi and native Android runtime libs to jniLibs"

dependsOn(buildTaskName)
into(destDir)

val sourceSoFile = File(cargoTargetDir, sourceLibPath.removePrefix("target/"))
doFirst {
if (!sourceSoFile.exists()) {
throw GradleException("Missing Rust Android library: ${sourceSoFile.absolutePath}")
}
}
val androidNdkRoot = System.getenv("ANDROID_NDK_ROOT")
val libcxxSourceFile =
if (!androidNdkRoot.isNullOrBlank()) ndkLibCppSharedForAbi(targetAbi, androidNdkRoot) else null
from(sourceSoFile)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

doFirst {
if (!sourceSoFile.exists()) {
throw GradleException("Missing Rust Android library: ${sourceSoFile.absolutePath}")
val androidNdkRoot = System.getenv("ANDROID_NDK_ROOT")
val libcxxSourceFile =
if (!androidNdkRoot.isNullOrBlank()) ndkLibCppSharedForAbi(targetAbi, androidNdkRoot) else null
if (libcxxSourceFile != null && libcxxSourceFile.exists()) {
from(libcxxSourceFile)
}
destDir.mkdirs()
destSoFile.delete()
destLibcxxFile.delete()

val ortLibDir = ortLibLocation?.let(::File)
val ortSharedLibs =
if (ortPreferDynamicLink && ortLibDir != null && ortLibDir.exists()) {
ortLibDir
.listFiles()
?.filter { it.isFile && it.name.contains(".so") }
?.toList()
?: emptyList()
} else {
emptyList()
}
if (ortSharedLibs.isNotEmpty()) {
logger.lifecycle(
"Copying ${ortSharedLibs.size} ORT shared libraries from ${ortLibDir?.absolutePath} (profile=${ortLibProfile ?: "unknown"})"
"Syncing ${ortSharedLibs.size} ORT shared libraries from ${ortLibDir?.absolutePath} (profile=${ortLibProfile ?: "unknown"})"
)
from(ortSharedLibs)
}
}

from(sourceSoFile)
if (libcxxSourceFile != null && libcxxSourceFile.exists()) {
from(libcxxSourceFile)
}
if (ortSharedLibs.isNotEmpty()) {
from(ortSharedLibs)
}
into(destDir)
}
}

// Debug variant: build Rust in debug mode
tasks.register<Exec>("buildRustAndroidDebug") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ class MainActivity : ComponentActivity() {
@Composable
fun AndroidApp() {
val context = LocalContext.current
val activity = context as? ComponentActivity

var hasOverlayPermission by remember { mutableStateOf(Settings.canDrawOverlays(context)) }
var permissionRefreshTick by remember { mutableIntStateOf(0) }
var shutdownRequested by remember { mutableStateOf(false) }

val permissionLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
Expand Down Expand Up @@ -109,6 +111,11 @@ fun AndroidApp() {
if (event == Lifecycle.Event.ON_RESUME) {
hasOverlayPermission = Settings.canDrawOverlays(context)
permissionRefreshTick += 1
} else if (event == Lifecycle.Event.ON_DESTROY) {
// Ignore config-change destroys; shut down only when activity is actually finishing.
if (activity?.isFinishing != false) {
shutdownRequested = true
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
}
lifecycleOwner.lifecycle.addObserver(observer)
Expand Down Expand Up @@ -229,7 +236,10 @@ fun AndroidApp() {
if (hasOverlayPermission) {
startMagicWandService(context)
}
}
},
shutdownRequested = shutdownRequested,
onShutdownCompleted = {},
autoShutdownOnDispose = true
)
}
}
Expand Down
Loading
Loading