Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
ef532b3
refactor(scripts/build-flutter-desktop): 分离桌面包组装与归档
SXP-Simon Nov 23, 2026
904c7c9
refactor(crates/handwriting-server): 分离请求校验和渲染任务输出
SXP-Simon Nov 23, 2026
f13c59f
test(crates/handwriting-server): 按服务契约归类测试
SXP-Simon Nov 23, 2026
9c6a039
refactor(crates/handwriting-core): 分离 DOCX 容器读取和 Word 文本解析
SXP-Simon Nov 23, 2026
e169272
refactor(crates/handwriting-core): 提取行内根式与分式识别
SXP-Simon Nov 23, 2026
db37d57
refactor(crates/handwriting-core): 集中段落缩进与换行规则
SXP-Simon Nov 23, 2026
a00e2b2
refactor(app/lib): 由独立模型管理逐字微调历史
SXP-Simon Nov 23, 2026
efa4d7e
refactor(crates/handwriting-core): 分离逐字合成和删除线处理
SXP-Simon Nov 23, 2026
567462f
refactor(crates/handwriting-core): 集中电路支路符号与标签绘制
SXP-Simon Nov 23, 2026
4c84b9d
refactor(crates/handwriting-core): 分离信纸横线跟踪与逐列校正
SXP-Simon Nov 23, 2026
c099565
refactor(app/updater): 隔离平台进程身份读取与精确停止
SXP-Simon Nov 23, 2026
d2cdbc3
refactor(app/updater): 明确安装包校验与写入边界
SXP-Simon Nov 23, 2026
012f069
refactor(app/screens): 独立管理编辑器文本整理作业
SXP-Simon Nov 23, 2026
94726cc
refactor(crates/handwriting-bridge): 分离原生任务工作线程和结果发布
SXP-Simon Nov 23, 2026
e4fcd9e
refactor(app/view_models): 集中逐字预览的拖动和角点命中
SXP-Simon Nov 23, 2026
61596ae
refactor(crates/panache-mcp): 分离稿件保存和预览请求
SXP-Simon Nov 23, 2026
9620dda
refactor(app/widgets): 分离更新卡片的状态文案与操作
SXP-Simon Nov 23, 2026
93d8f88
refactor(app/lib): 分离 LaTeX 语法节点与文本转换
SXP-Simon Nov 23, 2026
6a735b3
refactor(crates/handwriting-core): 集中电路元件选项解析
SXP-Simon Nov 23, 2026
9047e69
refactor(website): 分开静态资源、双语索引与页面生成
SXP-Simon Nov 23, 2026
a054563
refactor(app/widgets): 按职责组织工作台设置与布局
SXP-Simon Nov 23, 2026
3070b83
refactor(app/widgets): 拆开预览分页、缩放与精编绘制
SXP-Simon Nov 23, 2026
e8f3e78
refactor(crates/panache-mcp): 分离逐字调整计算与版本提交
SXP-Simon Nov 23, 2026
aff544c
refactor(app/lib): 按区段组织数学和 Markdown 文本扫描
SXP-Simon Nov 23, 2026
1e76a28
refactor(crates/handwriting-core): 独立采样数学笔画的字体轮廓
SXP-Simon Nov 23, 2026
86664de
refactor(app/models): 集中渲染参数定义与旧草稿恢复规则
SXP-Simon Nov 23, 2026
79834de
refactor(app/lib): 按图片格式拆分纸张 EXIF 定位
SXP-Simon Nov 23, 2026
1063d64
refactor(scripts): 统一移动平台 ABI 和原生构建参数
SXP-Simon Nov 23, 2026
f83dbda
refactor(app/updater): 明确安装准备阶段的事务顺序
SXP-Simon Nov 23, 2026
1662a09
refactor(app/view_models): 收拢生成任务阶段与有效性检查
SXP-Simon Nov 23, 2026
cf5067c
refactor(app/services): 抽取纸张识别响应与几何校正
SXP-Simon Nov 23, 2026
7d3396d
refactor(crates/handwriting-core): 划分 PDF 原页文字提取与背景重写
SXP-Simon Nov 23, 2026
d93b97e
chore(scripts): 提供可复测的 Dart 结构审计工具
SXP-Simon Nov 23, 2026
1733535
refactor(crates/panache-mcp): 分离评审选区和逐行测量
SXP-Simon Nov 23, 2026
7c3edbf
refactor(crates/handwriting-core): 简化根号墨迹采样与回退
SXP-Simon Nov 23, 2026
8cd9658
refactor(app/updater): 分离 Windows 启动代理与升级控制协议
SXP-Simon Nov 23, 2026
ca8812a
refactor(app/services): 分离旧草稿和上传字体状态恢复
SXP-Simon Nov 23, 2026
d8c976e
refactor(app/theme): 分离工作台配色和控件主题配方
SXP-Simon Nov 23, 2026
3c04517
refactor(crates/handwriting-core): 集中行高与可见墨迹边界计算
SXP-Simon Nov 23, 2026
ac3e324
refactor(crates/handwriting-core): 统一表格列边界与线段绘制
SXP-Simon Nov 23, 2026
e09882a
docs(docs): 说明工作台和渲染引擎的职责边界
SXP-Simon Nov 23, 2026
58f8bfe
refactor(app/models): 分开旧草稿字形解码与批次校验
SXP-Simon Nov 23, 2026
c26c104
refactor(app/services): 分开底纸尺寸预算与图像资源释放
SXP-Simon Nov 23, 2026
4ac83db
refactor(app/services): 集中更新助手的取消与恢复
SXP-Simon Nov 23, 2026
a40b64d
refactor(crates/handwriting-server): 分离启动配置与服务生命周期
SXP-Simon Nov 23, 2026
620e35e
refactor(crates/handwriting-core): 用节点范围流组织作业排版
SXP-Simon Nov 23, 2026
3e9e788
test(app/updater): 覆盖保存途中取消更新的时序
SXP-Simon Nov 23, 2026
cc9ed9f
refactor(app/screens): 分离底纸选区画布和坐标投影
SXP-Simon Nov 23, 2026
61f0893
refactor(app/screens): 分离 PDF 逐页组装与导出交互
SXP-Simon Nov 23, 2026
657da2d
fix(crates/handwriting-core): 拒绝不完整电路标签并保留原文
SXP-Simon Nov 23, 2026
e14f83e
fix(app/windows): 修复窗口字体通知与控制台重定向
SXP-Simon Nov 23, 2026
490628c
fix(app/services): 允许桌面更新恢复被拒绝后重试
SXP-Simon Nov 23, 2026
c743afa
fix(app/android): 解绑宿主时结束旧 APK 校验与权限请求
SXP-Simon Nov 23, 2026
c153a04
fix(app/utils): 保留 Markdown 原文字符与后续代码段
SXP-Simon Nov 23, 2026
6c5c6b4
fix(app/utils): 避免重复剥除未配对的反引号
SXP-Simon Nov 23, 2026
495acbc
refactor(app/services): 将生成契约和上传模型从传输实现中分离
SXP-Simon Nov 23, 2026
969d45b
refactor(app/services): 解除字体持久化接口和平台工厂的依赖环
SXP-Simon Nov 23, 2026
c8e9cae
refactor(app/utils): 分开课程命令分派与 SI 单位语法
SXP-Simon Nov 23, 2026
61b7acd
refactor(app/widgets): 分开精修选区规则和检查面板
SXP-Simon Nov 23, 2026
aae2568
refactor(app/screens): 分离实时预览的调度与页面导航
SXP-Simon Nov 23, 2026
5a368c8
fix(app/screens): 文本整理完成后恢复实时预览
SXP-Simon Nov 23, 2026
a47bf28
refactor(app/widgets): 分离工作台响应式外壳与导航呈现
SXP-Simon Nov 23, 2026
b313e9d
refactor(app/updater): 解除进程身份与升级协议的依赖环
SXP-Simon Nov 23, 2026
1a98e27
fix(app/utils): 精确保留大分母化学计量系数
SXP-Simon Nov 23, 2026
e0675f6
docs(docs): 对齐工作台、引擎契约与平台适配的维护入口
SXP-Simon Nov 23, 2026
e9ecee3
refactor(app/utils): 分开物理公式的扫描、校验和展开
SXP-Simon Nov 24, 2026
9479279
refactor(app/utils): 把 Markdown 表格分隔识别与切片分开
SXP-Simon Nov 24, 2026
d5788d3
refactor(app/utils): 分开 LaTeX 节点分派与输出规则
SXP-Simon Nov 24, 2026
75ebb10
refactor(crates/handwriting-server): 由任务存储管理下载租约
SXP-Simon Nov 24, 2026
af0e008
refactor(app/screens): 分开 PDF 工作台布局和文档操作
SXP-Simon Nov 24, 2026
7ac6c7a
refactor(app/utils): 独立解析化学式的元素与括号组
SXP-Simon Nov 24, 2026
e255e38
refactor(app/widgets): 独立手稿输入框和插图栏
SXP-Simon Nov 24, 2026
38d55a6
refactor(app/widgets): 按更新阶段组织状态和可用操作
SXP-Simon Nov 24, 2026
eef2263
ci: 移除移动端工作流中的 iOS 验证
SXP-Simon Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .github/workflows/flutter_mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,3 @@ jobs:
with:
name: android-release
path: app/build/app/outputs/flutter-apk/app-release.apk
ios:
needs: markdown-update
if: ${{ !cancelled() && needs.markdown-update.outputs.skip != 'true' }}
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.47.5"
cache: true
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.94.1"
targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios
- run: flutter pub get && flutter build ios --simulator --debug
working-directory: app
- name: iOS 模拟器离线集成测试
working-directory: app
run: |
DEVICE=$(xcrun simctl list devices available -j | python3 -c 'import json,sys; print(next(d["udid"] for devices in json.load(sys.stdin)["devices"].values() for d in devices if d["name"].startswith("iPhone")))')
xcrun simctl boot "$DEVICE" || true
xcrun simctl bootstatus "$DEVICE" -b
flutter test integration_test/mobile_engine_test.dart -d "$DEVICE"
- run: flutter build ios --release --no-codesign
working-directory: app
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## 未发布

