跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

0016-workbench-image-progress.patch

73 行 · 2.0 KB历史下载
1diff --git a/pkg/downloader/resume.go b/pkg/downloader/resume.go
2--- a/pkg/downloader/resume.go
3+++ b/pkg/downloader/resume.go
4@@ -157,6 +157,17 @@
5 bar.Start()
6 defer bar.Finish()
7 reader := &downloadActivityReader{reader: resp.Body, timer: idle}
8+ // The desktop workbench consumes complete lines when stderr is a pipe.
9+ // Range responses count the bytes already present in the partial file.
10+ if os.Getenv("CAGE_SETUP_PROGRESS") == "1" {
11+ reader.received = offset
12+ reader.total = total
13+ reader.report = func(received, total int64) {
14+ fmt.Fprintf(os.Stderr, "CAGE_IMAGE_BYTES %d %d\n", received, total)
15+ }
16+ reader.report(offset, total)
17+ reader.lastReport = time.Now()
18+ }
19 n, err := io.Copy(out, bar.NewProxyReader(reader))
20 if err != nil {
21 return true, err
22@@ -172,6 +183,10 @@
23 if total >= 0 && n+offset != total {
24 return true, io.ErrUnexpectedEOF
25 }
26+ if reader.report != nil {
27+ reader.report(reader.received, total)
28+ fmt.Fprintln(os.Stderr, "CAGE_IMAGE_VERIFY")
29+ }
30 if err := out.Sync(); err != nil {
31 return false, err
32 }
33@@ -186,14 +201,24 @@
34 }
35
36 type downloadActivityReader struct {
37- reader io.Reader
38- timer *time.Timer
39+ reader io.Reader
40+ timer *time.Timer
41+ received, total int64
42+ report func(int64, int64)
43+ lastReport time.Time
44 }
45
46 func (r *downloadActivityReader) Read(p []byte) (int, error) {
47 n, err := r.reader.Read(p)
48 if n > 0 {
49 r.timer.Reset(time.Minute)
50+ if r.report != nil {
51+ r.received += int64(n)
52+ if time.Since(r.lastReport) >= time.Second {
53+ r.report(r.received, r.total)
54+ r.lastReport = time.Now()
55+ }
56+ }
57 }
58 return n, err
59 }
60diff --git a/pkg/instance/start.go b/pkg/instance/start.go
61index 489df5f..10b4d2f 100644
62--- a/pkg/instance/start.go
63+++ b/pkg/instance/start.go
64@@ -183,6 +183,9 @@ func Prepare(ctx context.Context, inst *limatype.Instance, guestAgent string) (*
65 }
66 }
67
68+ if os.Getenv("CAGE_SETUP_PROGRESS") == "1" {
69+ fmt.Fprintln(os.Stderr, "CAGE_IMAGE_READY")
70+ }
71 if err := limaDriver.CreateDisk(ctx); err != nil {
72 return nil, err
73 }