diff --git a/.agents/notes/implemented/bug-fix/2026-11-24-plugin-staging-sweep-ownership.md b/.agents/notes/implemented/bug-fix/2026-11-24-plugin-staging-sweep-ownership.md new file mode 100644 index 000000000..19856da61 --- /dev/null +++ b/.agents/notes/implemented/bug-fix/2026-11-24-plugin-staging-sweep-ownership.md @@ -0,0 +1,39 @@ +# Agent 笔记:插件暂存目录的跨进程清理 + +状态:已实现 + +## 先说结论 + +桌面安装、后台准备更新和卸载使用同一个用户插件根目录。启动时只有取得独占锁的进程才清理临时目录,使用临时目录的进程共同持有共享锁。这样在另一个窗口启动时,正在验包或等候用户批准的安装仍能继续。 + +## 问题 + +每个桌面进程会在加载插件服务时清理 `.staging` 和 `.trash`,原先假定此时没有安装或卸载。打开新窗口可能启动另一个进程。后台更新在发布待激活目录之前已经解包,用于串行发布的锁也无法覆盖此前的准备过程。 + +## 决策 + +- 使用写在用户插件根目录的 `.staging-sweep.lock`。安装和卸载从准备临时文件前到发布或清理完成为止持有共享锁。启动先探测是否有遗留目录,然后只尝试一次独占锁。获取锁后重新读取目录,目录正在使用时留给以后启动清理。异常退出时系统会释放锁,锁文件继续供其他进程使用。 +- 包发布和审批记录继续使用原有的独占锁。用户等待审批时其他进程仍能准备各自的包,也能打开窗口。 +- 例如:进程 A 解包并进入审批,进程 B 启动并读取插件列表。B 发现暂存目录正由 A 使用,略过启动清理,A 可以继续发布。取得独占锁后才读取临时目录,可避免用加锁前的列表误删刚创建的包。 + +## 考虑过的备选方案 + +- 扩大包发布独占锁以覆盖下载、解包和审批。审批时间由用户决定,持有该锁会让其他安装或卸载等到超时。 +- 按文件修改时间删除旧目录。后台检查、用户审批和休眠都可能持续超过选定期限,目录年龄无法证明已经没有进程使用它。 + +## 后果 + +同时准备的包不互相等待,启动清理也不等待用户操作。其他桌面进程正在安装或卸载时,已中断任务的文件会留到下一次可清理的启动。锁文件随用户的插件数据根存在,位于发行包之外,因此不改变代码签名或应用增量更新基线。 + +## 验证 + +- `./scripts/desktop/desktop-go.sh test ./internal/workbench -run TestPluginAutoUpdateStagesAnApprovedNewVersionUntilRestart` 在合成插件归档解包和发布之间运行第二个桌面插件服务,验证更新成功暂存,并在随后激活。 +- `./scripts/desktop/desktop-go.sh test ./internal/pluginpkg ./internal/plugininstall ./internal/pluginservice` 验证遗留文件清理和安装包只读边界。 +- `./scripts/desktop/verify/verify-runtime-bundle-immutability.sh` 检查 macOS 和 Windows 的发行目录只读门禁。 + +## 适用范围 + +- `desktop/internal/pluginpkg/install.go` +- `desktop/internal/workbench/plugins.go` +- `desktop/internal/workbench/plugin_auto_update.go` +- `desktop/internal/pluginservice/lifecycle.go` diff --git a/.agents/notes/implemented/feature/2026-11-18-plugin-auto-updates.md b/.agents/notes/implemented/feature/2026-11-18-plugin-auto-updates.md index 1b3c91e1f..6a0a48a7f 100644 --- a/.agents/notes/implemented/feature/2026-11-18-plugin-auto-updates.md +++ b/.agents/notes/implemented/feature/2026-11-18-plugin-auto-updates.md @@ -31,6 +31,8 @@ 不同进程共享插件数据根。激活、手动安装、后台暂存、禁用和卸载使用同一个原生文件锁。卸载先取消并等待进程内的安装任务,再加锁让 Core 读取安装快照。这样即使另一个窗口刚刚激活新版,卸载计划也会包含它。锁文件保留在可写的插件数据根,进程退出时由操作系统释放锁。 +启动清理也需要和使用临时目录的进程协调。安装和卸载在使用临时目录期间持有共享锁,启动只在立即取得独占锁时清理。原因和回归场景见 [插件暂存目录的跨进程清理](../bug-fix/2026-11-24-plugin-staging-sweep-ownership.md)。 + ## 考虑过的备选方案 - 默认无条件自动更新:用户没有同意后台下载或插件执行代码更换,拒绝。 diff --git a/desktop/internal/filelock/lock.go b/desktop/internal/filelock/lock.go index db6b6dfb6..81e449324 100644 --- a/desktop/internal/filelock/lock.go +++ b/desktop/internal/filelock/lock.go @@ -17,7 +17,23 @@ var ( // Acquire uses an OS lock, not a pid or timestamp lease: process death releases // ownership automatically. The file stays in place so another opener cannot // lock a different inode while a previous waiter still holds the old one. -func Acquire(ctx context.Context, name string) (unlock func() error, err error) { +func Acquire(ctx context.Context, name string) (func() error, error) { + return acquire(ctx, name, true, true) +} + +// AcquireShared lets multiple users hold the same lock until an exclusive +// operation can run without any of them. +func AcquireShared(ctx context.Context, name string) (func() error, error) { + return acquire(ctx, name, false, true) +} + +// TryAcquire attempts an exclusive lock once. A nil closer with no error means +// another process owns the lock. +func TryAcquire(name string) (func() error, error) { + return acquire(context.Background(), name, true, false) +} + +func acquire(ctx context.Context, name string, exclusive, wait bool) (unlock func() error, err error) { defer func() { if err != nil && unlock != nil { err = errors.Join(err, unlock()) @@ -57,7 +73,7 @@ func Acquire(ctx context.Context, name string) (unlock func() error, err error) bounded, cancel := context.WithTimeout(ctx, 5*time.Minute) defer cancel() for { - locked, err := tryLock(file) + locked, err := tryLock(file, exclusive) if err != nil { return nil, err } @@ -68,6 +84,9 @@ func Acquire(ctx context.Context, name string) (unlock func() error, err error) owned = true return file.Close, nil } + if !wait { + return nil, nil + } // Native advisory locks have no cross-platform cancellable wait. The // bounded timer performs no filesystem scanning and owns no goroutine. timer := time.NewTimer(100 * time.Millisecond) diff --git a/desktop/internal/filelock/lock_unix.go b/desktop/internal/filelock/lock_unix.go index 4ce41a8f2..1f9e89b66 100644 --- a/desktop/internal/filelock/lock_unix.go +++ b/desktop/internal/filelock/lock_unix.go @@ -9,8 +9,12 @@ import ( "golang.org/x/sys/unix" ) -func tryLock(file *os.File) (bool, error) { - err := unix.Flock(int(file.Fd()), unix.LOCK_EX|unix.LOCK_NB) +func tryLock(file *os.File, exclusive bool) (bool, error) { + mode := unix.LOCK_SH + if exclusive { + mode = unix.LOCK_EX + } + err := unix.Flock(int(file.Fd()), mode|unix.LOCK_NB) if errors.Is(err, unix.EWOULDBLOCK) || errors.Is(err, unix.EAGAIN) { return false, nil } diff --git a/desktop/internal/filelock/lock_windows.go b/desktop/internal/filelock/lock_windows.go index 659e7ac8b..bab55e13b 100644 --- a/desktop/internal/filelock/lock_windows.go +++ b/desktop/internal/filelock/lock_windows.go @@ -9,8 +9,12 @@ import ( "golang.org/x/sys/windows" ) -func tryLock(file *os.File) (bool, error) { - err := windows.LockFileEx(windows.Handle(file.Fd()), windows.LOCKFILE_EXCLUSIVE_LOCK|windows.LOCKFILE_FAIL_IMMEDIATELY, 0, 1, 0, new(windows.Overlapped)) +func tryLock(file *os.File, exclusive bool) (bool, error) { + mode := uint32(windows.LOCKFILE_FAIL_IMMEDIATELY) + if exclusive { + mode |= windows.LOCKFILE_EXCLUSIVE_LOCK + } + err := windows.LockFileEx(windows.Handle(file.Fd()), mode, 0, 1, 0, new(windows.Overlapped)) if errors.Is(err, windows.ERROR_LOCK_VIOLATION) { return false, nil } diff --git a/desktop/internal/plugininstall/pending_test.go b/desktop/internal/plugininstall/pending_test.go index 373f40f40..4ce6709b1 100644 --- a/desktop/internal/plugininstall/pending_test.go +++ b/desktop/internal/plugininstall/pending_test.go @@ -1,9 +1,11 @@ package plugininstall import ( + "context" "os" "path/filepath" "testing" + "time" "github.com/1lck/Lithe-IDEA/desktop/internal/installedpackagetest" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginpkg" @@ -18,6 +20,17 @@ func TestStageUpdateLeavesInstalledPackageUnchanged(t *testing.T) { if err != nil { t.Fatal(err) } + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + release, err := pluginpkg.ProtectStaging(ctx, root) + if err != nil { + t.Fatal(err) + } + defer func() { + if err := release(); err != nil { + t.Error(err) + } + }() staging, err := pluginpkg.NewStaging(root) if err != nil { t.Fatal(err) diff --git a/desktop/internal/pluginpkg/install.go b/desktop/internal/pluginpkg/install.go index 9a9a153bc..8c6dc708e 100644 --- a/desktop/internal/pluginpkg/install.go +++ b/desktop/internal/pluginpkg/install.go @@ -1,6 +1,7 @@ package pluginpkg import ( + "context" "errors" "fmt" "io/fs" @@ -8,6 +9,8 @@ import ( "path/filepath" "sort" "strings" + + "github.com/1lck/Lithe-IDEA/desktop/internal/filelock" ) const ( @@ -16,6 +19,7 @@ const ( // plugin, which is also why a plugin ID may not start with one. stagingDirectory = ".staging" trashDirectory = ".trash" + stagingSweepLock = ".staging-sweep.lock" // StateDirectory is where the programs of installed plugins keep their // writable state, one directory per plugin ID; see RemoveState. StateDirectory = ".state" @@ -44,19 +48,52 @@ type Installed struct { Path string } -// Sweep removes what an interrupted install or uninstall left behind. +// ProtectStaging holds the temporary package directories against startup +// cleanup. Keep the lock from before creating any files until publication or +// cleanup. Other installations can still prepare their own directories. +func ProtectStaging(ctx context.Context, root string) (func() error, error) { + if err := checkRoot(root); err != nil { + return nil, err + } + if err := ctx.Err(); err != nil { + return nil, err + } + if err := os.MkdirAll(root, 0o700); err != nil { + return nil, err + } + return filelock.AcquireShared(ctx, filepath.Join(root, stagingSweepLock)) +} + +// Sweep removes what an interrupted install or uninstall left behind when +// no operation in any desktop process is using the temporary directories. // // Nothing else cleans the staging and trash areas: a process killed mid-install, or -// a delete that failed, leaves a complete extracted package there. Call it before -// any installation can start, so it never races one. -func Sweep(root string) error { +// a delete that failed, leaves a complete extracted package there. A busy +// sweep waits for a later process startup rather than blocking this one. +func Sweep(root string) (err error) { if err := checkRoot(root); err != nil { return err } + var release func() error + defer func() { + if release != nil { + err = errors.Join(err, release()) + } + }() var failures []error for _, name := range []string{stagingDirectory, trashDirectory} { directory := filepath.Join(root, name) entries, err := os.ReadDir(directory) + if err == nil && len(entries) != 0 && release == nil { + release, err = filelock.TryAcquire(filepath.Join(root, stagingSweepLock)) + if err != nil || release == nil { + return errors.Join(append(failures, err)...) + } + // An owner may have created, removed or published a package + // between the unlocked probe and acquisition. + entries, err = os.ReadDir(directory) + } + // log-exempt: 预期的缺失:插件根目录还没有该临时目录。 if errors.Is(err, fs.ErrNotExist) { continue } diff --git a/desktop/internal/pluginpkg/install_test.go b/desktop/internal/pluginpkg/install_test.go index a6c8b52a4..abf53624c 100644 --- a/desktop/internal/pluginpkg/install_test.go +++ b/desktop/internal/pluginpkg/install_test.go @@ -1,10 +1,12 @@ package pluginpkg import ( + "context" "errors" "os" "path/filepath" "testing" + "time" "github.com/1lck/Lithe-IDEA/desktop/internal/installedpackagetest" ) @@ -227,6 +229,37 @@ func TestSweepRemovesLeftoversAndKeepsInstalledPackages(t *testing.T) { t.Fatal(err) } } + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + acquire := func() func() { + t.Helper() + release, err := ProtectStaging(ctx, root) + if err != nil { + t.Fatal(err) + } + finish := func() { + t.Helper() + if release != nil { + if err := release(); err != nil { + t.Error(err) + } + release = nil + } + } + t.Cleanup(finish) + return finish + } + first, second := acquire(), acquire() + first() + if err := Sweep(root); err != nil { + t.Fatal(err) + } + for _, directory := range leftovers { + if _, err := os.Stat(filepath.Join(directory, "leftover")); err != nil { + t.Fatalf("sweep removed an in-use file: %v", err) + } + } + second() if err := Sweep(root); err != nil { t.Fatalf("sweep: %v", err) } @@ -242,9 +275,13 @@ func TestSweepRemovesLeftoversAndKeepsInstalledPackages(t *testing.T) { } func TestSweepAcceptsAnEmptyRoot(t *testing.T) { - if err := Sweep(t.TempDir()); err != nil { + root := t.TempDir() + if err := Sweep(root); err != nil { t.Fatalf("sweep: %v", err) } + if _, err := os.Stat(filepath.Join(root, stagingSweepLock)); !errors.Is(err, os.ErrNotExist) { + t.Fatalf("startup wrote a lock without any files to sweep: %v", err) + } if err := Sweep("relative"); !errors.Is(err, ErrUnsafePath) { t.Fatalf("err = %v", err) } @@ -265,6 +302,18 @@ func TestInstallLeavesTheInstalledPackageUnchanged(t *testing.T) { if err := Sweep(root); err != nil { t.Fatal(err) } + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + release, err := ProtectStaging(ctx, root) + if err != nil { + t.Fatal(err) + } + defer func() { + if err := release(); err != nil { + t.Error(err) + } + }() + installedpackagetest.Outside(t, filepath.Join(root, stagingSweepLock)) staging, err := NewStaging(root) if err != nil { t.Fatal(err) diff --git a/desktop/internal/pluginservice/hostworkspacewatch_test.go b/desktop/internal/pluginservice/hostworkspacewatch_test.go index 7a868a3d2..6c8a2f9bc 100644 --- a/desktop/internal/pluginservice/hostworkspacewatch_test.go +++ b/desktop/internal/pluginservice/hostworkspacewatch_test.go @@ -27,8 +27,26 @@ func TestWorkspaceWatchUsesNativeEventsAndReleasesOwnedSubscriptions(t *testing. t.Fatal(err) } root := t.TempDir() - if err := os.Mkdir(filepath.Join(root, "src"), 0o700); err != nil { - t.Fatal(err) + const ( + created = "create/note.txt" + replaced = "replace/note.txt" + staging = "replace/next.txt" + removed = "remove/note.txt" + burst = "burst/note.txt" + next = "burst/next.txt" + ) + // Each operation owns its own directory. A native batch can + // report just the parent, and later batches can repeat its name. + // Prepare existing entries before the subscription starts. + for _, path := range []string{created, replaced, removed, burst} { + if err := os.Mkdir(filepath.Join(root, filepath.Dir(path)), 0o700); err != nil { + t.Fatal(err) + } + } + for _, path := range []string{replaced, staging, removed, burst, next} { + if err := os.WriteFile(filepath.Join(root, path), []byte(path), 0o600); err != nil { + t.Fatal(err) + } } workspace := service.Contexts.Open(root) t.Cleanup(func() { service.Contexts.Close(root) }) @@ -57,6 +75,8 @@ func TestWorkspaceWatchUsesNativeEventsAndReleasesOwnedSubscriptions(t *testing. var sequence uint64 await := func(operation, path string) { t.Helper() + parent := filepath.ToSlash(filepath.Dir(path)) + var observed [][]string for { select { case notification := <-kernel.events: @@ -73,14 +93,17 @@ func TestWorkspaceWatchUsesNativeEventsAndReleasesOwnedSubscriptions(t *testing. t.Fatalf("%s notification = %+v, %v", operation, notification, err) } sequence = value.Sequence - if path == "" && value.Event.RequiresRescan { + if value.Event.RequiresRescan { return } - if path != "" && (value.Event.RequiresRescan || slices.Contains(value.Event.ChangedPaths, path) || slices.Contains(value.Event.ChangedPaths, "src")) { + if path != "" && (slices.Contains(value.Event.ChangedPaths, path) || slices.Contains(value.Event.ChangedPaths, parent)) { return } + if len(observed) < cap(kernel.events) { + observed = append(observed, value.Event.ChangedPaths) + } case <-ctx.Done(): - t.Fatalf("%s did not reach the native watch: %v", operation, ctx.Err()) + t.Fatalf("%s did not reach the native watch for %q at sequence %d: %v (other batches: %v)", operation, path, sequence, ctx.Err(), observed) } } } @@ -90,23 +113,26 @@ func TestWorkspaceWatchUsesNativeEventsAndReleasesOwnedSubscriptions(t *testing. } // Disposal is scoped to the plugin and exact backend session. service.resources.dispose(pluginhost.Caller{PluginID: plugin, SessionID: "replacement-session"}, id) - file := filepath.Join(root, "src", "a.txt") - if err := os.WriteFile(file, []byte("first"), 0o600); err != nil { + if err := os.WriteFile(filepath.Join(root, created), []byte("first"), 0o600); err != nil { + t.Fatal(err) + } + await("nested creation", created) + if err := os.Rename(filepath.Join(root, staging), filepath.Join(root, replaced)); err != nil { t.Fatal(err) } - await("nested creation", "src/a.txt") - staging := filepath.Join(root, "src", "next") - if err := os.WriteFile(staging, []byte("saved"), 0o600); err != nil { + await("atomic replacement", replaced) + if err := os.Remove(filepath.Join(root, removed)); err != nil { t.Fatal(err) } - if err := os.Rename(staging, file); err != nil { + await("deletion", removed) + // A replace-and-remove burst can coalesce to a single change. + if err := os.Rename(filepath.Join(root, next), filepath.Join(root, burst)); err != nil { t.Fatal(err) } - await("atomic replacement", "src/a.txt") - if err := os.Remove(file); err != nil { + if err := os.Remove(filepath.Join(root, burst)); err != nil { t.Fatal(err) } - await("deletion", "src/a.txt") + await("replacement and deletion burst", burst) switch ending { case "dispose": params, _ := json.Marshal(map[string]string{"subscriptionID": id}) diff --git a/desktop/internal/pluginservice/lifecycle.go b/desktop/internal/pluginservice/lifecycle.go index 5f88e4453..dd1bb3c73 100644 --- a/desktop/internal/pluginservice/lifecycle.go +++ b/desktop/internal/pluginservice/lifecycle.go @@ -5,6 +5,7 @@ import ( "errors" "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginpkg" ) // Uninstall stops what plugin id runs and then removes it, in the order Core @@ -26,6 +27,11 @@ func (s *Service) Uninstall(ctx context.Context, id string, server *LanguageSess if err := s.stopRuntimePreparations(ctx, id); err != nil { return err } + finishStaging, err := pluginpkg.ProtectStaging(ctx, s.Root) + if err != nil { + return err + } + defer func() { err = errors.Join(err, finishStaging()) }() unlock, err := s.lockPackageChanges(ctx) if err != nil { return err diff --git a/desktop/internal/pluginservice/pluginservice.go b/desktop/internal/pluginservice/pluginservice.go index c73509fd0..4c725e536 100644 --- a/desktop/internal/pluginservice/pluginservice.go +++ b/desktop/internal/pluginservice/pluginservice.go @@ -199,8 +199,8 @@ func open(kernel Kernel, preferences *store.Store, root string, first bool) (*Se approvals := plugintrust.New(preferences) state := pluginstate.New(preferences) hostServices := pluginhost.NewServices() - // Nothing else removes what an interrupted install or uninstall left behind, and - // Open runs before any installation can start. + // Sweep collects interrupted installations when no other process is using + // the scratch directories for an installation or removal. if first { if err := pluginpkg.Sweep(root); err != nil { return nil, fmt.Errorf("%w: %w", ErrAssembly, err) diff --git a/desktop/internal/workbench/editoractions_test.go b/desktop/internal/workbench/editoractions_test.go index a14f40898..48b8186fe 100644 --- a/desktop/internal/workbench/editoractions_test.go +++ b/desktop/internal/workbench/editoractions_test.go @@ -374,6 +374,17 @@ func openNavActionHarness(t *testing.T, collected json.RawMessage, invokeFn func return h, kernel } +func navActionFixtureURI(t *testing.T, path string) string { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + uri, err := core.NewClient().PluginDocumentURI(ctx, path, "auto") + if err != nil { + t.Fatalf("encode navigation fixture path %q: %v", path, err) + } + return uri +} + func installCollectedNavActions(t *testing.T, h *harness, kernel *navActionKernel, p *project, d *document) { t.Helper() if err := h.app.plugins.Manager.SetEnabled(navFixturePluginID, true); err != nil { @@ -650,6 +661,8 @@ func TestEditorNavigationGutterClickAnchorsPopupAndSuppressesStartingToast(t *te root := t.TempDir() implA := filepath.Join(root, "ImplA.java") implB := filepath.Join(root, "ImplB.java") + implAURI := navActionFixtureURI(t, implA) + implBURI := navActionFixtureURI(t, implB) servicePath := filepath.Join(root, "Service.java") writeFixture(t, root, map[string]string{ "Service.java": "class ServiceImpl implements Service {\n public void run() {}\n public void third() {}\n}\n", @@ -669,9 +682,9 @@ func TestEditorNavigationGutterClickAnchorsPopupAndSuppressesStartingToast(t *te invokedMu.Lock() invoked = append(invoked, req.Data.Kind) invokedMu.Unlock() - loc := func(path string, line int) map[string]any { + loc := func(uri string, line int) map[string]any { return map[string]any{ - "uri": (&url.URL{Scheme: "file", Path: filepath.ToSlash(path)}).String(), + "uri": uri, "range": map[string]any{ "start": map[string]int{"line": line, "character": 0}, "end": map[string]int{"line": line, "character": 5}, @@ -680,10 +693,10 @@ func TestEditorNavigationGutterClickAnchorsPopupAndSuppressesStartingToast(t *te } switch req.Data.Kind { case "single": - data, _ := json.Marshal(map[string]any{"reveal": map[string]any{"locations": []any{loc(implA, 0)}}}) + data, _ := json.Marshal(map[string]any{"reveal": map[string]any{"locations": []any{loc(implAURI, 0)}}}) return data default: - data, _ := json.Marshal(map[string]any{"reveal": map[string]any{"locations": []any{loc(implA, 0), loc(implB, 0)}}}) + data, _ := json.Marshal(map[string]any{"reveal": map[string]any{"locations": []any{loc(implAURI, 0), loc(implBURI, 0)}}}) return data } }) @@ -700,7 +713,7 @@ func TestEditorNavigationGutterClickAnchorsPopupAndSuppressesStartingToast(t *te // Single-target click opens directly without "Starting ..." toast. cellUp := findGutterIconCell(t, d, 0, 0) h.click(gfx.Point{X: cellUp.X + cellUp.Width/2, Y: cellUp.Y + cellUp.Height/2}) - awaitDocumentState(t, h, func() bool { return p.docs.byPath(implA) != nil }) + h.await("single-target gutter navigation to open ImplA.java", func() bool { return p.docs.byPath(implA) != nil }) for _, entry := range h.app.notifications.list { if strings.Contains(entry.text, "Starting") { t.Fatalf("unexpected starting toast for navigation action: %q", entry.text) @@ -718,7 +731,7 @@ func TestEditorNavigationGutterClickAnchorsPopupAndSuppressesStartingToast(t *te h.settle() caret2, _ := d.view.CaretRect() h.click(gfx.Point{X: cellDown.X + cellDown.Width/2, Y: cellDown.Y + cellDown.Height/2}) - awaitDocumentState(t, h, func() bool { return h.app.semantics.definition.open }) + h.await("implementation targets popup to open", func() bool { return h.app.semantics.definition.open }) invokedMu.Lock() gotInvoked := append([]string(nil), invoked...) invokedMu.Unlock() @@ -739,7 +752,7 @@ func TestEditorNavigationGutterClickAnchorsPopupAndSuppressesStartingToast(t *te h.app.closeSemanticDefinition() cellBaseUp := findGutterIconCell(t, d, 1, 0) h.click(gfx.Point{X: cellBaseUp.X + cellBaseUp.Width/2, Y: cellBaseUp.Y + cellBaseUp.Height/2}) - awaitDocumentState(t, h, func() bool { return h.app.semantics.definition.open }) + h.await("definition targets popup to open", func() bool { return h.app.semantics.definition.open }) if got, want := h.app.definitionPopupTitle(), h.shared("desktop.semantics.definitions"); got != want { t.Fatalf("up multi-target popup title = %q, want %q", got, want) } diff --git a/desktop/internal/workbench/plugin_auto_update.go b/desktop/internal/workbench/plugin_auto_update.go index 60c3e7168..bd8cc4e99 100644 --- a/desktop/internal/workbench/plugin_auto_update.go +++ b/desktop/internal/workbench/plugin_auto_update.go @@ -14,6 +14,7 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/pluginhost" "github.com/1lck/Lithe-IDEA/desktop/internal/plugininstall" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginmanager" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginpkg" "github.com/1lck/Lithe-IDEA/desktop/internal/plugintrust" ) @@ -348,6 +349,11 @@ func (a *App) applyPluginAutoUpdate(ctx context.Context, downloader *marketplace return false, err } defer func() { a.recordPluginInstallCleanup(ctx, archive.Discard()) }() + finishStaging, err := pluginpkg.ProtectStaging(ctx, a.plugins.Root) + if err != nil { + return false, err + } + defer func() { a.recordPluginInstallCleanup(ctx, finishStaging()) }() plan, err := a.preparePlugin(ctx, plugininstall.Request{ ArchivePath: archive.Path(), Root: a.plugins.Root, Source: plugintrust.Marketplace, ArchiveSHA256: plugin.Availability.SHA256, diff --git a/desktop/internal/workbench/plugin_auto_update_test.go b/desktop/internal/workbench/plugin_auto_update_test.go index 34cafe8a4..d8d1f0766 100644 --- a/desktop/internal/workbench/plugin_auto_update_test.go +++ b/desktop/internal/workbench/plugin_auto_update_test.go @@ -6,10 +6,12 @@ import ( "context" "crypto/sha256" "encoding/hex" + "encoding/json" "errors" "io" "net/http" "os" + "os/exec" "path/filepath" "strings" "testing" @@ -22,6 +24,7 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/pluginpkg" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice" "github.com/1lck/Lithe-IDEA/desktop/internal/plugintrust" + "github.com/1lck/Lithe-IDEA/desktop/internal/store" ) func TestAutoUpdateCandidatesRequireMatchingApprovedSourceAndNewerRelease(t *testing.T) { @@ -75,11 +78,31 @@ func TestApprovedPluginAutoSourceOnlyMatchesSavedOrigins(t *testing.T) { // manual install. The previous approved version remains on disk while the next // version is selected, without any real plugin, network, or toolchain. func TestPluginAutoUpdateStagesAnApprovedNewVersionUntilRestart(t *testing.T) { - for _, scenario := range []string{"activate", "disabled before restart", "damaged package"} { + if root := os.Getenv("LITHE_TEST_PLUGIN_UPDATE_SWEEP_ROOT"); root != "" { + if _, err := pluginservice.Open(core.NewClient(), store.At(os.Getenv("LITHE_TEST_PLUGIN_UPDATE_SWEEP_PREFS")), root); err != nil { + t.Fatal(err) + } + return + } + for _, scenario := range []string{"activate", "disabled before restart", "damaged package", "another process starts during preparation"} { t.Run(scenario, func(t *testing.T) { verifyPendingPluginUpdate(t, scenario) }) } } +type startupSweepReviewKernel struct { + *core.Client + beforeReview func(context.Context) error +} + +func (k *startupSweepReviewKernel) ReviewMarketplaceInstall(ctx context.Context, manifest json.RawMessage, id, version string, approved []json.RawMessage, capabilities map[string][]int) (core.MarketplaceReview, error) { + if k.beforeReview != nil { + if err := k.beforeReview(ctx); err != nil { + return core.MarketplaceReview{}, err + } + } + return k.Client.ReviewMarketplaceInstall(ctx, manifest, id, version, approved, capabilities) +} + func verifyPendingPluginUpdate(t *testing.T, scenario string) { t.Helper() const id = "io.github.example.output-links" @@ -87,7 +110,8 @@ func verifyPendingPluginUpdate(t *testing.T, scenario string) { const archiveURL = "https://plugins.example.test/auto-update.zip" h := newHarness(t, &testKernel{Client: core.NewClient()}) - service, err := pluginservice.Open(core.NewClient(), h.store, t.TempDir()) + kernel := &startupSweepReviewKernel{Client: core.NewClient()} + service, err := pluginservice.Open(kernel, h.store, t.TempDir()) if err != nil { t.Fatal(err) } @@ -142,6 +166,25 @@ func verifyPendingPluginUpdate(t *testing.T, scenario string) { if err != nil || !found || previous.MarketplaceIndexURL != origin { t.Fatalf("initial approved source = %+v, found = %v, error = %v", previous, found, err) } + if scenario == "another process starts during preparation" { + binary, err := os.Executable() + if err != nil { + t.Fatal(err) + } + // The second startup runs after extraction and before the first + // process publishes the prepared package. + kernel.beforeReview = func(ctx context.Context) error { + childCtx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + cmd := exec.CommandContext(childCtx, binary, "-test.run=^TestPluginAutoUpdateStagesAnApprovedNewVersionUntilRestart$") + cmd.Env = append(os.Environ(), "LITHE_TEST_PLUGIN_UPDATE_SWEEP_ROOT="+service.Root, "LITHE_TEST_PLUGIN_UPDATE_SWEEP_PREFS="+h.store.Dir()) + if output, err := cmd.CombinedOutput(); err != nil { + t.Logf("other desktop startup: %s", output) + return err + } + return nil + } + } nextBytes, nextDigest := archiveBytes("2.0.0") requests := 0 @@ -194,7 +237,7 @@ func verifyPendingPluginUpdate(t *testing.T, scenario string) { t.Fatal(activationErr) } versions, err = pluginpkg.List(service.Root) - if scenario != "activate" { + if scenario == "disabled before restart" || scenario == "damaged package" { if err != nil || len(versions) != 1 || versions[0].Version != "1.0.0" { t.Fatalf("ineligible plugin was updated: %+v, %v", versions, err) } diff --git a/desktop/internal/workbench/plugins.go b/desktop/internal/workbench/plugins.go index 55065d3af..800d71a08 100644 --- a/desktop/internal/workbench/plugins.go +++ b/desktop/internal/workbench/plugins.go @@ -17,6 +17,7 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/marketplace" "github.com/1lck/Lithe-IDEA/desktop/internal/plugininstall" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginmanager" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginpkg" "github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice" "github.com/1lck/Lithe-IDEA/desktop/internal/plugintrust" "github.com/1lck/Lithe-IDEA/desktop/internal/settingswindow" @@ -159,7 +160,13 @@ func (a *App) preparePluginInstall(feedback settingswindow.PluginInstallFeedback // The review window's context ends the install; the install still belongs to the // action that started it, so its records and Core requests carry its op. origin := core.OriginOf(work) - plan, err := prepare(core.WithOrigin(feedback.Context, origin)) + ctx := core.WithOrigin(feedback.Context, origin) + finishStaging, err := pluginpkg.ProtectStaging(ctx, a.plugins.Root) + var plan plugininstall.Plan + if err == nil { + defer func() { a.recordPluginInstallCleanup(work, finishStaging()) }() + plan, err = prepare(ctx) + } if err != nil { // log-exempt: 用户取消:关闭审查窗口取消未完成的安装。 cancelled := feedback.Context.Err() != nil diff --git a/desktop/internal/workbench/pluginsemantics_test.go b/desktop/internal/workbench/pluginsemantics_test.go index 513494f9d..0fbb0e38a 100644 --- a/desktop/internal/workbench/pluginsemantics_test.go +++ b/desktop/internal/workbench/pluginsemantics_test.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "net/url" "os" "path/filepath" "runtime" @@ -1254,7 +1253,7 @@ func TestImplementationFallbackToGutterAndSuperShortcutAndContextMenu(t *testing } ] }`) - var implTarget, superTarget string + var implURI, superURI string h, kernel := openNavActionHarness(t, collected, func(arg json.RawMessage) json.RawMessage { var req struct { Data struct { @@ -1262,11 +1261,10 @@ func TestImplementationFallbackToGutterAndSuperShortcutAndContextMenu(t *testing } `json:"data"` } _ = json.Unmarshal(arg, &req) - path := superTarget + uri := superURI if req.Data.Target == "impl" { - path = implTarget + uri = implURI } - uri := (&url.URL{Scheme: "file", Path: filepath.ToSlash(path)}).String() data, _ := json.Marshal(map[string]any{"reveal": map[string]any{"locations": []any{map[string]any{ "uri": uri, "range": map[string]any{"start": map[string]int{"line": 0, "character": 0}, "end": map[string]int{"line": 0, "character": 4}}, @@ -1274,8 +1272,10 @@ func TestImplementationFallbackToGutterAndSuperShortcutAndContextMenu(t *testing return data }) f := openSemanticFixture(t, h, kernel.semanticTestKernel) - implTarget = filepath.Join(f.p.root, "Impl.java") - superTarget = filepath.Join(f.p.root, "Service.java") + implTarget := filepath.Join(f.p.root, "Impl.java") + superTarget := filepath.Join(f.p.root, "Service.java") + implURI = navActionFixtureURI(t, implTarget) + superURI = navActionFixtureURI(t, superTarget) for _, path := range []string{implTarget, superTarget} { if err := os.WriteFile(path, []byte("class T {}\n"), 0o600); err != nil { t.Fatal(err) @@ -1294,7 +1294,7 @@ func TestImplementationFallbackToGutterAndSuperShortcutAndContextMenu(t *testing if _, err := f.h.driver.ShortcutChord(primaryModifier()|gfx.ModifierAlt, 'b'); err != nil { t.Fatal(err) } - awaitDocumentState(t, f.h, func() bool { return f.p.docs.byPath(implTarget) != nil }) + f.h.await("implementation shortcut to open Impl.java", func() bool { return f.p.docs.byPath(implTarget) != nil }) for i := range f.kernel.requestCount() { if f.kernel.request(i).Operation == pluginSemanticImplementation { t.Fatal("unexpected LSP implementation request when server lacks capability") @@ -1309,7 +1309,7 @@ func TestImplementationFallbackToGutterAndSuperShortcutAndContextMenu(t *testing if err != nil || !handled { t.Fatalf("super shortcut handled=%v err=%v", handled, err) } - awaitDocumentState(t, f.h, func() bool { return f.p.docs.byPath(superTarget) != nil }) + f.h.await("super declaration shortcut to open Service.java", func() bool { return f.p.docs.byPath(superTarget) != nil }) // Primary+U on line 1 (2 choices) opens the navigate-up lane menu. f.h.app.selectDocument(f.p, f.d.id) diff --git a/docs/ci-builds.md b/docs/ci-builds.md index 3e0a28204..e1df9a91d 100644 --- a/docs/ci-builds.md +++ b/docs/ci-builds.md @@ -269,6 +269,8 @@ Go 构建在 windows/amd64 和 windows/arm64 上用 `go:embed` 把它们编译 已安装插件目录由 `desktop/internal/pluginpkg`(`pluginpkg.DefaultRoot()`)按平台管理:macOS 为 `~/Library/Application Support/Lithe Desktop/plugins`,Windows 为 `%LOCALAPPDATA%\Lithe Desktop\plugins`,Linux 为 `/lithe-desktop/plugins`。各个插件由自己的仓库负责构建、校验、签名与发布,桌面主仓库不内置插件打包器或签名密钥;宿主下载校验并经用户批准后,先在 `/.staging/` 解压,再原子重命名到 `///`,卸载时先移入 `/.trash/` 再删除,可写状态统一落在 `/.state//`。已安装版本目录在运行时只读,重装、回滚和卸载均由插件安装流程统一处理,且位于 app bundle 和 Windows 安装目录之外,不改变代码签名或桌面增量更新基线;它们属于用户运行时目录而非工作树构建缓存,任何情况下都不得跨 Git 工作树复制或共享。 +桌面进程在同一个可写插件根目录用 `.staging-sweep.lock` 协调启动清理与插件安装、后台暂存、卸载。锁文件由宿主管理,进程关闭句柄或退出时操作系统释放锁,文件名保留供下个进程使用。该文件位于应用安装目录之外,和插件暂存目录同属用户运行时状态,不能跨检出复制,对代码签名及 Sparkle 增量基线没有影响。 + Build Provider 的模型与依赖快照位于插件根(`pluginpkg.DefaultRoot`)下的 `.state///build//`。会话拥有其缓存、日志和临时输出;模型失效可重建,插件卸载随所属状态清理。工作区摘要只是归属键,不是构建身份。 它属于具体插件、构建系统和工作区的可变上游状态,没有版本/平台/架构/工具链 identity stamp, 不跨工作树复制或共享。 diff --git a/shared/platform-feature-matrix/features/lsp-navigation-edits.json b/shared/platform-feature-matrix/features/lsp-navigation-edits.json index 04e264e17..01d855632 100644 --- a/shared/platform-feature-matrix/features/lsp-navigation-edits.json +++ b/shared/platform-feature-matrix/features/lsp-navigation-edits.json @@ -38,7 +38,7 @@ ] }, "owner": "Language Tooling", - "verification": "Viva(2026-11-24):已接入双向继承/实现跳转:Go to Implementation(Option+Command+B / Ctrl+Alt+B、Alt+Command/Ctrl+点击、编辑器右键菜单,调用 textDocument/implementation;语言服务器未声明 implementationProvider 时回退到行首 navigate-down 动作,空结果提示未找到实现)与 Go to Super Declaration(Command+U / Ctrl+U、编辑器右键菜单,通过行首 navigate-up 动作跳转到父类或接口定义,空结果提示未找到父声明);Windows/UNC 与 POSIX file URI 路径经 fileURILocalPath 统一规范化。单元测试与无头视觉测试覆盖快捷键、修饰点击、回退路径、右键菜单及就地弹窗定位(pluginsemantics_test.go、navigation_gutter_visual_test.go);尚未在 macOS/Windows 原生窗口人工验收。 Viva(2026-11-12):跳转沿用 IntelliJ IDEA 的 Go to Declaration or Usages。Command+B(Windows/Linux 为 Control+B)与 Command/Control+点击、F12、编辑器菜单走同一请求:在使用处打开声明;在声明本身上,由 Core 的 lsp.declarationOrUsages 判定定义结果就是手势所在位置,改为以 includeDeclaration: false 请求引用,单个用法直接打开、多个进入选择列表、没有时提示,不进入 References 工具窗口;查找引用(Shift+F12)仍包含声明。单元测试覆盖四种入口与三种结果。尚未在 macOS/Windows 原生窗口验收。 Viva(2026-11-10):查找引用(Shift+F12,列表虚拟化、键盘导航、点击打开)、重命名(F2/Shift+F6,经 Core 的 lsp.planWorkspaceEdit 规划,已打开文档走撤销栈、未打开文件走受保护写入并在失败时回滚)和格式化文档(Control+Alt+L,Option+Command+L 于 macOS,局部编辑走撤销栈)已接入;非 file URI 目标提示不可用而不崩溃。真实 clangd 无头窗口验证了引用与重命名。尚缺:格式化选区(Core 无 rangeFormatting 操作)、右键菜单入口、非文件 URI 的只读内容(依赖插件内容提供者)、语义标记。 Viva(2026-11-09):定义跳转支持 F12、Command/Ctrl+点击与多目标选择列表,目标在 Viva 编辑器中按 Core 规范化位置打开;无头 Viva 窗口使用真实 clangd 隔离插件验证了从调用跳到头文件声明的完整路径。尚未在 macOS/Windows 原生窗口验收;引用、语义标记、格式化和重命名仍未接入,因此保持部分实现。 验证定义、引用、语义标记和 UTF-16 文本编辑的坐标转换。 Windows 验证 Ctrl+点击临时失败后无需修改源码即可重试成功,服务重启或文档重新连接后不复用旧位置,切换编辑器时丢弃迟到结果。 macOS 验证 Command 悬停仅在定义可用时显示链接颜色、下划线和手形,松键/移出/切换文档后清除;点击单目标直接打开定义,同文件方法调用不误转实现查询,主/分屏均保留原生导航历史。 macOS 普通说明悬停 500 ms,Command 提示在语义解析后立即显示;深浅主题及透明编辑器背景下,说明面板复用共享 popup chrome 并保持不透明,代码和说明文字分别使用编程/UI 字体。 macOS 悬停生命周期回归:普通说明与 Command 提示分别拥有状态;松键仅关闭 Command 提示;Esc、滚动、编辑、模型切换和失焦清除提示,取消后迟到结果不得重开;鼠标进入面板仍可交互。Command 内边距对齐 IDEA 6/6/5/6,普通说明保留原排版。运行真实 WebKit 生命周期检查;完整应用人工视觉验收待补。 macOS 实现选择列表使用原生共享 litheDropdown,验证 Esc、点击外部、关闭后重开、选择目标与切换标签关闭,并清除旧导航操作。共享搜索框、行选择样式及外框,列表按结果数收缩;上下键与回车可操作,输入法组合不误导航。查询语义分流问题不在本轮布局修复范围内。 Command 候选符号在异步解析期间立即使用稳定视图层小手光标,链接色与下划线仍等待确认;负结果在同一手势内不重复查询,松键移出后允许重试。真实 WebKit 使用原生回复闸门验证慢服务、重绘、逐像素移动和迟到回复不造成指针闪烁或残留。 macOS Command 导航提示使用 Monaco Delayed 模式及既有 500ms hover 延迟,避免快速经过符号时立即弹窗;手形/下划线独立反馈。WebKit 验证延迟模式与首刻不显示,并覆盖松键、滚动、失焦、编辑、切换取消及统一样式。 Command 悬停候选词同步呈现手形、变色、下划线,不等待 native definitionHover;面板仍在语义确认后延迟 500ms,与即时导航装饰分离。无目标或失败撤销候选反馈,同一词内移动不重复闪动;真实导航仍由点击请求解析。WebKit 显式阻塞 native 回复验证即时装饰,并验证负结果清除。 Command hover 与点击复用 Monaco/TextMate token 类型过滤注释、字符串和正则正文;多行注释不凭单行文本猜测。词法解析成本过高时暂不显示候选。WebKit 覆盖行注释、多行注释、字符串不高亮且不导航,真实代码慢回复仍即时反馈。 macOS 定义跳转默认关闭;用测试内联的、声明 editorNavigation 的合成插件启用后验证 Command 悬停/点击和 F12,关闭后验证专属手势监听、动作、装饰与延迟提示被释放,停止发出定义可用性请求,迟到回复不能恢复提示或结果。覆盖重复开关、现存/新建分屏、插件设置持久化、恢复默认值和插件禁用撤销;补全、诊断、普通文档悬停和独立的用法/继承标记功能保持可用。Windows 尚未实现此开关。 全局跳转开关同步所有已有项目窗口,新项目读取存储值;双项目反复切换验证旧操作失效与对象释放。未声明 editorNavigation 的语言保留原有点击/F12;不增加其悬停查询。WebKit 100 次切换验证监听恢复基线、窗口监听清零及模型/编辑器数量不增长;该结果不是长期堆内存采样。 Windows 的工作区编辑与格式化通过 lsp.applyTextEdits 应用整批修改;验证中文、emoji、CRLF、非法和重叠范围,以及任一目标校验失败时不修改其他缓冲区。列号夹取与代理对边界处理沿用 Core。 异步编辑返回后必须统一检查工作区及缓冲区内容、版本和身份,拒绝覆盖新输入;Core 范围错误按稳定类别翻译。 Windows 查找引用保留语言服务器返回的同文件同一行各个位置,覆盖当前行中多个引用。", + "verification": "Viva(2026-11-24):已接入双向继承/实现跳转:Go to Implementation(Option+Command+B / Ctrl+Alt+B、Alt+Command/Ctrl+点击、编辑器右键菜单,调用 textDocument/implementation;语言服务器未声明 implementationProvider 时回退到行首 navigate-down 动作,空结果提示未找到实现)与 Go to Super Declaration(Command+U / Ctrl+U、编辑器右键菜单,通过行首 navigate-up 动作跳转到父类或接口定义,空结果提示未找到父声明);Windows/UNC 与 POSIX file URI 路径经 fileURILocalPath 统一规范化。单元测试与无头视觉测试覆盖快捷键、修饰点击、回退路径、右键菜单及就地弹窗定位(pluginsemantics_test.go、navigation_gutter_visual_test.go);尚未在 macOS/Windows 原生窗口人工验收。 Viva(2026-11-12):跳转沿用 IntelliJ IDEA 的 Go to Declaration or Usages。Command+B(Windows/Linux 为 Control+B)与 Command/Control+点击、F12、编辑器菜单走同一请求:在使用处打开声明;在声明本身上,由 Core 的 lsp.declarationOrUsages 判定定义结果就是手势所在位置,改为以 includeDeclaration: false 请求引用,单个用法直接打开、多个进入选择列表、没有时提示,不进入 References 工具窗口;查找引用(Shift+F12)仍包含声明。单元测试覆盖四种入口与三种结果。尚未在 macOS/Windows 原生窗口验收。 Viva(2026-11-10):查找引用(Shift+F12,列表虚拟化、键盘导航、点击打开)、重命名(F2/Shift+F6,经 Core 的 lsp.planWorkspaceEdit 规划,已打开文档走撤销栈、未打开文件走受保护写入并在失败时回滚)和格式化文档(Control+Alt+L,Option+Command+L 于 macOS,局部编辑走撤销栈)已接入;非 file URI 目标提示不可用而不崩溃。真实 clangd 无头窗口验证了引用与重命名。尚缺:格式化选区(Core 无 rangeFormatting 操作)、右键菜单入口、非文件 URI 的只读内容(依赖插件内容提供者)、语义标记。 Viva(2026-11-09):定义跳转支持 F12、Command/Ctrl+点击与多目标选择列表,目标在 Viva 编辑器中按 Core 规范化位置打开;无头 Viva 窗口使用真实 clangd 隔离插件验证了从调用跳到头文件声明的完整路径。尚未在 macOS/Windows 原生窗口验收;引用、语义标记、格式化和重命名仍未接入,因此保持部分实现。 验证定义、引用、语义标记和 UTF-16 文本编辑的坐标转换。 Windows 验证 Ctrl+点击临时失败后无需修改源码即可重试成功,服务重启或文档重新连接后不复用旧位置,切换编辑器时丢弃迟到结果。 macOS 验证 Command 悬停仅在定义可用时显示链接颜色、下划线和手形,松键/移出/切换文档后清除;点击单目标直接打开定义,同文件方法调用不误转实现查询,主/分屏均保留原生导航历史。 macOS 普通说明悬停 500 ms,Command 提示在语义解析后立即显示;深浅主题及透明编辑器背景下,说明面板复用共享 popup chrome 并保持不透明,代码和说明文字分别使用编程/UI 字体。 macOS 悬停生命周期回归:普通说明与 Command 提示分别拥有状态;松键仅关闭 Command 提示;Esc、滚动、编辑、模型切换和失焦清除提示,取消后迟到结果不得重开;鼠标进入面板仍可交互。Command 内边距对齐 IDEA 6/6/5/6,普通说明保留原排版。运行真实 WebKit 生命周期检查;完整应用人工视觉验收待补。 macOS 实现选择列表使用原生共享 litheDropdown,验证 Esc、点击外部、关闭后重开、选择目标与切换标签关闭,并清除旧导航操作。共享搜索框、行选择样式及外框,列表按结果数收缩;上下键与回车可操作,输入法组合不误导航。查询语义分流问题不在本轮布局修复范围内。 Command 候选符号在异步解析期间立即使用稳定视图层小手光标,链接色与下划线仍等待确认;负结果在同一手势内不重复查询,松键移出后允许重试。真实 WebKit 使用原生回复闸门验证慢服务、重绘、逐像素移动和迟到回复不造成指针闪烁或残留。 macOS Command 导航提示使用 Monaco Delayed 模式及既有 500ms hover 延迟,避免快速经过符号时立即弹窗;手形/下划线独立反馈。WebKit 验证延迟模式与首刻不显示,并覆盖松键、滚动、失焦、编辑、切换取消及统一样式。 Command 悬停候选词同步呈现手形、变色、下划线,不等待 native definitionHover;面板仍在语义确认后延迟 500ms,与即时导航装饰分离。无目标或失败撤销候选反馈,同一词内移动不重复闪动;真实导航仍由点击请求解析。WebKit 显式阻塞 native 回复验证即时装饰,并验证负结果清除。 Command hover 与点击复用 Monaco/TextMate token 类型过滤注释、字符串和正则正文;多行注释不凭单行文本猜测。词法解析成本过高时暂不显示候选。WebKit 覆盖行注释、多行注释、字符串不高亮且不导航,真实代码慢回复仍即时反馈。 macOS 定义跳转默认关闭;用测试内联的、声明 editorNavigation 的合成插件启用后验证 Command 悬停/点击和 F12,关闭后验证专属手势监听、动作、装饰与延迟提示被释放,停止发出定义可用性请求,迟到回复不能恢复提示或结果。覆盖重复开关、现存/新建分屏、插件设置持久化、恢复默认值和插件禁用撤销;补全、诊断、普通文档悬停和独立的用法/继承标记功能保持可用。Windows 尚未实现此开关。 全局跳转开关同步所有已有项目窗口,新项目读取存储值;双项目反复切换验证旧操作失效与对象释放。未声明 editorNavigation 的语言保留原有点击/F12;不增加其悬停查询。WebKit 100 次切换验证监听恢复基线、窗口监听清零及模型/编辑器数量不增长;该结果不是长期堆内存采样。 Windows 的工作区编辑与格式化通过 lsp.applyTextEdits 应用整批修改;验证中文、emoji、CRLF、非法和重叠范围,以及任一目标校验失败时不修改其他缓冲区。列号夹取与代理对边界处理沿用 Core。 异步编辑返回后必须统一检查工作区及缓冲区内容、版本和身份,拒绝覆盖新输入;Core 范围错误按稳定类别翻译。 Windows 查找引用保留语言服务器返回的同文件同一行各个位置,覆盖当前行中多个引用。 导航回归的目标 URI 使用 Core 的 lsp.documentUri 生成,覆盖 Windows 盘符路径和 POSIX 路径;通过窗口唤醒等待目标文档或导航列表实际打开。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": { diff --git a/shared/platform-feature-matrix/features/plugin-auto-update.json b/shared/platform-feature-matrix/features/plugin-auto-update.json index 86364226f..5370be75b 100644 --- a/shared/platform-feature-matrix/features/plugin-auto-update.json +++ b/shared/platform-feature-matrix/features/plugin-auto-update.json @@ -4,8 +4,8 @@ "group": "插件与主题", "capability": "插件管理页面可以主动启用或关闭自动更新。宿主在窗口前台定期检查同源且保持已批准权限与程序声明的新版,完整验包与保存批准后暂存在插件数据目录,重启 Lithe 时复核并激活。手动与后台的市场更新共用增量下载,精确基线与补丁均可用时重建并校验完整 ZIP,缺失或失败回退到完整包。", "owner": "Extensions", - "notes": "Viva Go 跨平台实现,默认关闭;首次开启后 30 秒检查,此后每 24 小时检查,窗口不活跃时暂缓。审批来源必须是首次经市场安装时记录的 Core 规范化 IndexURL;旧版本无来源记录的插件需要手动通过商城更新一次以建立来源。下载经市场 SHA-256 验证与安装审查,安装前再次核对启用状态和此前审批;不会通过切换/重启运行中的插件加载新版本。同一进程内使用同一个插件数据根的工作台共享更新轮次。可选补丁索引与实际读取的主索引来自同一市场修订,基线从限额缓存读取;批准记录和待激活包都准备完成后才进入下一次启动的候选。共享插件数据根的桌面进程串行发布、禁用和卸载,卸载在加锁后读取安装版本。 #2317:将 desktop.marketplace.autoUpdated 改为数量中性英文(“Plugins automatically updated: {count}. Restart Lithe to apply.”);中文不变。", - "verification": "自动化:desktop/internal/plugintrust/auto_update_test.go 检查同源/同权限/同程序集合,desktop/internal/marketplace/version_test.go 验证 Core 已排序版本判定,desktop/internal/workbench/plugin_auto_update_test.go 检查禁用/换源和版本过滤。手动:在插件设置齿轮开启自动更新,用合成测试市场和两版合成插件验证旧版有来源记录且权限相同时会后台下载、校验并安装;更改权限、程序声明或市场地址时不安装;后台中断/关闭开关后无临时文件与遗留子进程;重启应用后加载最新版本。macOS 和 Windows 真实原生测试及无头截图待执行。增量运输测试覆盖精确匹配、缺失索引或基线、损坏补丁或基线、目标重建不一致和取消,以及缓存锁不可用时仍交付已验包。安装包只读用例使用实际用户缓存路径。后台验证覆盖重启激活以及在重启前禁用后放弃待更新包。双进程测试覆盖共享缓存的 128 项和 256 MiB 上限、发布期间卸载等待、重试后移除新旧版本及发行包目录只读。 #2317:插件自动更新计数通知(desktop.marketplace.autoUpdated)改为数量中性英文,由 desktop/internal/i18n 与 settingswindow/workbench -race -tags 'dev vivahead' 覆盖,原生端待验收。", + "notes": "Viva Go 跨平台实现,默认关闭;首次开启后 30 秒检查,此后每 24 小时检查,窗口不活跃时暂缓。审批来源必须是首次经市场安装时记录的 Core 规范化 IndexURL;旧版本无来源记录的插件需要手动通过商城更新一次以建立来源。下载经市场 SHA-256 验证与安装审查,安装前再次核对启用状态和此前审批;不会通过切换/重启运行中的插件加载新版本。同一进程内使用同一个插件数据根的工作台共享更新轮次。可选补丁索引与实际读取的主索引来自同一市场修订,基线从限额缓存读取;批准记录和待激活包都准备完成后才进入下一次启动的候选。共享插件数据根的桌面进程串行发布、禁用和卸载,卸载在加锁后读取安装版本。 #2317:将 desktop.marketplace.autoUpdated 改为数量中性英文(“Plugins automatically updated: {count}. Restart Lithe to apply.”);中文不变。 桌面进程通过共享锁保护使用中的暂存与卸载临时目录,启动清理仅在可立即独占时执行。", + "verification": "自动化:desktop/internal/plugintrust/auto_update_test.go 检查同源/同权限/同程序集合,desktop/internal/marketplace/version_test.go 验证 Core 已排序版本判定,desktop/internal/workbench/plugin_auto_update_test.go 检查禁用/换源和版本过滤。手动:在插件设置齿轮开启自动更新,用合成测试市场和两版合成插件验证旧版有来源记录且权限相同时会后台下载、校验并安装;更改权限、程序声明或市场地址时不安装;后台中断/关闭开关后无临时文件与遗留子进程;重启应用后加载最新版本。macOS 和 Windows 真实原生测试及无头截图待执行。增量运输测试覆盖精确匹配、缺失索引或基线、损坏补丁或基线、目标重建不一致和取消,以及缓存锁不可用时仍交付已验包。安装包只读用例使用实际用户缓存路径。后台验证覆盖重启激活以及在重启前禁用后放弃待更新包。双进程测试覆盖共享缓存的 128 项和 256 MiB 上限、发布期间卸载等待、重试后移除新旧版本及发行包目录只读。 #2317:插件自动更新计数通知(desktop.marketplace.autoUpdated)改为数量中性英文,由 desktop/internal/i18n 与 settingswindow/workbench -race -tags 'dev vivahead' 覆盖,原生端待验收。 双进程回归在后台准备与提交之间启动另一插件服务,核对更新仍可暂存并随后激活。", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending", @@ -23,7 +23,9 @@ "desktop/internal/marketplace/delta_test.go", "desktop/internal/marketplace/archive_cache_test.go", "desktop/internal/plugininstall/pending.go", - "desktop/internal/pluginservice/package_lifecycle_test.go" + "desktop/internal/pluginservice/package_lifecycle_test.go", + "desktop/internal/pluginpkg/install.go", + "desktop/internal/pluginpkg/install_test.go" ] }, "windows": { @@ -43,7 +45,9 @@ "desktop/internal/marketplace/delta_test.go", "desktop/internal/marketplace/archive_cache_test.go", "desktop/internal/plugininstall/pending.go", - "desktop/internal/pluginservice/package_lifecycle_test.go" + "desktop/internal/pluginservice/package_lifecycle_test.go", + "desktop/internal/pluginpkg/install.go", + "desktop/internal/pluginpkg/install_test.go" ] } } diff --git a/shared/platform-feature-matrix/features/plugin-editor-actions.json b/shared/platform-feature-matrix/features/plugin-editor-actions.json index b9f29900a..7ca67b9cc 100644 --- a/shared/platform-feature-matrix/features/plugin-editor-actions.json +++ b/shared/platform-feature-matrix/features/plugin-editor-actions.json @@ -48,7 +48,7 @@ ] }, "owner": "Extensions", - "verification": "用 HTTP 与 SQL 两种解析函数注册动作;验证当前脏文档版本、同一行多动作、明确点击执行、编辑取消旧解析、撤回/关闭/会话替换清理,不自动重试副作用。慢收集保持未完成时刷新立即确认,仍能输入并完成保存屏障;整批只使用八秒预算。版本 2:同一行运行车道与导航车道各自排列且折叠箭头随之让位;备选项各自调用自己的函数;点击后返回的 reveal 位置由宿主展示,插件自己的返回成员不被解释;宿主图标表之外的图标名被 Core 拒绝,且与网页图标键一致。 #2069:收集超时只重试编辑器组正在显示的文档且有次数上限,后台标签页在被选中时重新收集;非超时失败不重试;重启后的后端会话注册同一 ID 时替换旧会话遗留的绑定,注册校验期间会话结束不留下绑定(hostactions_refresh_test.go、editoractions_test.go)。 2026-11-24:导航通道细分为 navigate-up 与 navigate-down 双槽位,新增 IDEA 风格多层导航图标(navigate-implemented 绿色 I↓、navigate-implementing 绿色 I↑、navigate-overridden 蓝色 O↓、navigate-overriding 蓝色 O↑),支持深浅主题切换自动重烘焙图标、行首悬停多行提示卡、抑制导航通道 Starting 提示并就地弹出多目标列表;editorview 行首图标绘制与命中测试保持零堆分配并忽略自动换行续行(lineicons_test.go、editoractions_test.go、navigation_gutter_visual_test.go)。", + "verification": "用 HTTP 与 SQL 两种解析函数注册动作;验证当前脏文档版本、同一行多动作、明确点击执行、编辑取消旧解析、撤回/关闭/会话替换清理,不自动重试副作用。慢收集保持未完成时刷新立即确认,仍能输入并完成保存屏障;整批只使用八秒预算。版本 2:同一行运行车道与导航车道各自排列且折叠箭头随之让位;备选项各自调用自己的函数;点击后返回的 reveal 位置由宿主展示,插件自己的返回成员不被解释;宿主图标表之外的图标名被 Core 拒绝,且与网页图标键一致。 #2069:收集超时只重试编辑器组正在显示的文档且有次数上限,后台标签页在被选中时重新收集;非超时失败不重试;重启后的后端会话注册同一 ID 时替换旧会话遗留的绑定,注册校验期间会话结束不留下绑定(hostactions_refresh_test.go、editoractions_test.go)。 2026-11-24:导航通道细分为 navigate-up 与 navigate-down 双槽位,新增 IDEA 风格多层导航图标(navigate-implemented 绿色 I↓、navigate-implementing 绿色 I↑、navigate-overridden 蓝色 O↓、navigate-overriding 蓝色 O↑),支持深浅主题切换自动重烘焙图标、行首悬停多行提示卡、抑制导航通道 Starting 提示并就地弹出多目标列表;editorview 行首图标绘制与命中测试保持零堆分配并忽略自动换行续行(lineicons_test.go、editoractions_test.go、navigation_gutter_visual_test.go)。 导航回归的目标 URI 使用 Core 的 lsp.documentUri 生成,覆盖 Windows 盘符路径和 POSIX 路径;通过窗口唤醒等待目标文档或导航列表实际打开。", "notes": "Viva:工具插件经 editor/registerActions 为所选文件注册动作,停止输入后宿主调用收集函数取得当前文档的动作,文本一变即丢弃;动作显示为行首图标(运行、调试、测试、向上导航、向下导航各一条通道,同一行多图标并排、点击打开该通道的菜单或直接运行唯一选项)并进入该行的编辑器菜单,点击再次调用插件;CodeLens 作为无图标的动作显示。消息全部由 Core 校验(editor_actions.go)。 2026-11-13:宿主先检查工作区 context,再只把动作声明交给 Core;注册与撤回动作会通知窗口重新收集已打开文档,语言服务器 ready 后也会刷新动作。回归使用真实 Core 解码,避免测试替身漏掉 context 被当作未知字段的问题。 同一文本版本的模型刷新使用文档本地呈现代际隔离旧收集结果;旧空结果或错误不能覆盖后到的当前动作。 2026-11-17(#2069):语言服务器 ready 后仍在导入大项目时收集会超时,按 2、4、8、16 秒再 30 秒退避,最多重试 10 次;只重试正在显示的文档,避免每个打开的文件各自追加请求。旧会话结束与新会话注册交错时,旧绑定曾永久占住同一 ID,新注册被拒,文件一直没有运行/调试图标;现在新会话替换旧会话的绑定,注册期间结束的会话自行撤回。 2026-11-24:导航通道拆分 navigate-up / navigate-down 双通道并与 4 个 IDEA 风格语义图标配合,悬浮显示轻量提示,点击不触发耗时任务 toast;多目标按行首图标就地锚定弹出。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", diff --git a/shared/platform-feature-matrix/features/plugin-host-editor-file-window-services.json b/shared/platform-feature-matrix/features/plugin-host-editor-file-window-services.json index 597d8ac85..a82dffccb 100644 --- a/shared/platform-feature-matrix/features/plugin-host-editor-file-window-services.json +++ b/shared/platform-feature-matrix/features/plugin-host-editor-file-window-services.json @@ -78,7 +78,7 @@ ] }, "owner": "Extensions", - "verification": "API-06–08:默认固定 Core main c6cef0b(含 Core #190 与 #187 增量更新),运行 scripts/desktop/desktop-go.sh test ./internal/core ./internal/pluginservice ./internal/workbench -run 'TestWorkspace(Reads|Find|Search|Watch)|TestPluginWorkspace' -count=1 及对应 -race 检查,验证真实文件分页、文本/二进制读取、资源封装与权限上下文隔离、dirty 文档仍读磁盘及项目关闭取消,搜索分页/查询游标/范围与磁盘隔离,以及 macOS Viva 原生监听的递归创建、原子保存、删除、调用方归属、会话/上下文释放、在途通知取消、根目录替换后的最终重扫与释放。Windows 原生验收按用户要求本轮不执行,保持 pending。API-11:scripts/desktop/desktop-go.sh test ./internal/pluginservice -run 'TestFileChanges|TestChangeError' 与 ./internal/workbench -run 'TestPlugin(Save|Create|Rename|Trash)'。两平台原生验收使用内联合成插件:读取分页目录、磁盘文件,验证链接与 .. 越界拒绝、取消和重开工作区隔离,再保存/另存为、复制、重命名打开文件、移到废纸篓并恢复;无头测试不能替代 Windows reparse point 与目录共享行为验收。验收后关闭应用并确认无残留进程。 工作流增量:macOS 执行 scripts/desktop/desktop-go.sh test ./internal/workbench ./internal/pluginservice ./internal/pluginview -run 'Test(Workflow|BrowserOpensOnlyHTTP|SessionRefresh|WorkbenchDefaultLayout)' -count=1 -timeout=45s 及同范围 -race。覆盖取消和释放、关闭上下文取消在途调用、HTTP 重定向与预算及错误脱敏、预览更新和会话隔离、只读 Diff、输出清空、进度部分更新、密码取消清理。TestVisualPluginWorkflow 生成深浅主题及中英文截图,CI 上传 plugin-workflow-visual artifact。系统 WebView、剪贴板、浏览器和文件管理器的整机验收仍待完成;Windows 本轮不验收。", + "verification": "API-06–08:默认固定 Core main c6cef0b(含 Core #190 与 #187 增量更新),运行 scripts/desktop/desktop-go.sh test ./internal/core ./internal/pluginservice ./internal/workbench -run 'TestWorkspace(Reads|Find|Search|Watch)|TestPluginWorkspace' -count=1 及对应 -race 检查,验证真实文件分页、文本/二进制读取、资源封装与权限上下文隔离、dirty 文档仍读磁盘及项目关闭取消,搜索分页/查询游标/范围与磁盘隔离,以及 macOS Viva 原生监听的递归创建、原子保存、删除、调用方归属、会话/上下文释放、在途通知取消、根目录替换后的最终重扫与释放。原生监听回归通过分属不同目录的夹具分别验证创建、原子替换和删除,再验证替换后立即删除可用一次合并通知表达;各操作只能由本路径、所在目录或重扫通知确认。Windows 原生整机验收保持 pending。API-11:scripts/desktop/desktop-go.sh test ./internal/pluginservice -run 'TestFileChanges|TestChangeError' 与 ./internal/workbench -run 'TestPlugin(Save|Create|Rename|Trash)'。两平台原生验收使用内联合成插件:读取分页目录、磁盘文件,验证链接与 .. 越界拒绝、取消和重开工作区隔离,再保存/另存为、复制、重命名打开文件、移到废纸篓并恢复;无头测试不能替代 Windows reparse point 与目录共享行为验收。验收后关闭应用并确认无残留进程。 工作流增量:macOS 执行 scripts/desktop/desktop-go.sh test ./internal/workbench ./internal/pluginservice ./internal/pluginview -run 'Test(Workflow|BrowserOpensOnlyHTTP|SessionRefresh|WorkbenchDefaultLayout)' -count=1 -timeout=45s 及同范围 -race。覆盖取消和释放、关闭上下文取消在途调用、HTTP 重定向与预算及错误脱敏、预览更新和会话隔离、只读 Diff、输出清空、进度部分更新、密码取消清理。TestVisualPluginWorkflow 生成深浅主题及中英文截图,CI 上传 plugin-workflow-visual artifact。系统 WebView、剪贴板、浏览器和文件管理器的整机验收仍待完成;Windows 本轮不验收。", "notes": "Viva 已接通 documents/list|getSnapshot、editor/getActive|getSelections|open|reveal|insertText|replaceSelections|applyEdits、window/showInformation|showWarning|showError、browser/openExternal(HTTP(S) 地址或已保存 HTML 资源)、documents/registerContentProvider、editor/registerProviders。编辑走编辑器自己的撤销栈,整批一步,按 view 修订号做版本隔离,只读/组字/过期版本被拒。editor/open 只落光标(范围起点)。API-11(documents.save、workspace.files.write)已接通:documents/save|saveAs|close 走文档自己的保存,磁盘冲突、硬链接、未命名文档、组字被拒并返回错误码,不弹窗;workspace/create(文件、文件夹、kind:\"symlink\" 的符号链接)|rename|copy|trash 的参数由 Core 严格检查,磁盘变更由 Core 内核命令 workspace.createEntry|renameEntry|copyEntry|resolveEntry 完成(不跟随最后一段、不覆盖),窗口只负责先保存其下文档、打开的文档跟随文件移动、本地历史、项目树和系统废纸篓;Windows 上建符号链接需要开发者模式或管理员,否则返回 failed。API-06(workspace.files.read)已接通本地工作区的 workspace/readDirectory|stat|readFile:路径、隐藏规则、有界分页、no-follow 和 128 KiB 磁盘读取预算均由 Core 执行,文本/base64 与截断前缀 identity 如实返回,不读取 dirty 文档;窗口关闭或替换会取消并拒绝旧结果,remote authority 明确拒绝。API-07/08 已接通 workspace/watch|findFiles|findText:Core 复用匹配、编码和隐藏/索引规则,以 no-follow 句柄搜索磁盘、处理分页游标与监听过滤;Viva 原生事件无空闲轮询,订阅按插件/会话/上下文释放,dispose 返回前停止通知;搜索每页和总结果最多 200,精确范围为 null。macOS 真实文件与原生事件测试已通过;Windows 本轮不验收。默认 Core 已固定到 main c6cef0b,包含 Core #190 与 #187 增量更新。整体条目仍含其他未完成能力,状态保持 partial/pending。Core #193 与 #194 的工作流已接入:Markdown/HTML 资源和内联只读预览、只读文本对比、快速选择和安全输入、剪贴板、文件管理器定位、输出、进度、状态项、有界 HTTP。Core 负责参数、默认值、权限、过滤排序与预算;Viva 只做原生 I/O 和呈现。HTML 在原生 WebView 不可用时于打开标签前拒绝。浏览器资源默认 requireSaved,不自动保存。HTTP 惰性复用连接,无 Cookie jar、不跟随重定向,错误不带 URL 或正文。长期资源按插件、会话和上下文释放,不新增磁盘缓存。复杂身份验证、Cookie 提取与下载到文件不在本次范围。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36",