- 桌面更新恢复时,若系统拒绝退出,助手释放后会显示“重新启动”,可直接重试。Windows 在窗口启动和销毁期间也能处理系统字体通知,调试控制台只会重定向成功打开的输出流。
- Android 更换 Activity 时会结束原宿主上的安装校验,离开前发出的权限请求不会在新宿主上触发安装。
- 不完整的电路数学标签会随原文保留。整理 Markdown 时,原文中的私用区字符和已配对的行内代码会保留,前面单独出现的反引号不影响后面的代码段。化学式的非零分母无论长度都按原数字转写。实时预览开启时,文本整理完成后会自动生成整理后的草稿。

- 内部重构涵盖工作台的文本整理、设置、预览和主题,桌面更新助手,以及 Rust 引擎的文档提取、段落换行、字形绘制与导出。HTTP、移动端和 MCP 的请求处理与后台任务分别归入对应模块。物理公式参数、LaTeX 节点输出和 Markdown 表格分隔各有独立入口。HTTP 任务存储统一管理下载租约,直到最后一个下载响应释放才允许清理成品。

- 纸张设置只在已上传底纸时显示「底纸拍摄设备」。展开填写后可继续向下滚动到页边距。

- MCP 续稿时可按节和评语来源筛选历史。用 `read_section(view="trajectory", section=2, feedback_origin="user_quote")` 可直接找回第 2 节记录的用户原话、关联版本和复盘 ID。轨迹支持用游标续读,翻页时补录的评语会在下一轮查询中出现。
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ cargo fmt --all -- --check
cargo clippy --locked --workspace --all-targets -- -D warnings
cargo test --locked --workspace
```

对比两个提交的 Dart 函数复杂度、嵌套与长度,可使用[仓库自带的 Dart 结构计量命令](scripts/dart-quality/README.md)。
20 changes: 9 additions & 11 deletions app/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ plugins {
id("dev.flutter.flutter-gradle-plugin")
}

// Package the same architectures that the Rust build supplies.
val engineAbis = when (project.findProperty("target-platform") as? String) {
"android-arm64" -> listOf("arm64-v8a")
"android-x64" -> listOf("x86_64")
else -> listOf("arm64-v8a", "x86_64")
}

android {
namespace = "io.github.sxpsimon.handwriting"
compileSdk = flutter.compileSdkVersion
Expand All @@ -23,13 +30,7 @@ android {
// Flutter configures ABI splits itself. Combining splits with ndk ABI
// filters is rejected by the Android Gradle plugin.
if (project.findProperty("split-per-abi") != "true") {
val platforms = (project.findProperty("target-platform") as? String).orEmpty()
val abis = when (platforms) {
"android-arm64" -> listOf("arm64-v8a")
"android-x64" -> listOf("x86_64")
else -> listOf("arm64-v8a", "x86_64")
}
ndk { abiFilters += abis }
ndk { abiFilters += engineAbis }
}
targetSdk = flutter.targetSdkVersion
// Uses the version code from pubspec.yaml. When using split APKs, 1000 * ABI_VERSION
Expand Down Expand Up @@ -89,11 +90,8 @@ dependencies {
val buildMobileEngine by tasks.registering(Exec::class) {
val repository = rootProject.projectDir.parentFile.parentFile
val output = layout.buildDirectory.dir("rust-jni").get().asFile
val platforms = (project.findProperty("target-platform") as? String).orEmpty()
val abis = if (platforms == "android-arm64") "arm64-v8a"
else if (platforms == "android-x64") "x86_64" else "arm64-v8a,x86_64"
commandLine(if (System.getProperty("os.name").startsWith("Windows")) "python" else "python3",
repository.resolve("scripts/build-mobile-engine.py"), "android",
"--ndk", android.ndkDirectory, "--output", output, "--abis", abis)
"--ndk", android.ndkDirectory, "--output", output, "--abis", engineAbis.joinToString(","))
}
tasks.named("preBuild") { dependsOn(buildMobileEngine) }
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.github.sxpsimon.handwriting;

import java.io.File;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;

/** Verification and settings round-trips for one attachment. Host entry points run on the UI thread. */
final class ApkInstallSession implements AutoCloseable {
private static final AtomicInteger NEXT_PERMISSION_CODE = new AtomicInteger(7821);
private final ExecutorService worker = Executors.newSingleThreadExecutor();
private final Executor ui;
private int permissionCode = -1;

ApkInstallSession(Executor ui) {
this.ui = ui;
}

void verify(Callable<File> validate, Consumer<File> install, Consumer<Exception> fail) {
worker.execute(() -> {
final File file;
try {
file = validate.call();
} catch (Exception error) {
ui.execute(() -> {
if (!worker.isShutdown()) fail.accept(error);
});
return;
}
ui.execute(() -> {
if (worker.isShutdown()) return;
try {
install.accept(file);
} catch (Exception error) {
fail.accept(error);
}
});
});
}

int beginPermissionRequest() {
// A replacement Activity can receive the result of the previous Activity's settings request.
permissionCode = NEXT_PERMISSION_CODE.getAndIncrement() & 0xffff;
return permissionCode;
}

boolean consumePermissionResult(int code) {
if (permissionCode < 0 || code != permissionCode) return false;
permissionCode = -1;
return true;
}

@Override
public void close() {
permissionCode = -1;
worker.shutdownNow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,30 @@ import android.provider.Settings
import androidx.core.content.FileProvider
import java.io.File
import java.security.MessageDigest
import java.util.concurrent.Executors
import java.net.ProxySelector
import java.net.Proxy
import java.net.URI
import java.net.InetSocketAddress

class MainActivity : FlutterActivity() {
private var pending: MethodChannel.Result? = null
private var pendingPath: String? = null
private var pendingBuild: Long = 0
private var pendingHash: String? = null
private val verifier = Executors.newSingleThreadExecutor()
private val permissionRequest = 7821
private class InstallRequest(
val result: MethodChannel.Result, val path: String?, val build: Long, val hash: String?
)
private var pending: InstallRequest? = null
private var updates: MethodChannel? = null
private lateinit var installSession: ApkInstallSession

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger,
"io.github.sxpsimon.panache/updates").setMethodCallHandler { call, result ->
installSession = ApkInstallSession { task -> runOnUiThread(task) }
val channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger,
"io.github.sxpsimon.panache/updates")
updates = channel
channel.setMethodCallHandler { call, result ->
if (updates !== channel) {
result.error("install_unavailable", "Activity detached", null)
return@setMethodCallHandler
}
when (call.method) {
"supportedAbis" -> result.success(Build.SUPPORTED_ABIS.toList())
"cacheDirectory" -> result.success(File(cacheDir, "updates").absolutePath)
Expand All @@ -43,10 +49,8 @@ class MainActivity : FlutterActivity() {
if (pending != null) {
result.error("busy", "An installation request is already open", null)
} else {
pending = result
pendingPath = call.argument<String>("path")
pendingBuild = call.argument<Number>("buildNumber")?.toLong() ?: 0
pendingHash = call.argument<String>("sha256")
pending = InstallRequest(result, call.argument<String>("path"),
call.argument<Number>("buildNumber")?.toLong() ?: 0, call.argument<String>("sha256"))
verifyAndInstall(true)
}
}
Expand All @@ -55,47 +59,53 @@ class MainActivity : FlutterActivity() {
}
}

override fun cleanUpFlutterEngine(flutterEngine: FlutterEngine) {
updates?.setMethodCallHandler(null)
updates = null
installSession.close()
val result = pending?.result
pending = null
result?.error("install_unavailable", "Activity detached", null)
super.cleanUpFlutterEngine(flutterEngine)
}

@Suppress("DEPRECATION")
private fun validateApk(): File {
private fun validateApk(request: InstallRequest): File {
val root = File(cacheDir, "updates").canonicalFile
val file = File(pendingPath ?: "").canonicalFile
val file = File(request.path ?: "").canonicalFile
require(file.parentFile?.parentFile == root &&
file.parentFile?.name?.startsWith("download-") == true && file.isFile && file.extension == "apk")
val hash = MessageDigest.getInstance("SHA-256")
file.inputStream().use { stream ->
val buffer = ByteArray(65536)
while (true) {
if (Thread.currentThread().isInterrupted) throw InterruptedException("Activity detached")
val count = stream.read(buffer)
if (count < 0) break
hash.update(buffer, 0, count)
}
}
require(hash.digest().joinToString("") { "%02x".format(it) } == pendingHash)
require(hash.digest().joinToString("") { "%02x".format(it) } == request.hash)
val archive = packageManager.getPackageArchiveInfo(file.path, 0)
?: error("Cannot read APK")
val current = packageManager.getPackageInfo(packageName, 0)
val archiveVersion = if (Build.VERSION.SDK_INT >= 28) archive.longVersionCode else archive.versionCode.toLong()
val currentVersion = if (Build.VERSION.SDK_INT >= 28) current.longVersionCode else current.versionCode.toLong()
require(archive.packageName == packageName && archiveVersion == pendingBuild && archiveVersion > currentVersion)
require(archive.packageName == packageName && archiveVersion == request.build && archiveVersion > currentVersion)
return file
}

private fun verifyAndInstall(allowPermissionRequest: Boolean) {
verifier.execute {
try {
val file = validateApk()
runOnUiThread {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
!packageManager.canRequestPackageInstalls()) {
check(allowPermissionRequest) { "Installation permission was not granted" }
startActivityForResult(Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES,
Uri.parse("package:$packageName")), permissionRequest)
} else launchInstaller(file)
} catch (error: Exception) { fail(error) }
}
} catch (error: Exception) { runOnUiThread { fail(error) } }
}
val request = pending ?: return
installSession.verify({ validateApk(request) }, onVerified@{ file ->
if (pending !== request) return@onVerified
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
!packageManager.canRequestPackageInstalls()) {
check(allowPermissionRequest) { "Installation permission was not granted" }
startActivityForResult(Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES,
Uri.parse("package:$packageName")), installSession.beginPermissionRequest())
} else launchInstaller(file)
}, { error -> if (pending === request) fail(error) })
}

private fun launchInstaller(file: File) {
Expand All @@ -108,21 +118,21 @@ class MainActivity : FlutterActivity() {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
startActivity(intent)
pending?.success(null)
val result = pending?.result
pending = null
pendingPath = null
result?.success(null)
}

private fun fail(error: Exception) {
pending?.error("install_unavailable", error.message, null)
val result = pending?.result
pending = null
pendingPath = null
result?.error("install_unavailable", error.message, null)
}

@Deprecated("Android activity permission flow still delivers this callback")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode != permissionRequest || pending == null) return
if (pending == null || !installSession.consumePermissionResult(requestCode)) return
verifyAndInstall(false)
}
}
Loading
Loading