Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Lithe 默认不向用户的命令行环境注册命令。用户在设置的“

- Core(共享 Rust 规则层)解析启动参数、根据原生文件类型选择模式,并给出单文件模式允许的命令。桌面端只做路径观察、进程启动和界面呈现。单文件窗口借用既有文档与标签生命周期,不调用项目打开流程;父目录只是文件位置,不进行项目恢复、信任确认、递归搜索或插件上下文绑定。
- 单文件模式保留内置语法高亮、文本编辑、查找替换、保存、编码与换行选择和单个文档的外部变更观察。Markdown 文件与项目窗口一样显示渲染页(编辑 / 编辑与预览 / 预览切换和目录按钮,#2324):渲染页只读当前文档文本和它引用的图片,链接在本窗口打开文件,不需要项目服务。项目侧栏、Git、运行、调试、测试不呈现;SVG、HTML 文件只显示源码,图片、PDF 等查看器也不打开。终端默认关闭,由用户点击后才创建,使用当前文件所在目录,复用现有终端标签、分隔条及进程清理;隐藏面板保留会话,关闭标签或窗口释放 shell。单文件窗口不恢复或改写项目面板布局。双 Shift 和查找动作只列出允许的动作,不读取父目录。关闭全部文件后仍保持单文件空态。
- 单文件 Markdown 没有工作区;调用 Core 的引用解析接口(`markdown.resolveReference`)时省略工作区根目录参数(`workspaceRoot`),让每个文档自己的目录决定图片读取范围以及 `/` 开头的图片、链接的基准。单文件会话记录的首个文件父目录(`p.root`)只是窗口起点,不能当成随后打开的子目录或其他目录文档的工作区。原生图片、网页图片回调与点击链接使用同一上下文;项目窗口继续传项目根。
- 顶栏显示当前文件名与“单文件模式”,通过 ⓘ 解释边界。“以项目打开所在文件夹”使用当前选中文件的父目录,在另一窗口进入正常的项目信任和插件流程,保留原编辑窗口。
- CLI 卡片直接读取默认 shell 配置与启动器内容。macOS zsh 使用 `.zshrc`(尊重 `ZDOTDIR`),bash 使用实际登录配置,fish 使用自身配置;Windows 编辑当前用户注册表 PATH,保留其原生字符串类型,并有界广播环境变更。已有终端需重新打开。
- 打开页面只读,注册、修复和移除都来自明确按钮。Unix 来源使用带标记的配置块,Windows 只编辑匹配目录项;保留其他内容。写入前核对文件内容、来源目录和符号链接目标;读取后被外部改写则拒绝覆盖。Windows 注册表核对与单值写入间仍受外部进程竞争限制,不宣称跨进程事务。
Expand All @@ -25,6 +26,7 @@ Lithe 默认不向用户的命令行环境注册命令。用户在设置的“

- 安装或首次启动时自动写 PATH:违背默认不注册的要求,也无法让用户审阅修改目标。
- 在单文件窗口创建项目并禁用部分插件:项目管线仍会创建目录观察和恢复状态,无法保证任何插件都不激活。
- 把首个单文件的父目录当成所有文档的工作区:打开子目录文档时会允许它读取父目录图片,并把 `/image.png` 指向首个文件的目录。按文档传正确上下文,复用 Core 的既有解析及授权规则;首目录外的文档原本已由 Core 回退到自身目录,继续保持该行为。
- 只注册全局系统目录中的符号链接:Windows 与 Unix 所需权限不同,还可能要求管理员权限。用户级启动器可以保持显式注册且不修改安装资源。
- 在当前窗口将单文件直接升级为项目:会混合两种服务生命周期,产生插件初始化与未保存文档处理的隐含转换。使用正常项目新窗口复用已有完整流程,代价是多一个窗口。

Expand All @@ -36,6 +38,7 @@ Lithe 默认不向用户的命令行环境注册命令。用户在设置的“

- `scripts/desktop/desktop-go.sh test ./cmd/lithe ./internal/cli ./internal/core ./internal/workbench -run 'TestCLI|TestStandalone|TestDesktopStartupMakesInstalledPluginSettingsReachable' -count=1 -timeout=90s`:链接同一 Core 检出,验证真实文件类型、共享 fixture、真实临时 shell 配置的注册/修复/移除/冲突保护和独立编辑保存。
- `scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/settingswindow ./internal/workbench -run 'TestVisualCLISettings|TestVisualStandalone' -count=1 -timeout=90s`:生成明暗主题、中英文的真实渲染截图。通过 `LITHE_VISUAL_OUTPUT_DIR` 指定本工作树的输出目录。
- `TestStandaloneMarkdownImagesUseEachDocumentsFolder`、`TestStandaloneMarkdownWebPreviewKeepsScopeAndLifecycle`、`TestProjectMarkdownKeepsWorkspaceRootForNestedDocuments` 与 `TestPreviewWorkspaceRootReturnsEmptyOnlyForNilOrStandalone` 验证后续子目录及无关目录文档的本地图片、`/` 引用、符号链接与父目录越界图片、链接跟随及项目模式对照;网页视图替身只证明宿主接线,不替代 WKWebView/WebView2 原生验收。
- `scripts/desktop/verify/verify-runtime-bundle-immutability.sh`:检查两个桌面平台的发行目录只读边界。
- Windows 规则可以在 macOS 上以平台参数验证;注册表写入、环境广播与 cmd/PowerShell 调用仍需 Windows 原生环境验收,交叉编译不替代该验收。

Expand All @@ -45,5 +48,7 @@ Lithe 默认不向用户的命令行环境注册命令。用户在设置的“
- `desktop/internal/cli/`
- `desktop/internal/core/cli.go`
- `desktop/internal/workbench/standalone.go`
- `desktop/internal/workbench/preview_pages.go`
- `desktop/internal/workbench/standalone_markdown_references_test.go`
- `desktop/internal/settingswindow/cli_view.go`
- `shared/platform-feature-matrix/features/cli-single-file-mode.json`
2 changes: 1 addition & 1 deletion desktop/internal/workbench/markdown_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (a *App) markdownImageBitmap(p *project, d *document, s *markdownPreviewSta
}
image := &markdownImage{loading: true}
s.images[destination] = image
path, root, remote := s.path, p.root, a.previewRemote()
path, root, remote := s.path, p.previewWorkspaceRoot(), a.previewRemote()
a.background(p, markdownImageTimeout, func(ctx context.Context) func(*App) {
bitmap, err := loadMarkdownImage(ctx, kernel, path, root, destination, remote)
return func(a *App) {
Expand Down
2 changes: 1 addition & 1 deletion desktop/internal/workbench/markdown_preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ func (a *App) followDocumentLink(p *project, path, destination string, anchor fu
if !ok {
return
}
root := p.root
root := p.previewWorkspaceRoot()
a.background(p, kernelCallTimeout, func(ctx context.Context) func(*App) {
target, err := kernel.ResolveMarkdownReference(ctx, path, root, destination, core.MarkdownLink)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion desktop/internal/workbench/markdown_web.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (a *App) markdownWebPage(p *project, d *document, s *markdownPreviewState)
}
w := &markdownWeb{path: d.path, rendered: -1, rendering: -1, line: line}
// The page asks for its images on goroutines of its own: what they need is copied here.
path, root := d.path, p.root
path, root := d.path, p.previewWorkspaceRoot()
entry := a.openPreviewPage(webpreview.Config{
Page: webpreview.MarkdownPage,
Resolve: func(ctx context.Context, reference string) (core.MarkdownReference, error) {
Expand Down
10 changes: 10 additions & 0 deletions desktop/internal/workbench/preview_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ type markdownKernel interface {
ResolveMarkdownReference(ctx context.Context, documentPath, workspaceRoot, reference string, purpose core.MarkdownReferencePurpose) (core.MarkdownReference, error)
}

// previewWorkspaceRoot is the workspace given to Core when resolving a document's references.
// A standalone session has no workspace: p.root is only the first file's folder. With no root,
// Core uses each document's own folder for its image scope and root-relative references.
func (p *project) previewWorkspaceRoot() string {
if p == nil || p.standalone {
return ""
}
return p.root
}

// previewWeb reports whether pages can be opened: the web host is ready and no page failed to
// open.
func (a *App) previewWeb() bool {
Expand Down
Loading
Loading