Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

feat: report a problem with a redacted diagnostics report

baiyuze992a63f5024e
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 0000000..321c3bd
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,28 @@
+# CopySync 的「设置 → 反馈问题 → 在 GitHub 上提问题」打开这个模板,并预先填好 version。
+# 改了字段的 id,要一起改 ui/lib/widgets/feedback_dialog.dart 里的地址。
+name: Bug report / 问题反馈
+description: Something doesn't work as expected. / 用起来有问题。
+body:
+ - type: textarea
+ id: what
+ attributes:
+ label: What happened / 发生了什么
+ description: What you did, what you expected, and what happened instead. / 做了什么、以为会怎样、实际怎样。
+ validations:
+ required: true
+ - type: input
+ id: version
+ attributes:
+ label: CopySync version / 版本
+ placeholder: "1.7.0"
+ - type: textarea
+ id: diagnostics
+ attributes:
+ label: Diagnostics report / 诊断报告
+ description: >-
+ In CopySync, open Settings → Report a problem and copy the report, then paste it here.
+ Device names, the server address, public IP addresses and file names are already replaced;
+ read it through before posting, because issues are public.
+ 在 CopySync 的「设置 → 反馈问题」里拷贝报告,粘贴到这里。设备名、服务器地址、公网 IP 和文件名已经替换掉;
+ 问题是公开的,贴之前请看一遍。
+ render: text
diff --git a/client-core/cmd/copysyncd/main.go b/client-core/cmd/copysyncd/main.go
index 7a625b6..0f4a949 100644
--- a/client-core/cmd/copysyncd/main.go
+++ b/client-core/cmd/copysyncd/main.go
@@ -58,15 +58,14 @@ func main() {
os.Exit(runSupervisor(*dataDir))
}
- level := slog.LevelInfo
if *verbose {
- level = slog.LevelDebug
+ logLevel.Set(slog.LevelDebug)
}
logOut := logOutput(*dataDir)
if *probe {
logOut = os.Stderr
}
- slog.SetDefault(slog.New(slog.NewTextHandler(logOut, &slog.HandlerOptions{Level: level})))
+ slog.SetDefault(slog.New(slog.NewTextHandler(logOut, &slog.HandlerOptions{Level: &logLevel})))
if *probe {
probeClipboard()
@@ -208,6 +207,12 @@ func run(dataDir string) error {
// 状态快照要由 gRPC 服务组装,而它晚于 peerMgr 创建,这里先记下"状态变了",
// 等服务就绪后统一推送。容量 1 让连续的变化合并成一次刷新。
statusDirty := make(chan struct{}, 1)
+ verbose := &verboseLog{base: logLevel.Level(), changed: func() {
+ select {
+ case statusDirty <- struct{}{}:
+ default:
+ }
+ }}
peerMgr, err := peers.NewManager(peers.Options{
Identity: id,
@@ -331,6 +336,9 @@ func run(dataDir string) error {
ConfirmPairing: peerMgr.ConfirmPairing,
Unpair: peerMgr.Unpair,
SetDeviceAddress: peerMgr.SetDeviceAddress,
+ LogFiles: func() ([]string, string) { return logFiles(dataDir) },
+ VerboseLog: verbose.Set,
+ VerboseUntil: verbose.Until,
ShowNearby: peerMgr.ShowNearby,
Nearby: peerMgr.Nearby,
PairNearby: peerMgr.PairNearby,
diff --git a/client-core/cmd/copysyncd/platform_other.go b/client-core/cmd/copysyncd/platform_other.go
index f73fdb0..1048490 100644
--- a/client-core/cmd/copysyncd/platform_other.go
+++ b/client-core/cmd/copysyncd/platform_other.go
@@ -6,6 +6,7 @@ import (
"context"
"io"
"os"
+ "path/filepath"
)
func startTray(context.Context, context.CancelFunc, bool) func() { return func() {} }
@@ -14,6 +15,16 @@ func startTray(context.Context, context.CancelFunc, bool) func() { return func()
func logOutput(string) io.Writer { return os.Stderr }
+// logFiles 是诊断报告要读的日志:launchd 把标准错误输出写到这里(见界面里写 LaunchAgent 的地方),
+// 不轮转;panic 也直接写进去,没有单独的 crash.log。
+func logFiles(string) (logs []string, crash string) {
+ home, err := os.UserHomeDir()
+ if err != nil {
+ return nil, ""
+ }
+ return []string{filepath.Join(home, "Library", "Logs", "CopySync", "daemon.log")}, ""
+}
+
func acquireInstance(string) (release func(), ok bool) { return func() {}, true }
func runSupervisor(string) int {
diff --git a/client-core/cmd/copysyncd/supervisor.go b/client-core/cmd/copysyncd/supervisor.go
index e8f18ef..c45ef1a 100644
--- a/client-core/cmd/copysyncd/supervisor.go
+++ b/client-core/cmd/copysyncd/supervisor.go
@@ -44,6 +44,16 @@ func logOutput(dataDir string) io.Writer {
return w
}
+// logFiles 是诊断报告要读的日志,与 logOutput 写的是同一处:轮转出去的旧文件在前。
+func logFiles(dataDir string) (logs []string, crash string) {
+ paths, err := resolvePaths(dataDir)
+ if err != nil {
+ return nil, ""
+ }
+ dir := filepath.Join(paths.Root, "logs")
+ return []string{filepath.Join(dir, "daemon.log.1"), filepath.Join(dir, "daemon.log")}, filepath.Join(dir, "crash.log")
+}
+
// runSupervisor 是守护模式:拉起后台服务,它异常退出就隔一会儿再拉起。
//
// 子进程正常退出(退出码 0:用户注销、或界面要求停止)或发现已有实例在运行时,
diff --git a/client-core/cmd/copysyncd/verbose.go b/client-core/cmd/copysyncd/verbose.go
new file mode 100644
index 0000000..d42732c
--- /dev/null
+++ b/client-core/cmd/copysyncd/verbose.go
@@ -0,0 +1,62 @@
+package main
+
+import (
+ "log/slog"
+ "sync"
+ "time"
+)
+
+// logLevel 是后台服务的日志级别:平时记 Info;用 -v 启动、或者界面里临时打开详细日志时记 Debug。
+var logLevel slog.LevelVar
+
+// verboseLog 让界面临时打开详细日志,到时间自动关回去:详细日志量大,一直开着会占满磁盘。
+// 有些连接问题只在详细日志里看得出原因,反馈问题时先打开它、重现一次。
+type verboseLog struct {
+ mu sync.Mutex
+ base slog.Level // 关回去时的级别:用 -v 启动的一直是 Debug
+ until time.Time
+ timer *time.Timer
+ changed func() // 打开、关闭时调用,让界面刷新状态
+}
+
+// Set 打开详细日志 d 这么久,d 不大于 0 时立即关闭。返回打开到什么时候,关闭时为零值。
+func (v *verboseLog) Set(d time.Duration) time.Time {
+ v.mu.Lock()
+ if v.timer != nil {
+ v.timer.Stop()
+ v.timer = nil
+ }
+ if d <= 0 {
+ v.until = time.Time{}
+ logLevel.Set(v.base)
+ slog.Info("详细日志已关闭")
+ } else {
+ until := time.Now().Add(d)
+ v.until = until
+ logLevel.Set(slog.LevelDebug)
+ slog.Info("详细日志已打开", "到", until.Format("15:04:05"))
+ v.timer = time.AfterFunc(d, func() { v.expire(until) })
+ }
+ until := v.until
+ v.mu.Unlock()
+ if v.changed != nil {
+ v.changed()
+ }
+ return until
+}
+
+// expire 是计时器到点后的关闭。期间用户又打开过一次的话,until 已经变了,这次到点不算数
+func (v *verboseLog) expire(until time.Time) {
+ v.mu.Lock()
+ current := v.until.Equal(until)
+ v.mu.Unlock()
+ if current {
+ v.Set(0)
+ }
+}
+
+func (v *verboseLog) Until() time.Time {
+ v.mu.Lock()
+ defer v.mu.Unlock()
+ return v.until
+}
diff --git a/client-core/cmd/copysyncd/verbose_test.go b/client-core/cmd/copysyncd/verbose_test.go
new file mode 100644
index 0000000..6bd4306
--- /dev/null
+++ b/client-core/cmd/copysyncd/verbose_test.go
@@ -0,0 +1,51 @@
+package main
+
+import (
+ "log/slog"
+ "testing"
+ "time"
+)
+
+func TestVerboseLog(t *testing.T) {
+ logLevel.Set(slog.LevelInfo)
+ t.Cleanup(func() { logLevel.Set(slog.LevelInfo) })
+ changes := 0
+ v := &verboseLog{base: slog.LevelInfo, changed: func() { changes++ }}
+
+ until := v.Set(50 * time.Millisecond)
+ if until.IsZero() || logLevel.Level() != slog.LevelDebug || !v.Until().Equal(until) {
+ t.Fatalf("打开后:until=%v level=%v", until, logLevel.Level())
+ }
+ // 到点自动关回平时的级别
+ deadline := time.Now().Add(2 * time.Second)
+ for logLevel.Level() != slog.LevelInfo && time.Now().Before(deadline) {
+ time.Sleep(10 * time.Millisecond)
+ }
+ if logLevel.Level() != slog.LevelInfo || !v.Until().IsZero() {
+ t.Fatalf("到点后没有关闭:level=%v until=%v", logLevel.Level(), v.Until())
+ }
+
+ // 上一轮的计时器晚到一步,不能把刚刚重新打开的详细日志关掉
+ old := v.Set(time.Hour)
+ v.Set(time.Hour)
+ v.expire(old)
+ if logLevel.Level() != slog.LevelDebug || v.Until().IsZero() {
+ t.Error("过期的计时器把新打开的详细日志关掉了")
+ }
+ v.Set(0)
+ if logLevel.Level() != slog.LevelInfo || changes < 4 {
+ t.Errorf("关闭后:level=%v,通知 %d 次", logLevel.Level(), changes)
+ }
+}
+
+// 用 -v 启动的,关掉临时的详细日志后仍是 Debug
+func TestVerboseLogKeepsFlag(t *testing.T) {
+ logLevel.Set(slog.LevelDebug)
+ t.Cleanup(func() { logLevel.Set(slog.LevelInfo) })
+ v := &verboseLog{base: slog.LevelDebug}
+ v.Set(time.Hour)
+ v.Set(0)
+ if logLevel.Level() != slog.LevelDebug {
+ t.Errorf("level=%v,应保持 Debug", logLevel.Level())
+ }
+}
diff --git a/client-core/internal/diag/diag_test.go b/client-core/internal/diag/diag_test.go
new file mode 100644
index 0000000..2d05160
--- /dev/null
+++ b/client-core/internal/diag/diag_test.go
@@ -0,0 +1,106 @@
+package diag
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/baiyuze/copysync/client-core/internal/config"
+ pb "github.com/baiyuze/copysync/proto/gen/copysync/v1"
+)
+
+func sampleInput(t *testing.T, log string) Input {
+ dir := t.TempDir()
+ path := filepath.Join(dir, "daemon.log")
+ if err := os.WriteFile(path, []byte(log), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ cfg := config.Default()
+ cfg.DeviceName = "张三的 MacBook Pro"
+ cfg.SignalingURL = "ws://sync.example.com:8787/signal"
+ return Input{
+ Now: time.Date(2026, 10, 13, 20, 50, 0, 0, time.UTC),
+ Version: "1.7.0",
+ Config: cfg,
+ Status: &pb.Status{SignalingConnected: true, LanEnabled: true},
+ Self: &pb.Device{Id: "self", Name: "张三的 MacBook Pro", Platform: "darwin"},
+ Peers: []*pb.Device{{Id: "b", Name: "DESKTOP-LISI", Platform: "windows", Connection: pb.ConnectionKind_CONNECTION_KIND_DIRECT}},
+ LogFiles: []string{path},
+ LogLines: 50,
+ Home: "/Users/zhangsan",
+ FileNames: []string{"离职申请.docx", "a"},
+ }
+}
+
+func TestReportRedacts(t *testing.T) {
+ log := strings.Join([]string{
+ `time=2026-10-13T20:41:02.123+08:00 level=INFO msg=配对成功 peer="DESKTOP-LISI" device=b`,
+ `time=2026-10-13T20:41:03.000+08:00 level=INFO msg=信令已连接 url=ws://sync.example.com:8787/signal`,
+ `time=2026-10-13T20:41:04.000+08:00 level=WARN msg=解包失败 err="open /Users/zhangsan/Downloads/离职申请.docx: permission denied"`,
+ `time=2026-10-13T20:41:05.000+08:00 level=DEBUG msg=候选 addr=203.0.113.7:51234 lan=192.168.1.20:8788 ts=100.88.20.5`,
+ `time=2026-10-13T20:41:06.000+08:00 level=DEBUG msg=候选 v6=2001:db8::1 local=fe80::1 mac=aa:bb:cc:dd:ee:ff`,
+ }, "\n") + "\n"
+ report := Build(sampleInput(t, log))
+
+ for _, secret := range []string{"张三", "LISI", "sync.example.com", "zhangsan", "离职申请", "203.0.113.7", "2001:db8::1"} {
+ if strings.Contains(report, secret) {
+ t.Errorf("报告里还有 %q:\n%s", secret, report)
+ }
+ }
+ for _, kept := range []string{
+ "<this-device>", "<device-1>", "ws://<server>:8787/signal", "~/Downloads/<file>", "<public-ip>:51234",
+ "192.168.1.20:8788", "100.88.20.5", "fe80::1", "aa:bb:cc:dd:ee:ff", "20:41:06.000+08:00",
+ "Log (last 5 lines)", "1.7.0",
+ } {
+ if !strings.Contains(report, kept) {
+ t.Errorf("报告里应当有 %q:\n%s", kept, report)
+ }
+ }
+ // 太短的文件名不替换,免得把日志里的普通字词也换掉
+ if !strings.Contains(report, `err="open ~/Downloads/<file>: permission denied"`) {
+ t.Errorf("路径没有按预期脱敏:\n%s", report)
+ }
+ if strings.Count(report, "<file>") != 1 {
+ t.Errorf("只有那个文件名该被替换:\n%s", report)
+ }
+}
+
+func TestTailLines(t *testing.T) {
+ dir := t.TempDir()
+ old := filepath.Join(dir, "daemon.log.1")
+ cur := filepath.Join(dir, "daemon.log")
+ _ = os.WriteFile(old, []byte("old 1\nold 2\nold 3\n"), 0o600)
+ _ = os.WriteFile(cur, []byte("new 1\r\nnew 2\n"), 0o600)
+
+ // 最新的文件不够时,从轮转出去的旧文件末尾补,顺序不乱
+ got := strings.Join(tailLines([]string{old, cur, filepath.Join(dir, "missing")}, 4), "|")
+ if got != "old 2|old 3|new 1|new 2" {
+ t.Errorf("tailLines = %q", got)
+ }
+
+ // 超长的一行截断
+ long := filepath.Join(dir, "long.log")
+ _ = os.WriteFile(long, []byte(strings.Repeat("长", 1000)+"\n"), 0o600)
+ if l := tailLines([]string{long}, 1)[0]; len([]rune(l)) != maxLineRunes+1 || !strings.HasSuffix(l, "…") {
+ t.Errorf("长行没有截断:%d 个字", len([]rune(l)))
+ }
+
+ // 只读末尾一段时,读到一半的第一行丢掉
+ big := filepath.Join(dir, "big.log")
+ _ = os.WriteFile(big, []byte(strings.Repeat("x", tailBytes)+"\nlast\n"), 0o600)
+ if got := tailLines([]string{big}, 5); len(got) != 1 || got[0] != "last" {
+ t.Errorf("大文件的末尾:%q", got)
+ }
+}
+
+func TestDuration(t *testing.T) {
+ for d, want := range map[time.Duration]string{
+ 72 * time.Hour: "3 days", 24 * time.Hour: "1 day", 12 * time.Hour: "12 hours", 90 * time.Minute: "1h30m0s",
+ } {
+ if got := duration(d); got != want {
+ t.Errorf("duration(%v) = %q,应为 %q", d, got, want)
+ }
+ }
+}
diff --git a/client-core/internal/diag/logs.go b/client-core/internal/diag/logs.go
new file mode 100644
index 0000000..bedc514
--- /dev/null
+++ b/client-core/internal/diag/logs.go
@@ -0,0 +1,63 @@
+package diag
+
+import (
+ "io"
+ "os"
+ "strings"
+ "unicode/utf8"
+)
+
+// 每个文件只读末尾这么多:要的最多一千来行,读整个文件没必要。Mac 上的日志由 launchd 写,不轮转,可能很大
+const tailBytes = 512 << 10
+
+// 单行太长的截断:一次网络出错的报错可能带出很长的内容,几行就能占满一份报告
+const maxLineRunes = 400
+
+// tailLines 取日志末尾的最多 n 行。files 按时间先后排列,轮转出去的旧文件在前:
+// 最新的文件不够 n 行时,再从前一个文件的末尾补。读不到的文件跳过。
+func tailLines(files []string, n int) []string {
+ var out []string
+ for i := len(files) - 1; i >= 0 && len(out) < n; i-- {
+ out = append(tailFile(files[i], n-len(out)), out...)
+ }
+ return out
+}
+
+func tailFile(path string, n int) []string {
+ f, err := os.Open(path)
+ if err != nil {
+ return nil
+ }
+ defer f.Close()
+ info, err := f.Stat()
+ if err != nil {
+ return nil
+ }
+ start := max(0, info.Size()-tailBytes)
+ if _, err := f.Seek(start, io.SeekStart); err != nil {
+ return nil
+ }
+ data, err := io.ReadAll(f)
+ if err != nil {
+ return nil
+ }
+ text := strings.TrimRight(strings.ToValidUTF8(string(data), "�"), "\r\n")
+ if text == "" {
+ return nil
+ }
+ lines := strings.Split(text, "\n")
+ if start > 0 {
+ lines = lines[1:] // 从文件中间开始读,第一行只读到了后半截
+ }
+ if len(lines) > n {
+ lines = lines[len(lines)-n:]
+ }
+ for i, l := range lines {
+ l = strings.TrimRight(l, "\r")
+ if utf8.RuneCountInString(l) > maxLineRunes {
+ l = string([]rune(l)[:maxLineRunes]) + "…"
+ }
+ lines[i] = l
+ }
+ return lines
+}
diff --git a/client-core/internal/diag/osinfo_darwin.go b/client-core/internal/diag/osinfo_darwin.go
new file mode 100644
index 0000000..4c0c191
--- /dev/null
+++ b/client-core/internal/diag/osinfo_darwin.go
@@ -0,0 +1,14 @@
+package diag
+
+import (
+ "os/exec"
+ "strings"
+)
+
+func osVersion() string {
+ out, err := exec.Command("sw_vers", "-productVersion").Output()
+ if err != nil {
+ return "macOS"
+ }
+ return "macOS " + strings.TrimSpace(string(out))
+}
diff --git a/client-core/internal/diag/osinfo_linux.go b/client-core/internal/diag/osinfo_linux.go
new file mode 100644
index 0000000..dc05d2f
--- /dev/null
+++ b/client-core/internal/diag/osinfo_linux.go
@@ -0,0 +1,26 @@
+package diag
+
+import (
+ "bufio"
+ "os"
+ "strings"
+)
+
+// osVersion 写发行版的名字,再加上桌面会话是 X11 还是 Wayland:剪贴板的问题常常和它有关
+func osVersion() string {
+ name := "Linux"
+ if f, err := os.Open("/etc/os-release"); err == nil {
+ defer f.Close()
+ sc := bufio.NewScanner(f)
+ for sc.Scan() {
+ if v, ok := strings.CutPrefix(sc.Text(), "PRETTY_NAME="); ok {
+ name = strings.Trim(v, `"`)
+ break
+ }
+ }
+ }
+ if session := os.Getenv("XDG_SESSION_TYPE"); session != "" {
+ name += ", " + session
+ }
+ return name
+}
diff --git a/client-core/internal/diag/osinfo_other.go b/client-core/internal/diag/osinfo_other.go
new file mode 100644
index 0000000..5d205f6
--- /dev/null
+++ b/client-core/internal/diag/osinfo_other.go
@@ -0,0 +1,7 @@
+//go:build !darwin && !windows && !linux
+
+package diag
+
+import "runtime"
+
+func osVersion() string { return runtime.GOOS }
diff --git a/client-core/internal/diag/osinfo_windows.go b/client-core/internal/diag/osinfo_windows.go
new file mode 100644
index 0000000..2562ee8
--- /dev/null
+++ b/client-core/internal/diag/osinfo_windows.go
@@ -0,0 +1,17 @@
+package diag
+
+import (
+ "fmt"
+
+ "golang.org/x/sys/windows"
+)
+
+// osVersion 按内部版本号区分 Windows 10 与 11:两者的主版本号都是 10,11 从 22000 开始
+func osVersion() string {
+ v := windows.RtlGetVersion()
+ name := "Windows 10"
+ if v.MajorVersion == 10 && v.BuildNumber >= 22000 {
+ name = "Windows 11"
+ }
+ return fmt.Sprintf("%s (build %d)", name, v.BuildNumber)
+}
diff --git a/client-core/internal/diag/redact.go b/client-core/internal/diag/redact.go
new file mode 100644
index 0000000..abdb480
--- /dev/null
+++ b/client-core/internal/diag/redact.go
@@ -0,0 +1,114 @@
+package diag
+
+import (
+ "cmp"
+ "fmt"
+ "maps"
+ "net/netip"
+ "net/url"
+ "regexp"
+ "slices"
+ "strings"
+ "unicode/utf8"
+)
+
+// redactor 把报告里能认出人的信息换成占位符:设备名、服务器地址、公网 IP、用户目录、文件名。
+//
+// 局域网与 Tailscale 的地址(192.168.x.x、10.x、100.64/10 等)保留:只在用户自己的网络里有意义,
+// 「不在同一网段」「访客网络隔离」这类问题全靠它们判断。
+type redactor struct {
+ words *strings.Replacer
+}
+
+var (
+ ipv4Pattern = regexp.MustCompile(`\b(?:\d{1,3}\.){3}\d{1,3}\b`)
+ // 先粗找由十六进制数字和冒号组成的一段,能不能算 IPv6 交给 netip 判断:
+ // 时间 20:50:01、MAC 地址都解析不成 IPv6,不会被误换
+ ipv6Pattern = regexp.MustCompile(`[0-9A-Fa-f]*:[0-9A-Fa-f:]*:[0-9A-Fa-f]*`)
+ cgnat = netip.MustParsePrefix("100.64.0.0/10") // 运营商级 NAT,Tailscale 也用这一段
+)
+
+// 太短的名字(比如叫「PC」的设备、叫「a」的文件)替换掉会误伤日志里的普通字词,宁可放过
+const minNameRunes = 3
+
+func newRedactor(in Input) *redactor {
+ type pair struct{ old, new string }
+ var pairs []pair
+ add := func(old, new string) {
+ old = strings.TrimSpace(old)
+ if utf8.RuneCountInString(old) >= minNameRunes {
+ pairs = append(pairs, pair{old, new})
+ }
+ }
+
+ // 设备名:本机一个,配对的设备按 ID 排序编号,同一份报告里同一台设备始终是同一个代号
+ add(in.Config.DeviceName, "<this-device>")
+ if in.Self != nil {
+ add(in.Self.GetName(), "<this-device>")
+ }
+ names := map[string]string{} // 设备 ID → 名字
+ for _, d := range in.Peers {
+ names[d.GetId()] = d.GetName()
+ }
+ for _, p := range in.Network.GetLan().GetPeers() {
+ if _, ok := names[p.GetDeviceId()]; !ok {
+ names[p.GetDeviceId()] = p.GetDeviceName()
+ }
+ }
+ for i, id := range slices.Sorted(maps.Keys(names)) {
+ add(names[id], fmt.Sprintf("<device-%d>", i+1))
+ }
+
+ // 服务器:主机名或公网 IP 换掉,协议、端口、路径留着,排查时用得上
+ if u, err := url.Parse(in.Config.SignalingURL); err == nil {
+ if host := u.Hostname(); host != "" && !keepIP(host) {
+ add(host, "<server>")
+ }
+ }
+
+ // 用户目录里有用户名;Windows 上的路径两种斜杠都可能出现
+ if in.Home != "" {
+ add(in.Home, "~")
+ add(strings.ReplaceAll(in.Home, `\`, "/"), "~")
+ }
+
+ for _, name := range in.FileNames {
+ add(name, "<file>")
+ }
+
+ // 长的先换:设备名「张三的 MacBook Pro」不能先被它的一部分换掉
+ slices.SortStableFunc(pairs, func(a, b pair) int { return cmp.Compare(len(b.old), len(a.old)) })
+ args := make([]string, 0, 2*len(pairs))
+ for _, p := range pairs {
+ args = append(args, p.old, p.new)
+ }
+ return &redactor{words: strings.NewReplacer(args...)}
+}
+
+func (r *redactor) apply(s string) string {
+ s = r.words.Replace(s)
+ s = ipv4Pattern.ReplaceAllStringFunc(s, func(m string) string {
+ if keepIP(m) {
+ return m
+ }
+ return "<public-ip>"
+ })
+ return ipv6Pattern.ReplaceAllStringFunc(s, func(m string) string {
+ if _, err := netip.ParseAddr(m); err != nil || keepIP(m) {
+ return m
+ }
+ return "<public-ip>"
+ })
+}
+
+// keepIP 判断一个地址能不能原样留在报告里:局域网、本机、链路本地、运营商级 NAT(含 Tailscale)可以。
+// 解析不成 IP 的(比如域名)返回 false。
+func keepIP(s string) bool {
+ a, err := netip.ParseAddr(s)
+ if err != nil {
+ return false
+ }
+ a = a.Unmap()
+ return a.IsPrivate() || a.IsLoopback() || a.IsLinkLocalUnicast() || a.IsUnspecified() ||
+ a.IsMulticast() || cgnat.Contains(a)
+}
diff --git a/client-core/internal/diag/report.go b/client-core/internal/diag/report.go
new file mode 100644
index 0000000..611657d
--- /dev/null
+++ b/client-core/internal/diag/report.go
@@ -0,0 +1,214 @@
+// Package diag 组装「反馈问题」用的诊断报告:版本与系统、设置、设备与网络的状态、最近的日志。
+//
+// 报告由用户看过之后自己贴进 GitHub 的 issue,那里是公开的,所以在这里先脱敏(见 redactor)。
+// 复制的内容本来就不写进日志,这里不用再处理。报告的栏目名用英文,日志本身是什么语言就是什么语言。
+package diag
+
+import (
+ "fmt"
+ "runtime"
+ "strings"
+ "time"
+
+ "github.com/baiyuze/copysync/client-core/internal/config"
+ pb "github.com/baiyuze/copysync/proto/gen/copysync/v1"
+)
+
+// Input 是生成报告要用的全部信息,由后台服务收集好传进来。
+type Input struct {
+ Now time.Time
+ Version string // 后台服务的版本
+ UIVersion string // 界面的版本,界面请求报告时带上
+ Config config.Config
+ Status *pb.Status
+ Self *pb.Device
+ Peers []*pb.Device
+ Network *pb.NetworkInfo // 还没探测过时为 nil
+
+ // 详细日志打开到什么时候;零值表示没打开
+ VerboseUntil time.Time
+
+ LogFiles []string // 按时间先后,轮转出去的旧文件在前
+ CrashLog string // 未处理的 panic 写在这里;Mac 上没有,panic 直接进日志
+ LogLines int
+
+ Home string // 用户目录,换成 ~
+ FileNames []string // 复制过的文件名,换成 <file>
+}
+
+// Build 生成脱敏后的报告文本。
+func Build(in Input) string {
+ // 整份报告最后统一脱敏;对齐成列的设备名先换掉,不然换完长短变了,列就歪了
+ r := newRedactor(in)
+ var b strings.Builder
+ line := func(format string, a ...any) { fmt.Fprintf(&b, format+"\n", a...) }
+ row := func(label string, value any) { line(" %-22s %v", label, value) }
+
+ line("CopySync diagnostics report")
+ line("Names, server address, public IP addresses, the user folder and file names are replaced.")
+ line("")
+ row("Generated", in.Now.Format("2006-01-02 15:04:05 -0700"))
+ row("Background service", in.Version)
+ if in.UIVersion != "" {
+ row("App", in.UIVersion)
+ }
+ row("System", fmt.Sprintf("%s (%s/%s)", osVersion(), runtime.GOOS, runtime.GOARCH))
+
+ c := in.Config
+ line("")
+ line("Settings")
+ row("Server", or(c.SignalingURL, "not set"))
+ row("Find devices on LAN", onOff(!c.LANDisabled))
+ row("Public STUN servers", onOff(!c.OnlyOwnSTUN))
+ row("Auto-sync limit", fmt.Sprintf("%d MB", c.AutoSyncThresholdBytes>>20))
+ row("History kept", duration(time.Duration(c.HistoryTTL)))
+ row("Files kept", duration(time.Duration(c.CacheTTL)))
+ row("Sync", syncKinds(c))
+ row("Language", or(c.Language, "follow system"))
+
+ if st := in.Status; st != nil {
+ line("")
+ line("Status")
+ conn := "not connected"
+ if st.GetSignalingConnected() {
+ conn = "connected"
+ }
+ row("Server connection", conn)
+ row("LAN", lanState(st))
+ row("Clipboard access", strings.ToLower(strings.TrimPrefix(st.GetClipboardPermission().String(), "CLIPBOARD_PERMISSION_")))
+ row("Cache", fmt.Sprintf("%d MB", st.GetCacheBytesUsed()>>20))
+ }
+ if in.VerboseUntil.IsZero() {
+ row("Detailed logging", "off")
+ } else {
+ row("Detailed logging", "on until "+in.VerboseUntil.Format("15:04"))
+ }
+
+ line("")
+ line("Devices")
+ if in.Self != nil {
+ line(" %-22s %s (this device)", r.apply(in.Self.GetName()), in.Self.GetPlatform())
+ }
+ for _, p := range in.Peers {
+ line(" %-22s %-8s %s", r.apply(p.GetName()), p.GetPlatform(),
+ strings.ToLower(strings.TrimPrefix(p.GetConnection().String(), "CONNECTION_KIND_")))
+ }
+
+ if n := in.Network; n != nil {
+ line("")
+ line("Network")
+ row("Hole-punching port", fmt.Sprintf("UDP %d", n.GetLocalPort()))
+ probed := "not yet"
+ if n.GetProbedAtUnix() > 0 {
+ probed = fmt.Sprintf("%s, %d of %d servers answered",
+ time.Unix(n.GetProbedAtUnix(), 0).Format("15:04:05"), n.GetAnswered(), n.GetProbed())
+ }
+ row("Last probe", probed)
+ for _, e := range n.GetEgresses() {
+ mode := "changes port"
+ if e.GetPortPreserved() {
+ mode = "keeps port"
+ }
+ via := strings.Join(e.GetVia(), ", ")
+ if e.GetGuessed() {
+ via = "guessed from history"
+ }
+ row("Egress", fmt.Sprintf("%s %s %s", e.GetAddress(), mode, via))
+ }
+ if lan := n.GetLan(); lan != nil && lan.GetEnabled() {
+ row("LAN port", fmt.Sprintf("UDP %d, addresses %s", lan.GetPort(), strings.Join(lan.GetLocalAddresses(), " ")))
+ row("Found on LAN", fmt.Sprintf("%d CopySync instances", lan.GetDiscovered()))
+ for _, p := range lan.GetPeers() {
+ state := "not found"
+ if p.GetReachable() {
+ state = "reachable at " + p.GetAddress()
+ }
+ if known := p.GetKnownAddresses(); len(known) > 0 {
+ state += ", remembered " + strings.Join(known, " ")
+ }
+ line(" %-22s %s", r.apply(p.GetDeviceName()), state)
+ }
+ }
+ }
+
+ logs := tailLines(in.LogFiles, in.LogLines)
+ line("")
+ line("Log (%s)", lastLines(len(logs)))
+ for _, l := range logs {
+ line("%s", l)
+ }
+ if crash := tailLines([]string{in.CrashLog}, 100); in.CrashLog != "" && len(crash) > 0 {
+ line("")
+ line("Crash log (%s)", lastLines(len(crash)))
+ for _, l := range crash {
+ line("%s", l)
+ }
+ }
+ return r.apply(b.String())
+}
+
+func lastLines(n int) string {
+ if n == 1 {
+ return "last line"
+ }
+ return fmt.Sprintf("last %d lines", n)
+}
+
+func or(s, fallback string) string {
+ if s == "" {
+ return fallback
+ }
+ return s
+}
+
+func onOff(on bool) string {
+ if on {
+ return "on"
+ }
+ return "off"
+}
+
+func lanState(st *pb.Status) string {
+ switch {
+ case !st.GetLanEnabled():
+ return "off"
+ case st.GetLanBlocked():
+ return "blocked by the system"
+ default:
+ return "on"
+ }
+}
+
+func syncKinds(c config.Config) string {
+ var kinds []string
+ for _, k := range []struct {
+ on bool
+ name string
+ }{{c.SyncText, "text"}, {c.SyncHTML, "rich text"}, {c.SyncImage, "images"}, {c.SyncFile, "files"}} {
+ if k.on {
+ kinds = append(kinds, k.name)
+ }
+ }
+ if len(kinds) == 0 {
+ return "nothing"
+ }
+ return strings.Join(kinds, ", ")
+}
+
+// duration 写成 3 days、12 hours 这样,设置里的时长都是整天或整小时
+func duration(d time.Duration) string {
+ plural := func(n time.Duration, unit string) string {
+ if n == 1 {
+ return "1 " + unit
+ }
+ return fmt.Sprintf("%d %ss", n, unit)
+ }
+ switch {
+ case d >= 24*time.Hour && d%(24*time.Hour) == 0:
+ return plural(d/(24*time.Hour), "day")
+ case d >= time.Hour && d%time.Hour == 0:
+ return plural(d/time.Hour, "hour")
+ default:
+ return d.String()
+ }
+}
diff --git a/client-core/internal/rpc/diagnostics_test.go b/client-core/internal/rpc/diagnostics_test.go
new file mode 100644
index 0000000..64a1cb4
--- /dev/null
+++ b/client-core/internal/rpc/diagnostics_test.go
@@ -0,0 +1,67 @@
+package rpc
+
+import (
+ "context"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/baiyuze/copysync/client-core/internal/config"
+ pb "github.com/baiyuze/copysync/proto/gen/copysync/v1"
+)
+
+func TestExportDiagnostics(t *testing.T) {
+ log := filepath.Join(t.TempDir(), "daemon.log")
+ var lines []string
+ for i := range 300 {
+ lines = append(lines, "level=INFO msg=第"+string(rune('0'+i%10))+"行 peer=\"李四的 ThinkPad\"")
+ }
+ if err := os.WriteFile(log, []byte(strings.Join(lines, "\n")+"\n"), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ cfg := config.Default()
+ cfg.DeviceName = "张三的 MacBook Pro"
+ s := NewServer(Deps{
+ Version: "1.7.0",
+ LoadConfig: func() config.Config { return cfg },
+ Devices: func() (*pb.Device, []*pb.Device) {
+ return &pb.Device{Id: "a", Name: cfg.DeviceName}, []*pb.Device{{Id: "b", Name: "李四的 ThinkPad"}}
+ },
+ LogFiles: func() ([]string, string) { return []string{log}, "" },
+ }, NewHub(), "test-token")
+
+ got, err := s.ExportDiagnostics(context.Background(), &pb.ExportDiagnosticsRequest{LogLines: 20, UiVersion: "1.7.0"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ r := got.GetReport()
+ if strings.Contains(r, "张三") || strings.Contains(r, "李四") {
+ t.Errorf("设备名没有换掉:\n%s", r)
+ }
+ if !strings.Contains(r, "Log (last 20 lines)") || strings.Count(r, "<device-1>") < 20 {
+ t.Errorf("日志行数或代号不对:\n%s", r)
+ }
+}
+
+func TestSetVerboseLog(t *testing.T) {
+ var asked time.Duration
+ until := time.Now().Add(30 * time.Minute)
+ s := NewServer(Deps{
+ LoadConfig: config.Default,
+ VerboseLog: func(d time.Duration) time.Time { asked = d; return until },
+ VerboseUntil: func() time.Time { return until },
+ }, NewHub(), "test-token")
+
+ st, err := s.SetVerboseLog(context.Background(), &pb.SetVerboseLogRequest{Minutes: 600})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if asked != 2*time.Hour {
+ t.Errorf("没有限制在两小时内:%v", asked)
+ }
+ if st.GetVerboseLogUntilUnix() != until.Unix() {
+ t.Errorf("状态里没有详细日志的截止时间:%d", st.GetVerboseLogUntilUnix())
+ }
+}
diff --git a/client-core/internal/rpc/server.go b/client-core/internal/rpc/server.go
index dcccd4b..c2ba30a 100644
--- a/client-core/internal/rpc/server.go
+++ b/client-core/internal/rpc/server.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"net"
+ "os"
"strings"
"time"
@@ -18,6 +19,7 @@ import (
"github.com/baiyuze/copysync/client-core/internal/clipboard"
"github.com/baiyuze/copysync/client-core/internal/config"
+ "github.com/baiyuze/copysync/client-core/internal/diag"
"github.com/baiyuze/copysync/client-core/internal/peers"
"github.com/baiyuze/copysync/client-core/internal/store"
"github.com/baiyuze/copysync/client-core/internal/transport/lan"
@@ -47,6 +49,11 @@ type Deps struct {
OpenPermissionSettings func() error
// SearchHistory 按文字内容与文件名搜索复制记录,见 sync.Engine.SearchHistory
SearchHistory func(query string, limit int) ([]store.Clip, error)
+ // 诊断报告要读的日志文件(轮转出去的旧文件在前)与崩溃日志
+ LogFiles func() (logs []string, crash string)
+ // VerboseLog 临时打开详细日志,d 不大于 0 时关闭;VerboseUntil 是打开到什么时候
+ VerboseLog func(d time.Duration) time.Time
+ VerboseUntil func() time.Time
// Network 返回最近一轮网络出口探测的结果
Network func() *pb.NetworkInfo
Devices func() (self *pb.Device, peers []*pb.Device)
@@ -321,6 +328,11 @@ func (s *Server) GetStatus(context.Context, *pb.Empty) (*pb.Status, error) {
if s.deps.LANBlocked != nil {
st.LanBlocked = s.deps.LANBlocked()
}
+ if s.deps.VerboseUntil != nil {
+ if until := s.deps.VerboseUntil(); !until.IsZero() {
+ st.VerboseLogUntilUnix = until.Unix()
+ }
+ }
if s.deps.CacheBytesUsed != nil {
st.CacheBytesUsed = s.deps.CacheBytesUsed()
}
@@ -342,6 +354,54 @@ func (s *Server) GetNetwork(context.Context, *pb.Empty) (*pb.NetworkInfo, error)
return s.deps.Network(), nil
}
+// ExportDiagnostics 生成反馈问题用的诊断报告,脱敏在 diag 包里做。
+func (s *Server) ExportDiagnostics(ctx context.Context, req *pb.ExportDiagnosticsRequest) (*pb.Diagnostics, error) {
+ lines := int(req.GetLogLines())
+ if lines <= 0 || lines > 2000 {
+ lines = 200
+ }
+ st, err := s.GetStatus(ctx, &pb.Empty{})
+ if err != nil {
+ return nil, err
+ }
+ in := diag.Input{
+ Now: time.Now(),
+ Version: s.deps.Version,
+ UIVersion: req.GetUiVersion(),
+ Config: s.deps.LoadConfig(),
+ Status: st,
+ LogLines: lines,
+ }
+ if s.deps.Devices != nil {
+ in.Self, in.Peers = s.deps.Devices()
+ }
+ if s.deps.Network != nil {
+ in.Network = s.deps.Network()
+ }
+ if s.deps.VerboseUntil != nil {
+ in.VerboseUntil = s.deps.VerboseUntil()
+ }
+ if s.deps.LogFiles != nil {
+ in.LogFiles, in.CrashLog = s.deps.LogFiles()
+ }
+ in.Home, _ = os.UserHomeDir()
+ if s.deps.Store != nil {
+ // 名字取不全只是少换掉几个,报告照样能用
+ in.FileNames, _ = s.deps.Store.FileNames(5000)
+ }
+ return &pb.Diagnostics{Report: diag.Build(in)}, nil
+}
+
+func (s *Server) SetVerboseLog(ctx context.Context, req *pb.SetVerboseLogRequest) (*pb.Status, error) {
+ if s.deps.VerboseLog == nil {
+ return nil, status.Error(codes.Unimplemented, "当前版本不支持临时打开详细日志")
+ }
+ // 最长两小时:详细日志量大,忘了关也不至于一直写下去
+ minutes := min(max(req.GetMinutes(), 0), 120)
+ s.deps.VerboseLog(time.Duration(minutes) * time.Minute)
+ return s.GetStatus(ctx, &pb.Empty{})
+}
+
func (s *Server) RequestClipboardPermission(context.Context, *pb.Empty) (*pb.Empty, error) {
if s.deps.OpenPermissionSettings == nil {
return nil, status.Error(codes.Unimplemented, "当前平台无需授权")
diff --git a/client-core/internal/store/store.go b/client-core/internal/store/store.go
index d5f2a3d..7dae05d 100644
--- a/client-core/internal/store/store.go
+++ b/client-core/internal/store/store.go
@@ -315,6 +315,28 @@ ORDER BY created_at DESC LIMIT ?`,
KindText, like, KindHTML, like, like, KindImage, like, limit)
}
+// FileNames 返回复制过的文件、文件夹名,以及它们在源电脑上的完整路径(去重,最多 limit 个)。
+// 诊断报告据此把它们从日志里换掉。
+func (s *Store) FileNames(limit int) ([]string, error) {
+ rows, err := s.db.Query(`
+SELECT name FROM clip_items
+UNION SELECT value FROM clips, json_each(clips.source_paths)
+LIMIT ?`, limit)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ var out []string
+ for rows.Next() {
+ var name string
+ if err := rows.Scan(&name); err != nil {
+ return nil, err
+ }
+ out = append(out, name)
+ }
+ return out, rows.Err()
+}
+
const clipCols = `id, kind, status, origin_device_id, origin_device_name, outgoing,
total_size, text_preview, text_content, text_plain, cache_path,
source_paths, error, created_at, expires_at`
diff --git a/client-core/internal/store/store_test.go b/client-core/internal/store/store_test.go
index f17a8d8..9bc5a19 100644
--- a/client-core/internal/store/store_test.go
+++ b/client-core/internal/store/store_test.go
@@ -3,6 +3,7 @@ package store
import (
"database/sql"
"path/filepath"
+ "slices"
"testing"
"time"
)
@@ -202,6 +203,24 @@ func TestSearchClips(t *testing.T) {
}
}
+func TestFileNames(t *testing.T) {
+ s := openTest(t)
+ now := time.Now()
+ for _, id := range []string{"x", "y"} { // 两条记录的文件名相同,只出现一次
+ if err := s.PutClip(sampleClip(id, now)); err != nil {
+ t.Fatal(err)
+ }
+ }
+ got, err := s.FileNames(100)
+ if err != nil {
+ t.Fatal(err)
+ }
+ slices.Sort(got)
+ if want := []string{"/tmp/a.txt", "/tmp/b.txt", "a.txt", "docs"}; !slices.Equal(got, want) {
+ t.Errorf("FileNames = %q,应为 %q", got, want)
+ }
+}
+
// GC 依赖这个查询找出该删的记录;边界判定错了会导致缓存永不释放。
func TestExpiredClips(t *testing.T) {
s := openTest(t)
diff --git a/proto/copysync/v1/daemon.proto b/proto/copysync/v1/daemon.proto
index e1d89b0..e76a7b2 100644
--- a/proto/copysync/v1/daemon.proto
+++ b/proto/copysync/v1/daemon.proto
@@ -49,6 +49,12 @@ service DaemonService {
// 网络出口与打洞诊断:本机有几个出口、各自的公网地址,见 copysync-cli nat
rpc GetNetwork(Empty) returns (NetworkInfo);
+
+ // 反馈问题用的诊断报告:版本、系统、设置、设备与网络状态、最近的日志。
+ // 设备名、服务器地址、公网 IP、用户目录、文件名已换成占位符,用户看过后自己贴进 issue
+ rpc ExportDiagnostics(ExportDiagnosticsRequest) returns (Diagnostics);
+ // 临时打开详细日志(调试级别),到时间自动关回去;minutes 为 0 立即关闭
+ rpc SetVerboseLog(SetVerboseLogRequest) returns (Status);
}
message Empty {}
@@ -333,6 +339,21 @@ message Status {
bool lan_enabled = 9;
// 系统拦下了本机发往局域网的包:macOS 上是没允许「本地网络」权限
bool lan_blocked = 10;
+ // 详细日志打开到什么时候;0 表示没打开
+ int64 verbose_log_until_unix = 11;
+}
+
+message ExportDiagnosticsRequest {
+ int32 log_lines = 1; // 带上最近多少行日志
+ string ui_version = 2; // 界面的版本,写进报告
+}
+
+message Diagnostics {
+ string report = 1;
+}
+
+message SetVerboseLogRequest {
+ int32 minutes = 1;
}
message GetImagePreviewRequest {
diff --git a/proto/gen/copysync/v1/daemon.pb.go b/proto/gen/copysync/v1/daemon.pb.go
index 5b41f7f..45b1b99 100644
--- a/proto/gen/copysync/v1/daemon.pb.go
+++ b/proto/gen/copysync/v1/daemon.pb.go
@@ -2164,9 +2164,11 @@ type Status struct {
ServerConfigured bool `protobuf:"varint,8,opt,name=server_configured,json=serverConfigured,proto3" json:"server_configured,omitempty"`
LanEnabled bool `protobuf:"varint,9,opt,name=lan_enabled,json=lanEnabled,proto3" json:"lan_enabled,omitempty"`
// 系统拦下了本机发往局域网的包:macOS 上是没允许「本地网络」权限
- LanBlocked bool `protobuf:"varint,10,opt,name=lan_blocked,json=lanBlocked,proto3" json:"lan_blocked,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ LanBlocked bool `protobuf:"varint,10,opt,name=lan_blocked,json=lanBlocked,proto3" json:"lan_blocked,omitempty"`
+ // 详细日志打开到什么时候;0 表示没打开
+ VerboseLogUntilUnix int64 `protobuf:"varint,11,opt,name=verbose_log_until_unix,json=verboseLogUntilUnix,proto3" json:"verbose_log_until_unix,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *Status) Reset() {
@@ -2269,6 +2271,153 @@ func (x *Status) GetLanBlocked() bool {
return false
}
+func (x *Status) GetVerboseLogUntilUnix() int64 {
+ if x != nil {
+ return x.VerboseLogUntilUnix
+ }
+ return 0
+}
+
+type ExportDiagnosticsRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ LogLines int32 `protobuf:"varint,1,opt,name=log_lines,json=logLines,proto3" json:"log_lines,omitempty"` // 带上最近多少行日志
+ UiVersion string `protobuf:"bytes,2,opt,name=ui_version,json=uiVersion,proto3" json:"ui_version,omitempty"` // 界面的版本,写进报告
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *ExportDiagnosticsRequest) Reset() {
+ *x = ExportDiagnosticsRequest{}
+ mi := &file_copysync_v1_daemon_proto_msgTypes[28]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *ExportDiagnosticsRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ExportDiagnosticsRequest) ProtoMessage() {}
+
+func (x *ExportDiagnosticsRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_copysync_v1_daemon_proto_msgTypes[28]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use ExportDiagnosticsRequest.ProtoReflect.Descriptor instead.
+func (*ExportDiagnosticsRequest) Descriptor() ([]byte, []int) {
+ return file_copysync_v1_daemon_proto_rawDescGZIP(), []int{28}
+}
+
+func (x *ExportDiagnosticsRequest) GetLogLines() int32 {
+ if x != nil {
+ return x.LogLines
+ }
+ return 0
+}
+
+func (x *ExportDiagnosticsRequest) GetUiVersion() string {
+ if x != nil {
+ return x.UiVersion
+ }
+ return ""
+}
+
+type Diagnostics struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Report string `protobuf:"bytes,1,opt,name=report,proto3" json:"report,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *Diagnostics) Reset() {
+ *x = Diagnostics{}
+ mi := &file_copysync_v1_daemon_proto_msgTypes[29]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *Diagnostics) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Diagnostics) ProtoMessage() {}
+
+func (x *Diagnostics) ProtoReflect() protoreflect.Message {
+ mi := &file_copysync_v1_daemon_proto_msgTypes[29]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use Diagnostics.ProtoReflect.Descriptor instead.
+func (*Diagnostics) Descriptor() ([]byte, []int) {
+ return file_copysync_v1_daemon_proto_rawDescGZIP(), []int{29}
+}
+
+func (x *Diagnostics) GetReport() string {
+ if x != nil {
+ return x.Report
+ }
+ return ""
+}
+
+type SetVerboseLogRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Minutes int32 `protobuf:"varint,1,opt,name=minutes,proto3" json:"minutes,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *SetVerboseLogRequest) Reset() {
+ *x = SetVerboseLogRequest{}
+ mi := &file_copysync_v1_daemon_proto_msgTypes[30]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *SetVerboseLogRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SetVerboseLogRequest) ProtoMessage() {}
+
+func (x *SetVerboseLogRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_copysync_v1_daemon_proto_msgTypes[30]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use SetVerboseLogRequest.ProtoReflect.Descriptor instead.
+func (*SetVerboseLogRequest) Descriptor() ([]byte, []int) {
+ return file_copysync_v1_daemon_proto_rawDescGZIP(), []int{30}
+}
+
+func (x *SetVerboseLogRequest) GetMinutes() int32 {
+ if x != nil {
+ return x.Minutes
+ }
+ return 0
+}
+
type GetImagePreviewRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
ClipId string `protobuf:"bytes,1,opt,name=clip_id,json=clipId,proto3" json:"clip_id,omitempty"`
@@ -2279,7 +2428,7 @@ type GetImagePreviewRequest struct {
func (x *GetImagePreviewRequest) Reset() {
*x = GetImagePreviewRequest{}
- mi := &file_copysync_v1_daemon_proto_msgTypes[28]
+ mi := &file_copysync_v1_daemon_proto_msgTypes[31]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2291,7 +2440,7 @@ func (x *GetImagePreviewRequest) String() string {
func (*GetImagePreviewRequest) ProtoMessage() {}
func (x *GetImagePreviewRequest) ProtoReflect() protoreflect.Message {
- mi := &file_copysync_v1_daemon_proto_msgTypes[28]
+ mi := &file_copysync_v1_daemon_proto_msgTypes[31]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2304,7 +2453,7 @@ func (x *GetImagePreviewRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetImagePreviewRequest.ProtoReflect.Descriptor instead.
func (*GetImagePreviewRequest) Descriptor() ([]byte, []int) {
- return file_copysync_v1_daemon_proto_rawDescGZIP(), []int{28}
+ return file_copysync_v1_daemon_proto_rawDescGZIP(), []int{31}
}
func (x *GetImagePreviewRequest) GetClipId() string {
@@ -2332,7 +2481,7 @@ type GetImagePreviewResponse struct {
func (x *GetImagePreviewResponse) Reset() {
*x = GetImagePreviewResponse{}
- mi := &file_copysync_v1_daemon_proto_msgTypes[29]
+ mi := &file_copysync_v1_daemon_proto_msgTypes[32]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2344,7 +2493,7 @@ func (x *GetImagePreviewResponse) String() string {
func (*GetImagePreviewResponse) ProtoMessage() {}
func (x *GetImagePreviewResponse) ProtoReflect() protoreflect.Message {
- mi := &file_copysync_v1_daemon_proto_msgTypes[29]
+ mi := &file_copysync_v1_daemon_proto_msgTypes[32]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2357,7 +2506,7 @@ func (x *GetImagePreviewResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetImagePreviewResponse.ProtoReflect.Descriptor instead.
func (*GetImagePreviewResponse) Descriptor() ([]byte, []int) {
- return file_copysync_v1_daemon_proto_rawDescGZIP(), []int{29}
+ return file_copysync_v1_daemon_proto_rawDescGZIP(), []int{32}
}
func (x *GetImagePreviewResponse) GetPath() string {
@@ -2534,7 +2683,7 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
"\aaddress\x18\x01 \x01(\tR\aaddress\x12%\n" +
"\x0eport_preserved\x18\x02 \x01(\bR\rportPreserved\x12\x18\n" +
"\aguessed\x18\x03 \x01(\bR\aguessed\x12\x10\n" +
- "\x03via\x18\x04 \x03(\tR\x03via\"\xa2\x03\n" +
+ "\x03via\x18\x04 \x03(\tR\x03via\"\xd7\x03\n" +
"\x06Status\x12\x1b\n" +
"\tdevice_id\x18\x01 \x01(\tR\bdeviceId\x12\x1f\n" +
"\vdevice_name\x18\x02 \x01(\tR\n" +
@@ -2549,7 +2698,16 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
"lanEnabled\x12\x1f\n" +
"\vlan_blocked\x18\n" +
" \x01(\bR\n" +
- "lanBlocked\"G\n" +
+ "lanBlocked\x123\n" +
+ "\x16verbose_log_until_unix\x18\v \x01(\x03R\x13verboseLogUntilUnix\"V\n" +
+ "\x18ExportDiagnosticsRequest\x12\x1b\n" +
+ "\tlog_lines\x18\x01 \x01(\x05R\blogLines\x12\x1d\n" +
+ "\n" +
+ "ui_version\x18\x02 \x01(\tR\tuiVersion\"%\n" +
+ "\vDiagnostics\x12\x16\n" +
+ "\x06report\x18\x01 \x01(\tR\x06report\"0\n" +
+ "\x14SetVerboseLogRequest\x12\x18\n" +
+ "\aminutes\x18\x01 \x01(\x05R\aminutes\"G\n" +
"\x16GetImagePreviewRequest\x12\x17\n" +
"\aclip_id\x18\x01 \x01(\tR\x06clipId\x12\x14\n" +
"\x05index\x18\x02 \x01(\x05R\x05index\"W\n" +
@@ -2582,7 +2740,7 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
"\x1cCLIPBOARD_PERMISSION_DEFAULT\x10\x02\x12\x1c\n" +
"\x18CLIPBOARD_PERMISSION_ASK\x10\x03\x12%\n" +
"!CLIPBOARD_PERMISSION_ALWAYS_ALLOW\x10\x04\x12$\n" +
- " CLIPBOARD_PERMISSION_ALWAYS_DENY\x10\x052\xa3\v\n" +
+ " CLIPBOARD_PERMISSION_ALWAYS_DENY\x10\x052\xc2\f\n" +
"\rDaemonService\x12@\n" +
"\tSubscribe\x12\x1d.copysync.v1.SubscribeRequest\x1a\x12.copysync.v1.Event0\x01\x12P\n" +
"\vListHistory\x12\x1f.copysync.v1.ListHistoryRequest\x1a .copysync.v1.ListHistoryResponse\x12F\n" +
@@ -2605,7 +2763,9 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
"\x1aRequestClipboardPermission\x12\x12.copysync.v1.Empty\x1a\x12.copysync.v1.Empty\x12G\n" +
"\x1dRequestLocalNetworkPermission\x12\x12.copysync.v1.Empty\x1a\x12.copysync.v1.Empty\x12:\n" +
"\n" +
- "GetNetwork\x12\x12.copysync.v1.Empty\x1a\x18.copysync.v1.NetworkInfoB>Z<github.com/baiyuze/copysync/proto/gen/copysync/v1;copysyncv1b\x06proto3"
+ "GetNetwork\x12\x12.copysync.v1.Empty\x1a\x18.copysync.v1.NetworkInfo\x12T\n" +
+ "\x11ExportDiagnostics\x12%.copysync.v1.ExportDiagnosticsRequest\x1a\x18.copysync.v1.Diagnostics\x12G\n" +
+ "\rSetVerboseLog\x12!.copysync.v1.SetVerboseLogRequest\x1a\x13.copysync.v1.StatusB>Z<github.com/baiyuze/copysync/proto/gen/copysync/v1;copysyncv1b\x06proto3"
var (
file_copysync_v1_daemon_proto_rawDescOnce sync.Once
@@ -2620,7 +2780,7 @@ func file_copysync_v1_daemon_proto_rawDescGZIP() []byte {
}
var file_copysync_v1_daemon_proto_enumTypes = make([]protoimpl.EnumInfo, 4)
-var file_copysync_v1_daemon_proto_msgTypes = make([]protoimpl.MessageInfo, 30)
+var file_copysync_v1_daemon_proto_msgTypes = make([]protoimpl.MessageInfo, 33)
var file_copysync_v1_daemon_proto_goTypes = []any{
(ClipKind)(0), // 0: copysync.v1.ClipKind
(ClipStatus)(0), // 1: copysync.v1.ClipStatus
@@ -2654,8 +2814,11 @@ var file_copysync_v1_daemon_proto_goTypes = []any{
(*LanPeer)(nil), // 29: copysync.v1.LanPeer
(*NetworkEgress)(nil), // 30: copysync.v1.NetworkEgress
(*Status)(nil), // 31: copysync.v1.Status
- (*GetImagePreviewRequest)(nil), // 32: copysync.v1.GetImagePreviewRequest
- (*GetImagePreviewResponse)(nil), // 33: copysync.v1.GetImagePreviewResponse
+ (*ExportDiagnosticsRequest)(nil), // 32: copysync.v1.ExportDiagnosticsRequest
+ (*Diagnostics)(nil), // 33: copysync.v1.Diagnostics
+ (*SetVerboseLogRequest)(nil), // 34: copysync.v1.SetVerboseLogRequest
+ (*GetImagePreviewRequest)(nil), // 35: copysync.v1.GetImagePreviewRequest
+ (*GetImagePreviewResponse)(nil), // 36: copysync.v1.GetImagePreviewResponse
}
var file_copysync_v1_daemon_proto_depIdxs = []int32{
0, // 0: copysync.v1.ClipRecord.kind:type_name -> copysync.v1.ClipKind
@@ -2683,7 +2846,7 @@ var file_copysync_v1_daemon_proto_depIdxs = []int32{
13, // 22: copysync.v1.DaemonService.DeleteHistory:input_type -> copysync.v1.DeleteHistoryRequest
14, // 23: copysync.v1.DaemonService.Fetch:input_type -> copysync.v1.FetchRequest
15, // 24: copysync.v1.DaemonService.ApplyToClipboard:input_type -> copysync.v1.ApplyToClipboardRequest
- 32, // 25: copysync.v1.DaemonService.GetImagePreview:input_type -> copysync.v1.GetImagePreviewRequest
+ 35, // 25: copysync.v1.DaemonService.GetImagePreview:input_type -> copysync.v1.GetImagePreviewRequest
4, // 26: copysync.v1.DaemonService.ListDevices:input_type -> copysync.v1.Empty
4, // 27: copysync.v1.DaemonService.CreatePairingCode:input_type -> copysync.v1.Empty
18, // 28: copysync.v1.DaemonService.RedeemPairingCode:input_type -> copysync.v1.RedeemPairingCodeRequest
@@ -2698,28 +2861,32 @@ var file_copysync_v1_daemon_proto_depIdxs = []int32{
4, // 37: copysync.v1.DaemonService.RequestClipboardPermission:input_type -> copysync.v1.Empty
4, // 38: copysync.v1.DaemonService.RequestLocalNetworkPermission:input_type -> copysync.v1.Empty
4, // 39: copysync.v1.DaemonService.GetNetwork:input_type -> copysync.v1.Empty
- 10, // 40: copysync.v1.DaemonService.Subscribe:output_type -> copysync.v1.Event
- 12, // 41: copysync.v1.DaemonService.ListHistory:output_type -> copysync.v1.ListHistoryResponse
- 4, // 42: copysync.v1.DaemonService.DeleteHistory:output_type -> copysync.v1.Empty
- 4, // 43: copysync.v1.DaemonService.Fetch:output_type -> copysync.v1.Empty
- 4, // 44: copysync.v1.DaemonService.ApplyToClipboard:output_type -> copysync.v1.Empty
- 33, // 45: copysync.v1.DaemonService.GetImagePreview:output_type -> copysync.v1.GetImagePreviewResponse
- 16, // 46: copysync.v1.DaemonService.ListDevices:output_type -> copysync.v1.ListDevicesResponse
- 17, // 47: copysync.v1.DaemonService.CreatePairingCode:output_type -> copysync.v1.CreatePairingCodeResponse
- 19, // 48: copysync.v1.DaemonService.RedeemPairingCode:output_type -> copysync.v1.RedeemPairingCodeResponse
- 4, // 49: copysync.v1.DaemonService.ConfirmPairing:output_type -> copysync.v1.Empty
- 4, // 50: copysync.v1.DaemonService.Unpair:output_type -> copysync.v1.Empty
- 4, // 51: copysync.v1.DaemonService.SetDeviceAddress:output_type -> copysync.v1.Empty
- 22, // 52: copysync.v1.DaemonService.WatchNearby:output_type -> copysync.v1.NearbyDevices
- 19, // 53: copysync.v1.DaemonService.PairNearby:output_type -> copysync.v1.RedeemPairingCodeResponse
- 26, // 54: copysync.v1.DaemonService.GetConfig:output_type -> copysync.v1.Config
- 26, // 55: copysync.v1.DaemonService.UpdateConfig:output_type -> copysync.v1.Config
- 31, // 56: copysync.v1.DaemonService.GetStatus:output_type -> copysync.v1.Status
- 4, // 57: copysync.v1.DaemonService.RequestClipboardPermission:output_type -> copysync.v1.Empty
- 4, // 58: copysync.v1.DaemonService.RequestLocalNetworkPermission:output_type -> copysync.v1.Empty
- 27, // 59: copysync.v1.DaemonService.GetNetwork:output_type -> copysync.v1.NetworkInfo
- 40, // [40:60] is the sub-list for method output_type
- 20, // [20:40] is the sub-list for method input_type
+ 32, // 40: copysync.v1.DaemonService.ExportDiagnostics:input_type -> copysync.v1.ExportDiagnosticsRequest
+ 34, // 41: copysync.v1.DaemonService.SetVerboseLog:input_type -> copysync.v1.SetVerboseLogRequest
+ 10, // 42: copysync.v1.DaemonService.Subscribe:output_type -> copysync.v1.Event
+ 12, // 43: copysync.v1.DaemonService.ListHistory:output_type -> copysync.v1.ListHistoryResponse
+ 4, // 44: copysync.v1.DaemonService.DeleteHistory:output_type -> copysync.v1.Empty
+ 4, // 45: copysync.v1.DaemonService.Fetch:output_type -> copysync.v1.Empty
+ 4, // 46: copysync.v1.DaemonService.ApplyToClipboard:output_type -> copysync.v1.Empty
+ 36, // 47: copysync.v1.DaemonService.GetImagePreview:output_type -> copysync.v1.GetImagePreviewResponse
+ 16, // 48: copysync.v1.DaemonService.ListDevices:output_type -> copysync.v1.ListDevicesResponse
+ 17, // 49: copysync.v1.DaemonService.CreatePairingCode:output_type -> copysync.v1.CreatePairingCodeResponse
+ 19, // 50: copysync.v1.DaemonService.RedeemPairingCode:output_type -> copysync.v1.RedeemPairingCodeResponse
+ 4, // 51: copysync.v1.DaemonService.ConfirmPairing:output_type -> copysync.v1.Empty
+ 4, // 52: copysync.v1.DaemonService.Unpair:output_type -> copysync.v1.Empty
+ 4, // 53: copysync.v1.DaemonService.SetDeviceAddress:output_type -> copysync.v1.Empty
+ 22, // 54: copysync.v1.DaemonService.WatchNearby:output_type -> copysync.v1.NearbyDevices
+ 19, // 55: copysync.v1.DaemonService.PairNearby:output_type -> copysync.v1.RedeemPairingCodeResponse
+ 26, // 56: copysync.v1.DaemonService.GetConfig:output_type -> copysync.v1.Config
+ 26, // 57: copysync.v1.DaemonService.UpdateConfig:output_type -> copysync.v1.Config
+ 31, // 58: copysync.v1.DaemonService.GetStatus:output_type -> copysync.v1.Status
+ 4, // 59: copysync.v1.DaemonService.RequestClipboardPermission:output_type -> copysync.v1.Empty
+ 4, // 60: copysync.v1.DaemonService.RequestLocalNetworkPermission:output_type -> copysync.v1.Empty
+ 27, // 61: copysync.v1.DaemonService.GetNetwork:output_type -> copysync.v1.NetworkInfo
+ 33, // 62: copysync.v1.DaemonService.ExportDiagnostics:output_type -> copysync.v1.Diagnostics
+ 31, // 63: copysync.v1.DaemonService.SetVerboseLog:output_type -> copysync.v1.Status
+ 42, // [42:64] is the sub-list for method output_type
+ 20, // [20:42] is the sub-list for method input_type
20, // [20:20] is the sub-list for extension type_name
20, // [20:20] is the sub-list for extension extendee
0, // [0:20] is the sub-list for field type_name
@@ -2745,7 +2912,7 @@ func file_copysync_v1_daemon_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_copysync_v1_daemon_proto_rawDesc), len(file_copysync_v1_daemon_proto_rawDesc)),
NumEnums: 4,
- NumMessages: 30,
+ NumMessages: 33,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/gen/copysync/v1/daemon_grpc.pb.go b/proto/gen/copysync/v1/daemon_grpc.pb.go
index 656291c..18ca84c 100644
--- a/proto/gen/copysync/v1/daemon_grpc.pb.go
+++ b/proto/gen/copysync/v1/daemon_grpc.pb.go
@@ -44,6 +44,8 @@ const (
DaemonService_RequestClipboardPermission_FullMethodName = "/copysync.v1.DaemonService/RequestClipboardPermission"
DaemonService_RequestLocalNetworkPermission_FullMethodName = "/copysync.v1.DaemonService/RequestLocalNetworkPermission"
DaemonService_GetNetwork_FullMethodName = "/copysync.v1.DaemonService/GetNetwork"
+ DaemonService_ExportDiagnostics_FullMethodName = "/copysync.v1.DaemonService/ExportDiagnostics"
+ DaemonService_SetVerboseLog_FullMethodName = "/copysync.v1.DaemonService/SetVerboseLog"
)
// DaemonServiceClient is the client API for DaemonService service.
@@ -83,6 +85,11 @@ type DaemonServiceClient interface {
RequestLocalNetworkPermission(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error)
// 网络出口与打洞诊断:本机有几个出口、各自的公网地址,见 copysync-cli nat
GetNetwork(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*NetworkInfo, error)
+ // 反馈问题用的诊断报告:版本、系统、设置、设备与网络状态、最近的日志。
+ // 设备名、服务器地址、公网 IP、用户目录、文件名已换成占位符,用户看过后自己贴进 issue
+ ExportDiagnostics(ctx context.Context, in *ExportDiagnosticsRequest, opts ...grpc.CallOption) (*Diagnostics, error)
+ // 临时打开详细日志(调试级别),到时间自动关回去;minutes 为 0 立即关闭
+ SetVerboseLog(ctx context.Context, in *SetVerboseLogRequest, opts ...grpc.CallOption) (*Status, error)
}
type daemonServiceClient struct {
@@ -311,6 +318,26 @@ func (c *daemonServiceClient) GetNetwork(ctx context.Context, in *Empty, opts ..
return out, nil
}
+func (c *daemonServiceClient) ExportDiagnostics(ctx context.Context, in *ExportDiagnosticsRequest, opts ...grpc.CallOption) (*Diagnostics, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(Diagnostics)
+ err := c.cc.Invoke(ctx, DaemonService_ExportDiagnostics_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *daemonServiceClient) SetVerboseLog(ctx context.Context, in *SetVerboseLogRequest, opts ...grpc.CallOption) (*Status, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(Status)
+ err := c.cc.Invoke(ctx, DaemonService_SetVerboseLog_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
// DaemonServiceServer is the server API for DaemonService service.
// All implementations must embed UnimplementedDaemonServiceServer
// for forward compatibility.
@@ -348,6 +375,11 @@ type DaemonServiceServer interface {
RequestLocalNetworkPermission(context.Context, *Empty) (*Empty, error)
// 网络出口与打洞诊断:本机有几个出口、各自的公网地址,见 copysync-cli nat
GetNetwork(context.Context, *Empty) (*NetworkInfo, error)
+ // 反馈问题用的诊断报告:版本、系统、设置、设备与网络状态、最近的日志。
+ // 设备名、服务器地址、公网 IP、用户目录、文件名已换成占位符,用户看过后自己贴进 issue
+ ExportDiagnostics(context.Context, *ExportDiagnosticsRequest) (*Diagnostics, error)
+ // 临时打开详细日志(调试级别),到时间自动关回去;minutes 为 0 立即关闭
+ SetVerboseLog(context.Context, *SetVerboseLogRequest) (*Status, error)
mustEmbedUnimplementedDaemonServiceServer()
}
@@ -418,6 +450,12 @@ func (UnimplementedDaemonServiceServer) RequestLocalNetworkPermission(context.Co
func (UnimplementedDaemonServiceServer) GetNetwork(context.Context, *Empty) (*NetworkInfo, error) {
return nil, status.Error(codes.Unimplemented, "method GetNetwork not implemented")
}
+func (UnimplementedDaemonServiceServer) ExportDiagnostics(context.Context, *ExportDiagnosticsRequest) (*Diagnostics, error) {
+ return nil, status.Error(codes.Unimplemented, "method ExportDiagnostics not implemented")
+}
+func (UnimplementedDaemonServiceServer) SetVerboseLog(context.Context, *SetVerboseLogRequest) (*Status, error) {
+ return nil, status.Error(codes.Unimplemented, "method SetVerboseLog not implemented")
+}
func (UnimplementedDaemonServiceServer) mustEmbedUnimplementedDaemonServiceServer() {}
func (UnimplementedDaemonServiceServer) testEmbeddedByValue() {}
@@ -785,6 +823,42 @@ func _DaemonService_GetNetwork_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
+func _DaemonService_ExportDiagnostics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ExportDiagnosticsRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(DaemonServiceServer).ExportDiagnostics(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: DaemonService_ExportDiagnostics_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(DaemonServiceServer).ExportDiagnostics(ctx, req.(*ExportDiagnosticsRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _DaemonService_SetVerboseLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(SetVerboseLogRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(DaemonServiceServer).SetVerboseLog(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: DaemonService_SetVerboseLog_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(DaemonServiceServer).SetVerboseLog(ctx, req.(*SetVerboseLogRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
// DaemonService_ServiceDesc is the grpc.ServiceDesc for DaemonService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -864,6 +938,14 @@ var DaemonService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetNetwork",
Handler: _DaemonService_GetNetwork_Handler,
},
+ {
+ MethodName: "ExportDiagnostics",
+ Handler: _DaemonService_ExportDiagnostics_Handler,
+ },
+ {
+ MethodName: "SetVerboseLog",
+ Handler: _DaemonService_SetVerboseLog_Handler,
+ },
},
Streams: []grpc.StreamDesc{
{
diff --git a/ui/lib/app_state.dart b/ui/lib/app_state.dart
index 0fef235..544686c 100644
--- a/ui/lib/app_state.dart
+++ b/ui/lib/app_state.dart
@@ -87,6 +87,12 @@ class AppState extends ChangeNotifier {
/// macOS 拦下了发往局域网的包:用户还没允许「本地网络」权限。
bool get lanBlocked => _status?.lanBlocked ?? false;
+ /// 详细日志打开到什么时候;没打开时为 null。
+ DateTime? get verboseLogUntil {
+ final until = _status?.verboseLogUntilUnix.toInt() ?? 0;
+ return until == 0 ? null : DateTime.fromMillisecondsSinceEpoch(until * 1000);
+ }
+
@override
void dispose() {
_retry?.cancel();
@@ -418,6 +424,18 @@ class AppState extends ChangeNotifier {
notifyListeners();
}
+ // ─────────────────────────── 反馈问题 ───────────────────────────
+
+ /// 反馈问题用的诊断报告,由后台服务生成并脱敏,带上最近 [logLines] 行日志。
+ Future<String> exportDiagnostics({int logLines = 200}) async =>
+ (await _client.exportDiagnostics(ExportDiagnosticsRequest(logLines: logLines, uiVersion: appVersion))).report;
+
+ /// 临时打开详细日志 [minutes] 分钟,0 表示立即关闭。
+ Future<void> setVerboseLog(int minutes) async {
+ _status = await _client.setVerboseLog(SetVerboseLogRequest(minutes: minutes));
+ notifyListeners();
+ }
+
Future<void> deleteRecords({List<String>? ids, bool all = false}) async {
await _client.deleteHistory(
DeleteHistoryRequest(ids: ids ?? const [], all: all),
diff --git a/ui/lib/gen/copysync/v1/daemon.pb.dart b/ui/lib/gen/copysync/v1/daemon.pb.dart
index 6adebfe..11b08fa 100644
--- a/ui/lib/gen/copysync/v1/daemon.pb.dart
+++ b/ui/lib/gen/copysync/v1/daemon.pb.dart
@@ -2533,6 +2533,7 @@ class Status extends $pb.GeneratedMessage {
$core.bool? serverConfigured,
$core.bool? lanEnabled,
$core.bool? lanBlocked,
+ $fixnum.Int64? verboseLogUntilUnix,
}) {
final result = Status._();
if (deviceId != null) result.deviceId = deviceId;
@@ -2547,6 +2548,8 @@ class Status extends $pb.GeneratedMessage {
if (serverConfigured != null) result.serverConfigured = serverConfigured;
if (lanEnabled != null) result.lanEnabled = lanEnabled;
if (lanBlocked != null) result.lanBlocked = lanBlocked;
+ if (verboseLogUntilUnix != null)
+ result.verboseLogUntilUnix = verboseLogUntilUnix;
return result;
}
@@ -2574,6 +2577,7 @@ class Status extends $pb.GeneratedMessage {
..aOB(8, _omitFieldNames ? '' : 'serverConfigured')
..aOB(9, _omitFieldNames ? '' : 'lanEnabled')
..aOB(10, _omitFieldNames ? '' : 'lanBlocked')
+ ..aInt64(11, _omitFieldNames ? '' : 'verboseLogUntilUnix')
..hasRequiredFields = false;
@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
@@ -2687,6 +2691,203 @@ class Status extends $pb.GeneratedMessage {
$core.bool hasLanBlocked() => $_has(9);
@$pb.TagNumber(10)
void clearLanBlocked() => $_clearField(10);
+
+ /// 详细日志打开到什么时候;0 表示没打开
+ @$pb.TagNumber(11)
+ $fixnum.Int64 get verboseLogUntilUnix => $_getI64(10);
+ @$pb.TagNumber(11)
+ set verboseLogUntilUnix($fixnum.Int64 value) => $_setInt64(10, value);
+ @$pb.TagNumber(11)
+ $core.bool hasVerboseLogUntilUnix() => $_has(10);
+ @$pb.TagNumber(11)
+ void clearVerboseLogUntilUnix() => $_clearField(11);
+}
+
+class ExportDiagnosticsRequest extends $pb.GeneratedMessage {
+ factory ExportDiagnosticsRequest({
+ $core.int? logLines,
+ $core.String? uiVersion,
+ }) {
+ final result = ExportDiagnosticsRequest._();
+ if (logLines != null) result.logLines = logLines;
+ if (uiVersion != null) result.uiVersion = uiVersion;
+ return result;
+ }
+
+ ExportDiagnosticsRequest._();
+
+ factory ExportDiagnosticsRequest.fromBuffer($core.List<$core.int> data,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ ExportDiagnosticsRequest()..mergeFromBuffer(data, registry);
+ factory ExportDiagnosticsRequest.fromJson($core.String json,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ ExportDiagnosticsRequest()..mergeFromJson(json, registry);
+
+ static final $pb.BuilderInfo _i = $pb.BuilderInfo(
+ _omitMessageNames ? '' : 'ExportDiagnosticsRequest',
+ package: const $pb.PackageName(_omitMessageNames ? '' : 'copysync.v1'),
+ createEmptyInstance: ExportDiagnosticsRequest.$_createMessage)
+ ..aI(1, _omitFieldNames ? '' : 'logLines')
+ ..aOS(2, _omitFieldNames ? '' : 'uiVersion')
+ ..hasRequiredFields = false;
+
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ ExportDiagnosticsRequest clone() => deepCopy();
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ ExportDiagnosticsRequest copyWith(
+ void Function(ExportDiagnosticsRequest) updates) =>
+ super.copyWith((message) => updates(message as ExportDiagnosticsRequest))
+ as ExportDiagnosticsRequest;
+
+ @$core.override
+ $pb.BuilderInfo get info_ => _i;
+
+ @$core.pragma('dart2js:noInline')
+ @$core.Deprecated(
+ 'Use ExportDiagnosticsRequest() / ExportDiagnosticsRequest.new instead')
+ static ExportDiagnosticsRequest create() => ExportDiagnosticsRequest._();
+ static $pb.GeneratedMessage $_createMessage() => ExportDiagnosticsRequest._();
+ @$core.override
+ ExportDiagnosticsRequest createEmptyInstance() =>
+ ExportDiagnosticsRequest._();
+ @$core.pragma('dart2js:noInline')
+ static ExportDiagnosticsRequest getDefault() => _defaultInstance ??=
+ $pb.GeneratedMessage.$_defaultFor<ExportDiagnosticsRequest>(
+ ExportDiagnosticsRequest.$_createMessage);
+ static ExportDiagnosticsRequest? _defaultInstance;
+
+ @$pb.TagNumber(1)
+ $core.int get logLines => $_getIZ(0);
+ @$pb.TagNumber(1)
+ set logLines($core.int value) => $_setSignedInt32(0, value);
+ @$pb.TagNumber(1)
+ $core.bool hasLogLines() => $_has(0);
+ @$pb.TagNumber(1)
+ void clearLogLines() => $_clearField(1);
+
+ @$pb.TagNumber(2)
+ $core.String get uiVersion => $_getSZ(1);
+ @$pb.TagNumber(2)
+ set uiVersion($core.String value) => $_setString(1, value);
+ @$pb.TagNumber(2)
+ $core.bool hasUiVersion() => $_has(1);
+ @$pb.TagNumber(2)
+ void clearUiVersion() => $_clearField(2);
+}
+
+class Diagnostics extends $pb.GeneratedMessage {
+ factory Diagnostics({
+ $core.String? report,
+ }) {
+ final result = Diagnostics._();
+ if (report != null) result.report = report;
+ return result;
+ }
+
+ Diagnostics._();
+
+ factory Diagnostics.fromBuffer($core.List<$core.int> data,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ Diagnostics()..mergeFromBuffer(data, registry);
+ factory Diagnostics.fromJson($core.String json,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ Diagnostics()..mergeFromJson(json, registry);
+
+ static final $pb.BuilderInfo _i = $pb.BuilderInfo(
+ _omitMessageNames ? '' : 'Diagnostics',
+ package: const $pb.PackageName(_omitMessageNames ? '' : 'copysync.v1'),
+ createEmptyInstance: Diagnostics.$_createMessage)
+ ..aOS(1, _omitFieldNames ? '' : 'report')
+ ..hasRequiredFields = false;
+
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ Diagnostics clone() => deepCopy();
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ Diagnostics copyWith(void Function(Diagnostics) updates) =>
+ super.copyWith((message) => updates(message as Diagnostics))
+ as Diagnostics;
+
+ @$core.override
+ $pb.BuilderInfo get info_ => _i;
+
+ @$core.pragma('dart2js:noInline')
+ @$core.Deprecated('Use Diagnostics() / Diagnostics.new instead')
+ static Diagnostics create() => Diagnostics._();
+ static $pb.GeneratedMessage $_createMessage() => Diagnostics._();
+ @$core.override
+ Diagnostics createEmptyInstance() => Diagnostics._();
+ @$core.pragma('dart2js:noInline')
+ static Diagnostics getDefault() =>
+ _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Diagnostics>(
+ Diagnostics.$_createMessage);
+ static Diagnostics? _defaultInstance;
+
+ @$pb.TagNumber(1)
+ $core.String get report => $_getSZ(0);
+ @$pb.TagNumber(1)
+ set report($core.String value) => $_setString(0, value);
+ @$pb.TagNumber(1)
+ $core.bool hasReport() => $_has(0);
+ @$pb.TagNumber(1)
+ void clearReport() => $_clearField(1);
+}
+
+class SetVerboseLogRequest extends $pb.GeneratedMessage {
+ factory SetVerboseLogRequest({
+ $core.int? minutes,
+ }) {
+ final result = SetVerboseLogRequest._();
+ if (minutes != null) result.minutes = minutes;
+ return result;
+ }
+
+ SetVerboseLogRequest._();
+
+ factory SetVerboseLogRequest.fromBuffer($core.List<$core.int> data,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ SetVerboseLogRequest()..mergeFromBuffer(data, registry);
+ factory SetVerboseLogRequest.fromJson($core.String json,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ SetVerboseLogRequest()..mergeFromJson(json, registry);
+
+ static final $pb.BuilderInfo _i = $pb.BuilderInfo(
+ _omitMessageNames ? '' : 'SetVerboseLogRequest',
+ package: const $pb.PackageName(_omitMessageNames ? '' : 'copysync.v1'),
+ createEmptyInstance: SetVerboseLogRequest.$_createMessage)
+ ..aI(1, _omitFieldNames ? '' : 'minutes')
+ ..hasRequiredFields = false;
+
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ SetVerboseLogRequest clone() => deepCopy();
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ SetVerboseLogRequest copyWith(void Function(SetVerboseLogRequest) updates) =>
+ super.copyWith((message) => updates(message as SetVerboseLogRequest))
+ as SetVerboseLogRequest;
+
+ @$core.override
+ $pb.BuilderInfo get info_ => _i;
+
+ @$core.pragma('dart2js:noInline')
+ @$core.Deprecated(
+ 'Use SetVerboseLogRequest() / SetVerboseLogRequest.new instead')
+ static SetVerboseLogRequest create() => SetVerboseLogRequest._();
+ static $pb.GeneratedMessage $_createMessage() => SetVerboseLogRequest._();
+ @$core.override
+ SetVerboseLogRequest createEmptyInstance() => SetVerboseLogRequest._();
+ @$core.pragma('dart2js:noInline')
+ static SetVerboseLogRequest getDefault() => _defaultInstance ??=
+ $pb.GeneratedMessage.$_defaultFor<SetVerboseLogRequest>(
+ SetVerboseLogRequest.$_createMessage);
+ static SetVerboseLogRequest? _defaultInstance;
+
+ @$pb.TagNumber(1)
+ $core.int get minutes => $_getIZ(0);
+ @$pb.TagNumber(1)
+ set minutes($core.int value) => $_setSignedInt32(0, value);
+ @$pb.TagNumber(1)
+ $core.bool hasMinutes() => $_has(0);
+ @$pb.TagNumber(1)
+ void clearMinutes() => $_clearField(1);
}
class GetImagePreviewRequest extends $pb.GeneratedMessage {
diff --git a/ui/lib/gen/copysync/v1/daemon.pbgrpc.dart b/ui/lib/gen/copysync/v1/daemon.pbgrpc.dart
index 231c914..7deebe8 100644
--- a/ui/lib/gen/copysync/v1/daemon.pbgrpc.dart
+++ b/ui/lib/gen/copysync/v1/daemon.pbgrpc.dart
@@ -191,6 +191,23 @@ class DaemonServiceClient extends $grpc.Client {
return $createUnaryCall(_$getNetwork, request, options: options);
}
+ /// 反馈问题用的诊断报告:版本、系统、设置、设备与网络状态、最近的日志。
+ /// 设备名、服务器地址、公网 IP、用户目录、文件名已换成占位符,用户看过后自己贴进 issue
+ $grpc.ResponseFuture<$0.Diagnostics> exportDiagnostics(
+ $0.ExportDiagnosticsRequest request, {
+ $grpc.CallOptions? options,
+ }) {
+ return $createUnaryCall(_$exportDiagnostics, request, options: options);
+ }
+
+ /// 临时打开详细日志(调试级别),到时间自动关回去;minutes 为 0 立即关闭
+ $grpc.ResponseFuture<$0.Status> setVerboseLog(
+ $0.SetVerboseLogRequest request, {
+ $grpc.CallOptions? options,
+ }) {
+ return $createUnaryCall(_$setVerboseLog, request, options: options);
+ }
+
// method descriptors
static final _$subscribe = $grpc.ClientMethod<$0.SubscribeRequest, $0.Event>(
@@ -285,6 +302,16 @@ class DaemonServiceClient extends $grpc.Client {
'/copysync.v1.DaemonService/GetNetwork',
($0.Empty value) => value.writeToBuffer(),
$0.NetworkInfo.fromBuffer);
+ static final _$exportDiagnostics =
+ $grpc.ClientMethod<$0.ExportDiagnosticsRequest, $0.Diagnostics>(
+ '/copysync.v1.DaemonService/ExportDiagnostics',
+ ($0.ExportDiagnosticsRequest value) => value.writeToBuffer(),
+ $0.Diagnostics.fromBuffer);
+ static final _$setVerboseLog =
+ $grpc.ClientMethod<$0.SetVerboseLogRequest, $0.Status>(
+ '/copysync.v1.DaemonService/SetVerboseLog',
+ ($0.SetVerboseLogRequest value) => value.writeToBuffer(),
+ $0.Status.fromBuffer);
}
@$pb.GrpcServiceName('copysync.v1.DaemonService')
@@ -444,6 +471,22 @@ abstract class DaemonServiceBase extends $grpc.Service {
false,
($core.List<$core.int> value) => $0.Empty.fromBuffer(value),
($0.NetworkInfo value) => value.writeToBuffer()));
+ $addMethod($grpc.ServiceMethod<$0.ExportDiagnosticsRequest, $0.Diagnostics>(
+ 'ExportDiagnostics',
+ exportDiagnostics_Pre,
+ false,
+ false,
+ ($core.List<$core.int> value) =>
+ $0.ExportDiagnosticsRequest.fromBuffer(value),
+ ($0.Diagnostics value) => value.writeToBuffer()));
+ $addMethod($grpc.ServiceMethod<$0.SetVerboseLogRequest, $0.Status>(
+ 'SetVerboseLog',
+ setVerboseLog_Pre,
+ false,
+ false,
+ ($core.List<$core.int> value) =>
+ $0.SetVerboseLogRequest.fromBuffer(value),
+ ($0.Status value) => value.writeToBuffer()));
}
$async.Stream<$0.Event> subscribe_Pre($grpc.ServiceCall $call,
@@ -606,4 +649,20 @@ abstract class DaemonServiceBase extends $grpc.Service {
$async.Future<$0.NetworkInfo> getNetwork(
$grpc.ServiceCall call, $0.Empty request);
+
+ $async.Future<$0.Diagnostics> exportDiagnostics_Pre($grpc.ServiceCall $call,
+ $async.Future<$0.ExportDiagnosticsRequest> $request) async {
+ return exportDiagnostics($call, await $request);
+ }
+
+ $async.Future<$0.Diagnostics> exportDiagnostics(
+ $grpc.ServiceCall call, $0.ExportDiagnosticsRequest request);
+
+ $async.Future<$0.Status> setVerboseLog_Pre($grpc.ServiceCall $call,
+ $async.Future<$0.SetVerboseLogRequest> $request) async {
+ return setVerboseLog($call, await $request);
+ }
+
+ $async.Future<$0.Status> setVerboseLog(
+ $grpc.ServiceCall call, $0.SetVerboseLogRequest request);
}
diff --git a/ui/lib/gen/copysync/v1/daemon.pbjson.dart b/ui/lib/gen/copysync/v1/daemon.pbjson.dart
index f18c73c..22c26ce 100644
--- a/ui/lib/gen/copysync/v1/daemon.pbjson.dart
+++ b/ui/lib/gen/copysync/v1/daemon.pbjson.dart
@@ -762,6 +762,13 @@ const Status$json = {
},
{'1': 'lan_enabled', '3': 9, '4': 1, '5': 8, '10': 'lanEnabled'},
{'1': 'lan_blocked', '3': 10, '4': 1, '5': 8, '10': 'lanBlocked'},
+ {
+ '1': 'verbose_log_until_unix',
+ '3': 11,
+ '4': 1,
+ '5': 3,
+ '10': 'verboseLogUntilUnix'
+ },
],
};
@@ -774,7 +781,48 @@ final $typed_data.Uint8List statusDescriptor = $convert.base64Decode(
'ZWQYBSABKANSDmNhY2hlQnl0ZXNVc2VkEiEKDHBlZXJzX29ubGluZRgGIAEoBVILcGVlcnNPbm'
'xpbmUSGAoHdmVyc2lvbhgHIAEoCVIHdmVyc2lvbhIrChFzZXJ2ZXJfY29uZmlndXJlZBgIIAEo'
'CFIQc2VydmVyQ29uZmlndXJlZBIfCgtsYW5fZW5hYmxlZBgJIAEoCFIKbGFuRW5hYmxlZBIfCg'
- 'tsYW5fYmxvY2tlZBgKIAEoCFIKbGFuQmxvY2tlZA==');
+ 'tsYW5fYmxvY2tlZBgKIAEoCFIKbGFuQmxvY2tlZBIzChZ2ZXJib3NlX2xvZ191bnRpbF91bml4'
+ 'GAsgASgDUhN2ZXJib3NlTG9nVW50aWxVbml4');
+
+@$core.Deprecated('Use exportDiagnosticsRequestDescriptor instead')
+const ExportDiagnosticsRequest$json = {
+ '1': 'ExportDiagnosticsRequest',
+ '2': [
+ {'1': 'log_lines', '3': 1, '4': 1, '5': 5, '10': 'logLines'},
+ {'1': 'ui_version', '3': 2, '4': 1, '5': 9, '10': 'uiVersion'},
+ ],
+};
+
+/// Descriptor for `ExportDiagnosticsRequest`. Decode as a `google.protobuf.DescriptorProto`.
+final $typed_data.Uint8List exportDiagnosticsRequestDescriptor =
+ $convert.base64Decode(
+ 'ChhFeHBvcnREaWFnbm9zdGljc1JlcXVlc3QSGwoJbG9nX2xpbmVzGAEgASgFUghsb2dMaW5lcx'
+ 'IdCgp1aV92ZXJzaW9uGAIgASgJUgl1aVZlcnNpb24=');
+
+@$core.Deprecated('Use diagnosticsDescriptor instead')
+const Diagnostics$json = {
+ '1': 'Diagnostics',
+ '2': [
+ {'1': 'report', '3': 1, '4': 1, '5': 9, '10': 'report'},
+ ],
+};
+
+/// Descriptor for `Diagnostics`. Decode as a `google.protobuf.DescriptorProto`.
+final $typed_data.Uint8List diagnosticsDescriptor = $convert
+ .base64Decode('CgtEaWFnbm9zdGljcxIWCgZyZXBvcnQYASABKAlSBnJlcG9ydA==');
+
+@$core.Deprecated('Use setVerboseLogRequestDescriptor instead')
+const SetVerboseLogRequest$json = {
+ '1': 'SetVerboseLogRequest',
+ '2': [
+ {'1': 'minutes', '3': 1, '4': 1, '5': 5, '10': 'minutes'},
+ ],
+};
+
+/// Descriptor for `SetVerboseLogRequest`. Decode as a `google.protobuf.DescriptorProto`.
+final $typed_data.Uint8List setVerboseLogRequestDescriptor =
+ $convert.base64Decode(
+ 'ChRTZXRWZXJib3NlTG9nUmVxdWVzdBIYCgdtaW51dGVzGAEgASgFUgdtaW51dGVz');
@$core.Deprecated('Use getImagePreviewRequestDescriptor instead')
const GetImagePreviewRequest$json = {
diff --git a/ui/lib/icons.dart b/ui/lib/icons.dart
index 1533a65..45c7cbe 100644
--- a/ui/lib/icons.dart
+++ b/ui/lib/icons.dart
@@ -22,6 +22,8 @@ abstract final class AppIcons {
_pick(CupertinoIcons.checkmark_circle, FluentIcons.checkmark_circle_24_regular);
static IconData get xmark => _pick(CupertinoIcons.xmark, FluentIcons.dismiss_24_regular);
static IconData get search => _pick(CupertinoIcons.search, FluentIcons.search_24_regular);
+ static IconData get arrowClockwise =>
+ _pick(CupertinoIcons.arrow_clockwise, FluentIcons.arrow_clockwise_24_regular);
// 搜索框里的清除按钮:实心圆里一个叉,与系统的搜索框一致
static IconData get clearField =>
_pick(CupertinoIcons.xmark_circle_fill, FluentIcons.dismiss_circle_20_filled);
diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arb
index 5242e76..37a45cf 100644
--- a/ui/lib/l10n/app_en.arb
+++ b/ui/lib/l10n/app_en.arb
@@ -458,6 +458,41 @@
"urlMustBeWs": "The address must start with ws:// or wss://",
"serverUpdated": "Server updated. Reconnecting…",
"deviceNameUpdated": "Device name updated",
+ "diagIntro": "This report has the app version, your system, settings, devices and recent logs. Device names, the server address, public IP addresses, your user folder and file names are replaced, and what you copy is never written to the logs. Issues on GitHub are public, so read it through before posting.",
+ "diagVerboseTitle": "Detailed logging",
+ "diagVerboseDesc": "For connection problems: turn it on, make the problem happen again, then come back for the report. It turns itself off after 30 minutes.",
+ "diagVerboseOn": "Turn on for 30 minutes",
+ "diagVerboseUntil": "On until {time}",
+ "@diagVerboseUntil": {
+ "placeholders": {
+ "time": {
+ "type": "String"
+ }
+ }
+ },
+ "diagVerboseOff": "Turn off",
+ "diagRefresh": "Regenerate",
+ "diagSave": "Save as file",
+ "diagSaved": "Saved to your Downloads folder: {name}",
+ "@diagSaved": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "diagCopy": "Copy report",
+ "diagCopied": "Report copied",
+ "diagNewIssue": "New issue on GitHub",
+ "diagIssueHint": "Report copied. Paste it into the issue's “Diagnostics report” box.",
+ "diagFailed": "Couldn't create the report: {detail}",
+ "@diagFailed": {
+ "placeholders": {
+ "detail": {
+ "type": "String"
+ }
+ }
+ },
"svcExtractTitle": "Install or extract CopySync first",
"svcExtractBody": "CopySync is running straight from the zip, and its temporary folder disappears when you close it. Run the installer, or extract the whole folder and open it from there, to turn on background sync.",
"svcMoveTitle": "Move CopySync to Applications first",
diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arb
index c6ffa2c..0385edf 100644
--- a/ui/lib/l10n/app_ja.arb
+++ b/ui/lib/l10n/app_ja.arb
@@ -219,6 +219,20 @@
"urlMustBeWs": "アドレスは ws:// または wss:// で始めてください",
"serverUpdated": "サーバーを更新しました。再接続しています…",
"deviceNameUpdated": "デバイス名を更新しました",
+ "diagIntro": "このレポートには、バージョン、システム、設定、デバイスの状態、最近のログが含まれます。デバイス名、サーバーのアドレス、グローバル IP アドレス、ユーザーフォルダ、ファイル名は置き換え済みで、コピーした内容はログに書かれません。GitHub の Issue は公開されるので、投稿する前に目を通してください。",
+ "diagVerboseTitle": "詳細ログ",
+ "diagVerboseDesc": "接続の問題を調べるときに使います。オンにして問題をもう一度起こしてから、ここでレポートを作り直してください。30 分後に自動でオフになります。",
+ "diagVerboseOn": "30 分間オンにする",
+ "diagVerboseUntil": "{time} までオン",
+ "diagVerboseOff": "オフにする",
+ "diagRefresh": "作り直す",
+ "diagSave": "ファイルに保存",
+ "diagSaved": "「ダウンロード」フォルダに保存しました:{name}",
+ "diagCopy": "レポートをコピー",
+ "diagCopied": "レポートをコピーしました",
+ "diagNewIssue": "GitHub で Issue を作成",
+ "diagIssueHint": "レポートをコピーしました。Issue の「Diagnostics report」欄に貼り付けてください",
+ "diagFailed": "レポートを作成できませんでした:{detail}",
"svcExtractTitle": "先に CopySync をインストールまたは展開してください",
"svcExtractBody": "CopySync は zip から直接開かれていて、閉じると一時フォルダごと消えます。インストーラーを実行するか、フォルダ全体を展開してから開くと、バックグラウンド同期を有効にできます。",
"svcMoveTitle": "先に CopySync を「アプリケーション」に移動してください",
diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dart
index 28fc2ef..eb9f489 100644
--- a/ui/lib/l10n/app_localizations.dart
+++ b/ui/lib/l10n/app_localizations.dart
@@ -416,36 +416,6 @@ abstract class AppLocalizations {
/// **'Nothing of this kind'**
String get historyEmptyFilteredTitle;
- /// No description provided for @searchHint.
- ///
- /// In en, this message translates to:
- /// **'Search text and file names'**
- String get searchHint;
-
- /// No description provided for @searchClear.
- ///
- /// In en, this message translates to:
- /// **'Clear search'**
- String get searchClear;
-
- /// No description provided for @searchResultCount.
- ///
- /// In en, this message translates to:
- /// **'{count, plural, =1{1 match} other{{count} matches}}'**
- String searchResultCount(int count);
-
- /// No description provided for @searchEmptyTitle.
- ///
- /// In en, this message translates to:
- /// **'No matches for “{query}”'**
- String searchEmptyTitle(String query);
-
- /// No description provided for @searchEmptyBody.
- ///
- /// In en, this message translates to:
- /// **'Search looks through copied text and the names of copied files.'**
- String get searchEmptyBody;
-
/// No description provided for @historyEmptyBody.
///
/// In en, this message translates to:
@@ -572,6 +542,36 @@ abstract class AppLocalizations {
/// **'{name} and {others, plural, =1{1 more} other{{others} more}}'**
String itemsSummary(String name, int others, int count);
+ /// No description provided for @searchHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Search text and file names'**
+ String get searchHint;
+
+ /// No description provided for @searchClear.
+ ///
+ /// In en, this message translates to:
+ /// **'Clear search'**
+ String get searchClear;
+
+ /// No description provided for @searchResultCount.
+ ///
+ /// In en, this message translates to:
+ /// **'{count, plural, =1{1 match} other{{count} matches}}'**
+ String searchResultCount(int count);
+
+ /// No description provided for @searchEmptyTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'No matches for “{query}”'**
+ String searchEmptyTitle(String query);
+
+ /// No description provided for @searchEmptyBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Search looks through copied text and the names of copied files.'**
+ String get searchEmptyBody;
+
/// No description provided for @imagePreviewTitle.
///
/// In en, this message translates to:
@@ -1424,6 +1424,90 @@ abstract class AppLocalizations {
/// **'Device name updated'**
String get deviceNameUpdated;
+ /// No description provided for @diagIntro.
+ ///
+ /// In en, this message translates to:
+ /// **'This report has the app version, your system, settings, devices and recent logs. Device names, the server address, public IP addresses, your user folder and file names are replaced, and what you copy is never written to the logs. Issues on GitHub are public, so read it through before posting.'**
+ String get diagIntro;
+
+ /// No description provided for @diagVerboseTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Detailed logging'**
+ String get diagVerboseTitle;
+
+ /// No description provided for @diagVerboseDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'For connection problems: turn it on, make the problem happen again, then come back for the report. It turns itself off after 30 minutes.'**
+ String get diagVerboseDesc;
+
+ /// No description provided for @diagVerboseOn.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn on for 30 minutes'**
+ String get diagVerboseOn;
+
+ /// No description provided for @diagVerboseUntil.
+ ///
+ /// In en, this message translates to:
+ /// **'On until {time}'**
+ String diagVerboseUntil(String time);
+
+ /// No description provided for @diagVerboseOff.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn off'**
+ String get diagVerboseOff;
+
+ /// No description provided for @diagRefresh.
+ ///
+ /// In en, this message translates to:
+ /// **'Regenerate'**
+ String get diagRefresh;
+
+ /// No description provided for @diagSave.
+ ///
+ /// In en, this message translates to:
+ /// **'Save as file'**
+ String get diagSave;
+
+ /// No description provided for @diagSaved.
+ ///
+ /// In en, this message translates to:
+ /// **'Saved to your Downloads folder: {name}'**
+ String diagSaved(String name);
+
+ /// No description provided for @diagCopy.
+ ///
+ /// In en, this message translates to:
+ /// **'Copy report'**
+ String get diagCopy;
+
+ /// No description provided for @diagCopied.
+ ///
+ /// In en, this message translates to:
+ /// **'Report copied'**
+ String get diagCopied;
+
+ /// No description provided for @diagNewIssue.
+ ///
+ /// In en, this message translates to:
+ /// **'New issue on GitHub'**
+ String get diagNewIssue;
+
+ /// No description provided for @diagIssueHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Report copied. Paste it into the issue\'s “Diagnostics report” box.'**
+ String get diagIssueHint;
+
+ /// No description provided for @diagFailed.
+ ///
+ /// In en, this message translates to:
+ /// **'Couldn\'t create the report: {detail}'**
+ String diagFailed(String detail);
+
/// No description provided for @svcExtractTitle.
///
/// In en, this message translates to:
diff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dart
index bbd9b73..d0bb7f2 100644
--- a/ui/lib/l10n/app_localizations_en.dart
+++ b/ui/lib/l10n/app_localizations_en.dart
@@ -243,32 +243,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get historyEmptyFilteredTitle => 'Nothing of this kind';
- @override
- String get searchHint => 'Search text and file names';
-
- @override
- String get searchClear => 'Clear search';
-
- @override
- String searchResultCount(int count) {
- String _temp0 = intl.Intl.pluralLogic(
- count,
- locale: localeName,
- other: '$count matches',
- one: '1 match',
- );
- return '$_temp0';
- }
-
- @override
- String searchEmptyTitle(String query) {
- return 'No matches for “$query”';
- }
-
- @override
- String get searchEmptyBody =>
- 'Search looks through copied text and the names of copied files.';
-
@override
String get historyEmptyBody =>
'Copy text, an image or a file on any paired device and it appears here.';
@@ -345,6 +319,32 @@ class AppLocalizationsEn extends AppLocalizations {
return '$name and $_temp0';
}
+ @override
+ String get searchHint => 'Search text and file names';
+
+ @override
+ String get searchClear => 'Clear search';
+
+ @override
+ String searchResultCount(int count) {
+ String _temp0 = intl.Intl.pluralLogic(
+ count,
+ locale: localeName,
+ other: '$count matches',
+ one: '1 match',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String searchEmptyTitle(String query) {
+ return 'No matches for “$query”';
+ }
+
+ @override
+ String get searchEmptyBody =>
+ 'Search looks through copied text and the names of copied files.';
+
@override
String get imagePreviewTitle => 'Image preview';
@@ -823,6 +823,57 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get deviceNameUpdated => 'Device name updated';
+ @override
+ String get diagIntro =>
+ 'This report has the app version, your system, settings, devices and recent logs. Device names, the server address, public IP addresses, your user folder and file names are replaced, and what you copy is never written to the logs. Issues on GitHub are public, so read it through before posting.';
+
+ @override
+ String get diagVerboseTitle => 'Detailed logging';
+
+ @override
+ String get diagVerboseDesc =>
+ 'For connection problems: turn it on, make the problem happen again, then come back for the report. It turns itself off after 30 minutes.';
+
+ @override
+ String get diagVerboseOn => 'Turn on for 30 minutes';
+
+ @override
+ String diagVerboseUntil(String time) {
+ return 'On until $time';
+ }
+
+ @override
+ String get diagVerboseOff => 'Turn off';
+
+ @override
+ String get diagRefresh => 'Regenerate';
+
+ @override
+ String get diagSave => 'Save as file';
+
+ @override
+ String diagSaved(String name) {
+ return 'Saved to your Downloads folder: $name';
+ }
+
+ @override
+ String get diagCopy => 'Copy report';
+
+ @override
+ String get diagCopied => 'Report copied';
+
+ @override
+ String get diagNewIssue => 'New issue on GitHub';
+
+ @override
+ String get diagIssueHint =>
+ 'Report copied. Paste it into the issue\'s “Diagnostics report” box.';
+
+ @override
+ String diagFailed(String detail) {
+ return 'Couldn\'t create the report: $detail';
+ }
+
@override
String get svcExtractTitle => 'Install or extract CopySync first';
diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dart
index 67c267f..ab15f7a 100644
--- a/ui/lib/l10n/app_localizations_ja.dart
+++ b/ui/lib/l10n/app_localizations_ja.dart
@@ -191,25 +191,6 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get historyEmptyFilteredTitle => 'この種類の履歴はありません';
- @override
- String get searchHint => 'テキストとファイル名を検索';
-
- @override
- String get searchClear => '検索をクリア';
-
- @override
- String searchResultCount(int count) {
- return '$count 件見つかりました';
- }
-
- @override
- String searchEmptyTitle(String query) {
- return '「$query」は見つかりません';
- }
-
- @override
- String get searchEmptyBody => 'コピーしたテキストとファイル名から検索します。';
-
@override
String get historyEmptyBody => 'ペアリングしたどのデバイスでテキスト、画像、ファイルをコピーしても、ここに表示されます。';
@@ -279,6 +260,25 @@ class AppLocalizationsJa extends AppLocalizations {
return '$name ほか $others 件';
}
+ @override
+ String get searchHint => 'テキストとファイル名を検索';
+
+ @override
+ String get searchClear => '検索をクリア';
+
+ @override
+ String searchResultCount(int count) {
+ return '$count 件見つかりました';
+ }
+
+ @override
+ String searchEmptyTitle(String query) {
+ return '「$query」は見つかりません';
+ }
+
+ @override
+ String get searchEmptyBody => 'コピーしたテキストとファイル名から検索します。';
+
@override
String get imagePreviewTitle => '画像プレビュー';
@@ -745,6 +745,57 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get deviceNameUpdated => 'デバイス名を更新しました';
+ @override
+ String get diagIntro =>
+ 'このレポートには、バージョン、システム、設定、デバイスの状態、最近のログが含まれます。デバイス名、サーバーのアドレス、グローバル IP アドレス、ユーザーフォルダ、ファイル名は置き換え済みで、コピーした内容はログに書かれません。GitHub の Issue は公開されるので、投稿する前に目を通してください。';
+
+ @override
+ String get diagVerboseTitle => '詳細ログ';
+
+ @override
+ String get diagVerboseDesc =>
+ '接続の問題を調べるときに使います。オンにして問題をもう一度起こしてから、ここでレポートを作り直してください。30 分後に自動でオフになります。';
+
+ @override
+ String get diagVerboseOn => '30 分間オンにする';
+
+ @override
+ String diagVerboseUntil(String time) {
+ return '$time までオン';
+ }
+
+ @override
+ String get diagVerboseOff => 'オフにする';
+
+ @override
+ String get diagRefresh => '作り直す';
+
+ @override
+ String get diagSave => 'ファイルに保存';
+
+ @override
+ String diagSaved(String name) {
+ return '「ダウンロード」フォルダに保存しました:$name';
+ }
+
+ @override
+ String get diagCopy => 'レポートをコピー';
+
+ @override
+ String get diagCopied => 'レポートをコピーしました';
+
+ @override
+ String get diagNewIssue => 'GitHub で Issue を作成';
+
+ @override
+ String get diagIssueHint =>
+ 'レポートをコピーしました。Issue の「Diagnostics report」欄に貼り付けてください';
+
+ @override
+ String diagFailed(String detail) {
+ return 'レポートを作成できませんでした:$detail';
+ }
+
@override
String get svcExtractTitle => '先に CopySync をインストールまたは展開してください';
diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dart
index d20ac63..ff9e94e 100644
--- a/ui/lib/l10n/app_localizations_zh.dart
+++ b/ui/lib/l10n/app_localizations_zh.dart
@@ -191,25 +191,6 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get historyEmptyFilteredTitle => '没有这一类的记录';
- @override
- String get searchHint => '搜索文字和文件名';
-
- @override
- String get searchClear => '清除搜索';
-
- @override
- String searchResultCount(int count) {
- return '找到 $count 条';
- }
-
- @override
- String searchEmptyTitle(String query) {
- return '没有找到「$query」';
- }
-
- @override
- String get searchEmptyBody => '搜索的是复制过的文字和文件名。';
-
@override
String get historyEmptyBody => '在任意一台已配对的设备上复制文本、图片或文件,记录会出现在这里。';
@@ -278,6 +259,25 @@ class AppLocalizationsZh extends AppLocalizations {
return '$name 等 $count 项';
}
+ @override
+ String get searchHint => '搜索文字和文件名';
+
+ @override
+ String get searchClear => '清除搜索';
+
+ @override
+ String searchResultCount(int count) {
+ return '找到 $count 条';
+ }
+
+ @override
+ String searchEmptyTitle(String query) {
+ return '没有找到「$query」';
+ }
+
+ @override
+ String get searchEmptyBody => '搜索的是复制过的文字和文件名。';
+
@override
String get imagePreviewTitle => '图片预览';
@@ -738,6 +738,55 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get deviceNameUpdated => '设备名称已更新';
+ @override
+ String get diagIntro =>
+ '报告里有版本、系统、设置、设备状态和最近的日志。设备名、服务器地址、公网 IP、用户目录和文件名都已替换,复制的内容从不写进日志。GitHub 上的问题是公开的,贴出去之前请看一遍。';
+
+ @override
+ String get diagVerboseTitle => '详细日志';
+
+ @override
+ String get diagVerboseDesc => '连接方面的问题常要看它:打开后重现一次问题,再回来生成报告。30 分钟后自动关闭。';
+
+ @override
+ String get diagVerboseOn => '打开 30 分钟';
+
+ @override
+ String diagVerboseUntil(String time) {
+ return '已打开,$time 自动关闭';
+ }
+
+ @override
+ String get diagVerboseOff => '关闭';
+
+ @override
+ String get diagRefresh => '重新生成';
+
+ @override
+ String get diagSave => '保存为文件';
+
+ @override
+ String diagSaved(String name) {
+ return '已保存到「下载」文件夹:$name';
+ }
+
+ @override
+ String get diagCopy => '拷贝报告';
+
+ @override
+ String get diagCopied => '报告已拷贝';
+
+ @override
+ String get diagNewIssue => '在 GitHub 上提问题';
+
+ @override
+ String get diagIssueHint => '报告已拷贝,粘贴到问题里的「诊断报告」一栏';
+
+ @override
+ String diagFailed(String detail) {
+ return '生成报告失败:$detail';
+ }
+
@override
String get svcExtractTitle => '先解压或安装 CopySync';
@@ -990,25 +1039,6 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
@override
String get historyEmptyFilteredTitle => '沒有這一類的記錄';
- @override
- String get searchHint => '搜尋文字和檔案名稱';
-
- @override
- String get searchClear => '清除搜尋';
-
- @override
- String searchResultCount(int count) {
- return '找到 $count 條';
- }
-
- @override
- String searchEmptyTitle(String query) {
- return '找不到「$query」';
- }
-
- @override
- String get searchEmptyBody => '搜尋範圍是複製過的文字和檔案名稱。';
-
@override
String get historyEmptyBody => '在任何一部已配對的裝置上複製文字、圖片或檔案,記錄會出現在這裏。';
@@ -1078,6 +1108,25 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
return '$name 等 $count 項';
}
+ @override
+ String get searchHint => '搜尋文字和檔案名稱';
+
+ @override
+ String get searchClear => '清除搜尋';
+
+ @override
+ String searchResultCount(int count) {
+ return '找到 $count 條';
+ }
+
+ @override
+ String searchEmptyTitle(String query) {
+ return '找不到「$query」';
+ }
+
+ @override
+ String get searchEmptyBody => '搜尋範圍是複製過的文字和檔案名稱。';
+
@override
String get imagePreviewTitle => '圖片預覽';
@@ -1538,6 +1587,55 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
@override
String get deviceNameUpdated => '裝置名稱已更新';
+ @override
+ String get diagIntro =>
+ '報告裏有版本、系統、設定、裝置狀態和最近的日誌。裝置名稱、伺服器地址、公網 IP、用戶資料夾和檔案名稱都已替換,複製的內容從不寫進日誌。GitHub 上的問題是公開的,貼出去之前請看一遍。';
+
+ @override
+ String get diagVerboseTitle => '詳細日誌';
+
+ @override
+ String get diagVerboseDesc => '連線方面的問題常要看它:開啟後重現一次問題,再回來產生報告。30 分鐘後自動關閉。';
+
+ @override
+ String get diagVerboseOn => '開啟 30 分鐘';
+
+ @override
+ String diagVerboseUntil(String time) {
+ return '已開啟,$time 自動關閉';
+ }
+
+ @override
+ String get diagVerboseOff => '關閉';
+
+ @override
+ String get diagRefresh => '重新產生';
+
+ @override
+ String get diagSave => '儲存為檔案';
+
+ @override
+ String diagSaved(String name) {
+ return '已儲存到「下載」資料夾:$name';
+ }
+
+ @override
+ String get diagCopy => '拷貝報告';
+
+ @override
+ String get diagCopied => '報告已拷貝';
+
+ @override
+ String get diagNewIssue => '在 GitHub 上回報';
+
+ @override
+ String get diagIssueHint => '報告已拷貝,貼到問題裏的「診斷報告」一欄';
+
+ @override
+ String diagFailed(String detail) {
+ return '產生報告失敗:$detail';
+ }
+
@override
String get svcExtractTitle => '先解壓縮或安裝 CopySync';
@@ -1790,25 +1888,6 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
@override
String get historyEmptyFilteredTitle => '沒有這一類的記錄';
- @override
- String get searchHint => '搜尋文字和檔名';
-
- @override
- String get searchClear => '清除搜尋';
-
- @override
- String searchResultCount(int count) {
- return '找到 $count 筆';
- }
-
- @override
- String searchEmptyTitle(String query) {
- return '找不到「$query」';
- }
-
- @override
- String get searchEmptyBody => '搜尋範圍是複製過的文字和檔名。';
-
@override
String get historyEmptyBody => '在任何一台已配對的裝置上複製文字、圖片或檔案,記錄會出現在這裡。';
@@ -1878,6 +1957,25 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
return '$name 等 $count 項';
}
+ @override
+ String get searchHint => '搜尋文字和檔名';
+
+ @override
+ String get searchClear => '清除搜尋';
+
+ @override
+ String searchResultCount(int count) {
+ return '找到 $count 筆';
+ }
+
+ @override
+ String searchEmptyTitle(String query) {
+ return '找不到「$query」';
+ }
+
+ @override
+ String get searchEmptyBody => '搜尋範圍是複製過的文字和檔名。';
+
@override
String get imagePreviewTitle => '圖片預覽';
@@ -2338,6 +2436,55 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
@override
String get deviceNameUpdated => '裝置名稱已更新';
+ @override
+ String get diagIntro =>
+ '報告裡有版本、系統、設定、裝置狀態和最近的記錄檔。裝置名稱、伺服器位址、公用 IP、使用者資料夾和檔名都已替換,複製的內容從不寫進記錄檔。GitHub 上的問題是公開的,貼出去之前請看一遍。';
+
+ @override
+ String get diagVerboseTitle => '詳細記錄檔';
+
+ @override
+ String get diagVerboseDesc => '連線方面的問題常要看它:開啟後重現一次問題,再回來產生報告。30 分鐘後自動關閉。';
+
+ @override
+ String get diagVerboseOn => '開啟 30 分鐘';
+
+ @override
+ String diagVerboseUntil(String time) {
+ return '已開啟,$time 自動關閉';
+ }
+
+ @override
+ String get diagVerboseOff => '關閉';
+
+ @override
+ String get diagRefresh => '重新產生';
+
+ @override
+ String get diagSave => '儲存為檔案';
+
+ @override
+ String diagSaved(String name) {
+ return '已儲存到「下載」資料夾:$name';
+ }
+
+ @override
+ String get diagCopy => '複製報告';
+
+ @override
+ String get diagCopied => '報告已複製';
+
+ @override
+ String get diagNewIssue => '在 GitHub 上回報';
+
+ @override
+ String get diagIssueHint => '報告已複製,貼到問題裡的「診斷報告」一欄';
+
+ @override
+ String diagFailed(String detail) {
+ return '產生報告失敗:$detail';
+ }
+
@override
String get svcExtractTitle => '先解壓縮或安裝 CopySync';
diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arb
index d8c3f9b..57815b3 100644
--- a/ui/lib/l10n/app_zh.arb
+++ b/ui/lib/l10n/app_zh.arb
@@ -219,6 +219,20 @@
"urlMustBeWs": "地址需以 ws:// 或 wss:// 开头",
"serverUpdated": "服务器地址已更新,正在重连",
"deviceNameUpdated": "设备名称已更新",
+ "diagIntro": "报告里有版本、系统、设置、设备状态和最近的日志。设备名、服务器地址、公网 IP、用户目录和文件名都已替换,复制的内容从不写进日志。GitHub 上的问题是公开的,贴出去之前请看一遍。",
+ "diagVerboseTitle": "详细日志",
+ "diagVerboseDesc": "连接方面的问题常要看它:打开后重现一次问题,再回来生成报告。30 分钟后自动关闭。",
+ "diagVerboseOn": "打开 30 分钟",
+ "diagVerboseUntil": "已打开,{time} 自动关闭",
+ "diagVerboseOff": "关闭",
+ "diagRefresh": "重新生成",
+ "diagSave": "保存为文件",
+ "diagSaved": "已保存到「下载」文件夹:{name}",
+ "diagCopy": "拷贝报告",
+ "diagCopied": "报告已拷贝",
+ "diagNewIssue": "在 GitHub 上提问题",
+ "diagIssueHint": "报告已拷贝,粘贴到问题里的「诊断报告」一栏",
+ "diagFailed": "生成报告失败:{detail}",
"svcExtractTitle": "先解压或安装 CopySync",
"svcExtractBody": "CopySync 现在是直接从压缩包里打开的,关掉之后它所在的临时文件夹就会被删除。运行安装程序,或者把整个文件夹解压出来再打开,就可以启用后台同步。",
"svcMoveTitle": "先把 CopySync 移到「应用程序」",
diff --git a/ui/lib/l10n/app_zh_Hant_HK.arb b/ui/lib/l10n/app_zh_Hant_HK.arb
index 338ab25..d0a92d2 100644
--- a/ui/lib/l10n/app_zh_Hant_HK.arb
+++ b/ui/lib/l10n/app_zh_Hant_HK.arb
@@ -219,6 +219,20 @@
"urlMustBeWs": "地址必須以 ws:// 或 wss:// 開頭",
"serverUpdated": "伺服器地址已更新,正在重新連線",
"deviceNameUpdated": "裝置名稱已更新",
+ "diagIntro": "報告裏有版本、系統、設定、裝置狀態和最近的日誌。裝置名稱、伺服器地址、公網 IP、用戶資料夾和檔案名稱都已替換,複製的內容從不寫進日誌。GitHub 上的問題是公開的,貼出去之前請看一遍。",
+ "diagVerboseTitle": "詳細日誌",
+ "diagVerboseDesc": "連線方面的問題常要看它:開啟後重現一次問題,再回來產生報告。30 分鐘後自動關閉。",
+ "diagVerboseOn": "開啟 30 分鐘",
+ "diagVerboseUntil": "已開啟,{time} 自動關閉",
+ "diagVerboseOff": "關閉",
+ "diagRefresh": "重新產生",
+ "diagSave": "儲存為檔案",
+ "diagSaved": "已儲存到「下載」資料夾:{name}",
+ "diagCopy": "拷貝報告",
+ "diagCopied": "報告已拷貝",
+ "diagNewIssue": "在 GitHub 上回報",
+ "diagIssueHint": "報告已拷貝,貼到問題裏的「診斷報告」一欄",
+ "diagFailed": "產生報告失敗:{detail}",
"svcExtractTitle": "先解壓縮或安裝 CopySync",
"svcExtractBody": "CopySync 現在是直接從壓縮檔裏開啟的,關閉之後它所在的臨時資料夾就會被刪除。執行安裝程式,或者把整個資料夾解壓縮出來再開啟,就可以啟用背景同步。",
"svcMoveTitle": "先把 CopySync 移到「應用程式」",
diff --git a/ui/lib/l10n/app_zh_Hant_TW.arb b/ui/lib/l10n/app_zh_Hant_TW.arb
index a64259f..d1d4fa7 100644
--- a/ui/lib/l10n/app_zh_Hant_TW.arb
+++ b/ui/lib/l10n/app_zh_Hant_TW.arb
@@ -219,6 +219,20 @@
"urlMustBeWs": "位址必須以 ws:// 或 wss:// 開頭",
"serverUpdated": "伺服器位址已更新,正在重新連線",
"deviceNameUpdated": "裝置名稱已更新",
+ "diagIntro": "報告裡有版本、系統、設定、裝置狀態和最近的記錄檔。裝置名稱、伺服器位址、公用 IP、使用者資料夾和檔名都已替換,複製的內容從不寫進記錄檔。GitHub 上的問題是公開的,貼出去之前請看一遍。",
+ "diagVerboseTitle": "詳細記錄檔",
+ "diagVerboseDesc": "連線方面的問題常要看它:開啟後重現一次問題,再回來產生報告。30 分鐘後自動關閉。",
+ "diagVerboseOn": "開啟 30 分鐘",
+ "diagVerboseUntil": "已開啟,{time} 自動關閉",
+ "diagVerboseOff": "關閉",
+ "diagRefresh": "重新產生",
+ "diagSave": "儲存為檔案",
+ "diagSaved": "已儲存到「下載」資料夾:{name}",
+ "diagCopy": "複製報告",
+ "diagCopied": "報告已複製",
+ "diagNewIssue": "在 GitHub 上回報",
+ "diagIssueHint": "報告已複製,貼到問題裡的「診斷報告」一欄",
+ "diagFailed": "產生報告失敗:{detail}",
"svcExtractTitle": "先解壓縮或安裝 CopySync",
"svcExtractBody": "CopySync 現在是直接從壓縮檔裡打開的,關掉之後它所在的暫存資料夾就會被刪除。執行安裝程式,或者把整個資料夾解壓縮出來再打開,就可以啟用背景同步。",
"svcMoveTitle": "先把 CopySync 移到「應用程式」",
diff --git a/ui/lib/pages/settings_page.dart b/ui/lib/pages/settings_page.dart
index c32776d..e62bf2a 100644
--- a/ui/lib/pages/settings_page.dart
+++ b/ui/lib/pages/settings_page.dart
@@ -10,6 +10,7 @@ import '../i18n.dart';
import '../main.dart';
import '../theme.dart';
import '../widgets/common.dart';
+import '../widgets/feedback_dialog.dart';
import '../icons.dart';
import '../platform.dart';
@@ -306,7 +307,7 @@ class _SettingsPageState extends State<SettingsPage> {
child: Text(l.homepage),
),
TextButton(
- onPressed: () => _open('https://github.com/baiyuze/copysync/issues'),
+ onPressed: () => showFeedbackDialog(context),
child: Text(l.feedback),
),
],
diff --git a/ui/lib/platform.dart b/ui/lib/platform.dart
index 8cf5e78..8f58dba 100644
--- a/ui/lib/platform.dart
+++ b/ui/lib/platform.dart
@@ -27,3 +27,33 @@ void openUrl(String url) {
Process.run('open', [url]);
}
}
+
+/// 用户的「下载」文件夹。Linux 上这个文件夹按系统语言命名(比如「下载」),以 XDG 的设置为准。
+String downloadsDir() {
+ final env = Platform.environment;
+ if (Platform.isWindows) return '${env['USERPROFILE']}\\Downloads';
+ final home = env['HOME'] ?? '';
+ if (Platform.isLinux) {
+ final config = env['XDG_CONFIG_HOME'] ?? '$home/.config';
+ try {
+ for (final line in File('$config/user-dirs.dirs').readAsLinesSync()) {
+ final m = RegExp(r'^XDG_DOWNLOAD_DIR="(.+)"$').firstMatch(line.trim());
+ if (m != null) return m.group(1)!.replaceFirst(r'$HOME', home);
+ }
+ } on FileSystemException {
+ // 没有这个文件就用默认的
+ }
+ }
+ return '$home/Downloads';
+}
+
+/// 在访达、资源管理器或文件管理器里显示这个文件。Linux 上的文件管理器各不相同,打开它所在的文件夹。
+void revealFile(String path) {
+ if (Platform.isWindows) {
+ Process.run('explorer.exe', ['/select,', path]);
+ } else if (Platform.isLinux) {
+ Process.run('xdg-open', [File(path).parent.path]);
+ } else {
+ Process.run('open', ['-R', path]);
+ }
+}
diff --git a/ui/lib/widgets/feedback_dialog.dart b/ui/lib/widgets/feedback_dialog.dart
new file mode 100644
index 0000000..d73bae9
--- /dev/null
+++ b/ui/lib/widgets/feedback_dialog.dart
@@ -0,0 +1,228 @@
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+import '../app_state.dart';
+import '../background_service.dart' show appVersion;
+import '../i18n.dart';
+import '../icons.dart';
+import '../main.dart';
+import '../platform.dart';
+import '../theme.dart';
+import 'common.dart';
+
+/// 新建 issue 的地址:用仓库里的问题模板(.github/ISSUE_TEMPLATE/bug_report.yml),版本号预先填好
+const _newIssue = 'https://github.com/baiyuze/copysync/issues/new?template=bug_report.yml';
+
+Future<void> showFeedbackDialog(BuildContext context) =>
+ showDialog<void>(context: context, builder: (_) => const FeedbackDialog());
+
+/// 反馈问题:先在本机生成诊断报告给用户看,用户自己拷贝或保存,再贴进 GitHub 的 issue。
+/// 不替用户上传任何东西:issue 是公开的,贴出去什么由用户看过之后决定。
+class FeedbackDialog extends StatefulWidget {
+ const FeedbackDialog({super.key});
+
+ @override
+ State<FeedbackDialog> createState() => _FeedbackDialogState();
+}
+
+class _FeedbackDialogState extends State<FeedbackDialog> {
+ String? _report;
+ String? _error;
+
+ @override
+ void initState() {
+ super.initState();
+ _load();
+ }
+
+ Future<void> _load() async {
+ setState(() {
+ _report = null;
+ _error = null;
+ });
+ try {
+ final report = await AppScope.read(context).exportDiagnostics();
+ if (mounted) setState(() => _report = report);
+ } catch (e) {
+ if (mounted) setState(() => _error = AppState.describeError(e));
+ }
+ }
+
+ Future<void> _setVerbose(int minutes) async {
+ try {
+ await AppScope.read(context).setVerboseLog(minutes);
+ await _load(); // 报告里有一行写着详细日志开没开
+ } catch (e) {
+ if (mounted) showToast(context, AppState.describeError(e), error: true);
+ }
+ }
+
+ Future<void> _copy() async {
+ await Clipboard.setData(ClipboardData(text: _report!));
+ if (mounted) showToast(context, context.l10n.diagCopied);
+ }
+
+ /// 保存的文件可以作为附件拖进 issue,所以多带些日志:粘贴的报告要塞进 issue 正文,有长度限制
+ Future<void> _save() async {
+ final l = context.l10n;
+ try {
+ final report = await AppScope.read(context).exportDiagnostics(logLines: 1000);
+ final now = DateTime.now();
+ String two(int n) => n.toString().padLeft(2, '0');
+ final name = 'CopySync-diagnostics-${now.year}${two(now.month)}${two(now.day)}'
+ '-${two(now.hour)}${two(now.minute)}.txt';
+ final file = File('${downloadsDir()}${Platform.pathSeparator}$name');
+ await file.parent.create(recursive: true);
+ await file.writeAsString(report);
+ revealFile(file.path);
+ if (mounted) showToast(context, l.diagSaved(name));
+ } catch (e) {
+ if (mounted) showToast(context, AppState.describeError(e), error: true);
+ }
+ }
+
+ /// 先把报告拷贝好,打开新建 issue 的页面后直接粘贴。报告生成失败时也照样打开,只是没有报告可贴
+ Future<void> _openIssue() async {
+ final l = context.l10n;
+ if (_report != null) await Clipboard.setData(ClipboardData(text: _report!));
+ openUrl('$_newIssue&version=${Uri.encodeQueryComponent(appVersion)}');
+ if (mounted && _report != null) showToast(context, l.diagIssueHint);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final l = context.l10n;
+ final p = context.palette;
+ final state = AppScope.of(context);
+ final until = state.verboseLogUntil;
+ final verbose = until != null && until.isAfter(DateTime.now());
+ String two(int n) => n.toString().padLeft(2, '0');
+
+ return Dialog(
+ child: SizedBox(
+ width: 600,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.lg, Insets.md, 0),
+ child: Row(
+ children: [
+ Expanded(child: Text(l.feedback, style: context.text.titleMedium)),
+ IconAction(icon: AppIcons.xmark, tooltip: l.close, onTap: () => Navigator.pop(context)),
+ ],
+ ),
+ ),
+ // 标题与按钮固定,中间的说明、报告、详细日志在窗口矮的时候可以滚动
+ Flexible(
+ child: SingleChildScrollView(
+ padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.md, Insets.xl, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Icon(AppIcons.lockShield, size: 15, color: p.textDim),
+ const SizedBox(width: Insets.sm),
+ Expanded(child: Text(l.diagIntro, style: context.text.bodySmall)),
+ ],
+ ),
+ const SizedBox(height: Insets.md),
+ Container(
+ height: 220,
+ decoration: BoxDecoration(
+ color: p.fill,
+ borderRadius: BorderRadius.circular(Radii.sm),
+ ),
+ child: Stack(
+ children: [
+ Positioned.fill(child: _reportView(context)),
+ Positioned(
+ top: 4,
+ right: 4,
+ child: IconAction(icon: AppIcons.arrowClockwise, tooltip: l.diagRefresh, onTap: _load),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: Insets.lg),
+ Row(
+ children: [
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(l.diagVerboseTitle, style: context.text.labelLarge),
+ const SizedBox(height: 2),
+ Text(l.diagVerboseDesc, style: context.text.bodySmall),
+ ],
+ ),
+ ),
+ const SizedBox(width: Insets.lg),
+ if (verbose) ...[
+ Text(l.diagVerboseUntil('${two(until.hour)}:${two(until.minute)}'),
+ style: context.text.bodySmall),
+ TextButton(onPressed: () => _setVerbose(0), child: Text(l.diagVerboseOff)),
+ ] else
+ OutlinedButton(onPressed: () => _setVerbose(30), child: Text(l.diagVerboseOn)),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.all(Insets.xl),
+ // 与系统对话框一样靠右排,主按钮在最右;放不下时折到下一行
+ child: Wrap(
+ alignment: WrapAlignment.end,
+ spacing: Insets.sm,
+ runSpacing: Insets.sm,
+ children: [
+ OutlinedButton(onPressed: _report == null ? null : _save, child: Text(l.diagSave)),
+ OutlinedButton(onPressed: _report == null ? null : _copy, child: Text(l.diagCopy)),
+ FilledButton(onPressed: _openIssue, child: Text(l.diagNewIssue)),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _reportView(BuildContext context) {
+ final l = context.l10n;
+ if (_error != null) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.all(Insets.lg),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(l.diagFailed(_error!),
+ textAlign: TextAlign.center, style: context.text.bodySmall?.copyWith(color: context.palette.danger)),
+ TextButton(onPressed: _load, child: Text(l.retry)),
+ ],
+ ),
+ ),
+ );
+ }
+ if (_report == null) {
+ return const Center(child: SizedBox(width: 16, height: 16, child: CircularProgressIndicator(strokeWidth: 2)));
+ }
+ return Scrollbar(
+ child: SingleChildScrollView(
+ padding: const EdgeInsets.fromLTRB(Insets.md, Insets.sm, 36, Insets.sm),
+ child: SelectableText(
+ _report!,
+ style: context.text.bodySmall?.copyWith(fontFamily: monoFamily, fontSize: 11, height: 1.45, color: context.palette.text),
+ ),
+ ),
+ );
+ }
+}
diff --git a/ui/test/feedback_dialog_test.dart b/ui/test/feedback_dialog_test.dart
new file mode 100644
index 0000000..adf0cde
--- /dev/null
+++ b/ui/test/feedback_dialog_test.dart
@@ -0,0 +1,99 @@
+import 'package:fixnum/fixnum.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import 'package:copysync_ui/app_state.dart';
+import 'package:copysync_ui/gen/copysync/v1/daemon.pb.dart';
+import 'package:copysync_ui/main.dart';
+import 'package:copysync_ui/widgets/feedback_dialog.dart';
+
+/// 不连后台服务:报告与详细日志的开关都由测试给出。
+/// 「在 GitHub 上提问题」与「保存为文件」不在测试里按:一个会打开浏览器,一个会写进真的「下载」文件夹。
+class _FeedbackState extends AppState {
+ int exports = 0;
+ final verboseCalls = <int>[];
+ Object? failWith;
+
+ @override
+ Future<String> exportDiagnostics({int logLines = 200}) async {
+ exports++;
+ if (failWith != null) throw failWith!;
+ return 'CopySync diagnostics report\n Background service 1.7.0\n#$exports';
+ }
+
+ @override
+ Future<void> setVerboseLog(int minutes) async {
+ verboseCalls.add(minutes);
+ final until = minutes == 0 ? 0 : DateTime(2030, 1, 1, 21, 20).millisecondsSinceEpoch ~/ 1000;
+ debugSeed(status: status!..verboseLogUntilUnix = Int64(until), config: config!, self: self!);
+ }
+}
+
+_FeedbackState _seed() => _FeedbackState()
+ ..debugSeed(
+ status: Status(signalingConnected: true, version: '1.7.0'),
+ config: Config(language: 'en'),
+ self: Device(id: 'self', name: 'MacBook Pro'),
+ );
+
+/// 常见的窗口大小。最小窗口下有没有挤坏,由 i18n_test 里逐个语言检查
+Future<void> _open(WidgetTester tester, AppState state) async {
+ tester.view.physicalSize = const Size(1100, 800);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(CopySyncApp(state: state));
+ showFeedbackDialog(tester.element(find.byType(Shell)));
+ await tester.pumpAndSettle();
+}
+
+void main() {
+ testWidgets('打开时生成报告给用户看,拷贝的就是看到的这份', (tester) async {
+ String? copied;
+ tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (call) async {
+ if (call.method == 'Clipboard.setData') copied = (call.arguments as Map)['text'] as String;
+ return null;
+ });
+ addTearDown(() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null));
+
+ final state = _seed();
+ await _open(tester, state);
+ expect(find.textContaining('CopySync diagnostics report'), findsOneWidget);
+
+ await tester.tap(find.text('Copy report'));
+ await tester.pumpAndSettle();
+ expect(copied, contains('Background service 1.7.0'));
+ expect(find.text('Report copied'), findsOneWidget);
+ });
+
+ testWidgets('打开详细日志后显示到几点,并重新生成报告;可以提前关掉', (tester) async {
+ final state = _seed();
+ await _open(tester, state);
+ expect(state.exports, 1);
+
+ await tester.tap(find.text('Turn on for 30 minutes'));
+ await tester.pumpAndSettle();
+ expect(state.verboseCalls, [30]);
+ expect(find.text('On until 21:20'), findsOneWidget);
+ expect(state.exports, 2);
+ expect(find.textContaining('#2'), findsOneWidget);
+
+ await tester.tap(find.text('Turn off'));
+ await tester.pumpAndSettle();
+ expect(state.verboseCalls, [30, 0]);
+ expect(find.text('Turn on for 30 minutes'), findsOneWidget);
+ });
+
+ testWidgets('生成失败时说明原因,可以重试;拷贝与保存先不能按', (tester) async {
+ final state = _seed()..failWith = Exception('daemon gone');
+ await _open(tester, state);
+ expect(find.textContaining("Couldn't create the report"), findsOneWidget);
+ expect(tester.widget<OutlinedButton>(find.widgetWithText(OutlinedButton, 'Copy report')).onPressed, isNull);
+ expect(tester.widget<OutlinedButton>(find.widgetWithText(OutlinedButton, 'Save as file')).onPressed, isNull);
+
+ state.failWith = null;
+ await tester.tap(find.text('Try again'));
+ await tester.pumpAndSettle();
+ expect(find.textContaining('CopySync diagnostics report'), findsOneWidget);
+ });
+}
diff --git a/ui/test/i18n_test.dart b/ui/test/i18n_test.dart
index 8a8b1c7..4804d06 100644
--- a/ui/test/i18n_test.dart
+++ b/ui/test/i18n_test.dart
@@ -7,11 +7,16 @@ import 'package:copysync_ui/background_service.dart';
import 'package:copysync_ui/gen/copysync/v1/daemon.pb.dart';
import 'package:copysync_ui/i18n.dart';
import 'package:copysync_ui/main.dart';
+import 'package:copysync_ui/widgets/feedback_dialog.dart';
import 'package:copysync_ui/widgets/pairing_dialog.dart';
class _DemoState extends AppState {
@override
Future<PairingCode> createPairingCode() async => (code: 'K7MP2X', addresses: ['192.168.1.20']);
+
+ @override
+ Future<String> exportDiagnostics({int logLines = 200}) async =>
+ 'CopySync diagnostics report\n${List.filled(40, 'time=2026-10-13T20:41:02 level=INFO msg=信令已连接').join('\n')}';
}
AppState _demo(String language, {LinkState link = LinkState.online, ServiceState? service}) =>
@@ -178,6 +183,13 @@ void main() {
expect(find.text(l.confirmMatch), findsOneWidget);
});
+ testWidgets('反馈问题', (tester) async {
+ final l = await open(tester, _demo(language));
+ showFeedbackDialog(tester.element(find.byType(Shell)));
+ await tester.pumpAndSettle();
+ expect(find.text(l.diagNewIssue), findsOneWidget);
+ });
+
testWidgets('启用后台服务的引导页', (tester) async {
final l = await open(tester, _demo(language, link: LinkState.offline, service: ServiceState.notInstalled));
expect(find.text(l.svcEnable), findsOneWidget);
diff --git a/ui/tool/l10n/strings.py b/ui/tool/l10n/strings.py
index 25c9279..1a0f7da 100644
--- a/ui/tool/l10n/strings.py
+++ b/ui/tool/l10n/strings.py
@@ -256,6 +256,22 @@ S = [
("serverUpdated", "Server updated. Reconnecting…", "服务器地址已更新,正在重连", "サーバーを更新しました。再接続しています…", "伺服器位址已更新,正在重新連線", "伺服器地址已更新,正在重新連線"),
("deviceNameUpdated", "Device name updated", "设备名称已更新", "デバイス名を更新しました", "裝置名稱已更新", "裝置名稱已更新"),
+ # ── 反馈问题:诊断报告 ──
+ ("diagIntro", "This report has the app version, your system, settings, devices and recent logs. Device names, the server address, public IP addresses, your user folder and file names are replaced, and what you copy is never written to the logs. Issues on GitHub are public, so read it through before posting.", "报告里有版本、系统、设置、设备状态和最近的日志。设备名、服务器地址、公网 IP、用户目录和文件名都已替换,复制的内容从不写进日志。GitHub 上的问题是公开的,贴出去之前请看一遍。", "このレポートには、バージョン、システム、設定、デバイスの状態、最近のログが含まれます。デバイス名、サーバーのアドレス、グローバル IP アドレス、ユーザーフォルダ、ファイル名は置き換え済みで、コピーした内容はログに書かれません。GitHub の Issue は公開されるので、投稿する前に目を通してください。", "報告裡有版本、系統、設定、裝置狀態和最近的記錄檔。裝置名稱、伺服器位址、公用 IP、使用者資料夾和檔名都已替換,複製的內容從不寫進記錄檔。GitHub 上的問題是公開的,貼出去之前請看一遍。", "報告裏有版本、系統、設定、裝置狀態和最近的日誌。裝置名稱、伺服器地址、公網 IP、用戶資料夾和檔案名稱都已替換,複製的內容從不寫進日誌。GitHub 上的問題是公開的,貼出去之前請看一遍。"),
+ ("diagVerboseTitle", "Detailed logging", "详细日志", "詳細ログ", "詳細記錄檔", "詳細日誌"),
+ ("diagVerboseDesc", "For connection problems: turn it on, make the problem happen again, then come back for the report. It turns itself off after 30 minutes.", "连接方面的问题常要看它:打开后重现一次问题,再回来生成报告。30 分钟后自动关闭。", "接続の問題を調べるときに使います。オンにして問題をもう一度起こしてから、ここでレポートを作り直してください。30 分後に自動でオフになります。", "連線方面的問題常要看它:開啟後重現一次問題,再回來產生報告。30 分鐘後自動關閉。", "連線方面的問題常要看它:開啟後重現一次問題,再回來產生報告。30 分鐘後自動關閉。"),
+ ("diagVerboseOn", "Turn on for 30 minutes", "打开 30 分钟", "30 分間オンにする", "開啟 30 分鐘", "開啟 30 分鐘"),
+ ("diagVerboseUntil", "On until {time}", "已打开,{time} 自动关闭", "{time} までオン", "已開啟,{time} 自動關閉", "已開啟,{time} 自動關閉"),
+ ("diagVerboseOff", "Turn off", "关闭", "オフにする", "關閉", "關閉"),
+ ("diagRefresh", "Regenerate", "重新生成", "作り直す", "重新產生", "重新產生"),
+ ("diagSave", "Save as file", "保存为文件", "ファイルに保存", "儲存為檔案", "儲存為檔案"),
+ ("diagSaved", "Saved to your Downloads folder: {name}", "已保存到「下载」文件夹:{name}", "「ダウンロード」フォルダに保存しました:{name}", "已儲存到「下載」資料夾:{name}", "已儲存到「下載」資料夾:{name}"),
+ ("diagCopy", "Copy report", "拷贝报告", "レポートをコピー", "複製報告", "拷貝報告"),
+ ("diagCopied", "Report copied", "报告已拷贝", "レポートをコピーしました", "報告已複製", "報告已拷貝"),
+ ("diagNewIssue", "New issue on GitHub", "在 GitHub 上提问题", "GitHub で Issue を作成", "在 GitHub 上回報", "在 GitHub 上回報"),
+ ("diagIssueHint", "Report copied. Paste it into the issue's “Diagnostics report” box.", "报告已拷贝,粘贴到问题里的「诊断报告」一栏", "レポートをコピーしました。Issue の「Diagnostics report」欄に貼り付けてください", "報告已複製,貼到問題裡的「診斷報告」一欄", "報告已拷貝,貼到問題裏的「診斷報告」一欄"),
+ ("diagFailed", "Couldn't create the report: {detail}", "生成报告失败:{detail}", "レポートを作成できませんでした:{detail}", "產生報告失敗:{detail}", "產生報告失敗:{detail}"),
+
# ── 启用后台服务的引导页 ──
("svcExtractTitle", "Install or extract CopySync first", "先解压或安装 CopySync", "先に CopySync をインストールまたは展開してください", "先解壓縮或安裝 CopySync", "先解壓縮或安裝 CopySync"),
("svcExtractBody", "CopySync is running straight from the zip, and its temporary folder disappears when you close it. Run the installer, or extract the whole folder and open it from there, to turn on background sync.", "CopySync 现在是直接从压缩包里打开的,关掉之后它所在的临时文件夹就会被删除。运行安装程序,或者把整个文件夹解压出来再打开,就可以启用后台同步。", "CopySync は zip から直接開かれていて、閉じると一時フォルダごと消えます。インストーラーを実行するか、フォルダ全体を展開してから開くと、バックグラウンド同期を有効にできます。", "CopySync 現在是直接從壓縮檔裡打開的,關掉之後它所在的暫存資料夾就會被刪除。執行安裝程式,或者把整個資料夾解壓縮出來再打開,就可以啟用背景同步。", "CopySync 現在是直接從壓縮檔裏開啟的,關閉之後它所在的臨時資料夾就會被刪除。執行安裝程式,或者把整個資料夾解壓縮出來再開啟,就可以啟用背景同步。"),
diff --git a/ui/tool/screenshots/screenshots_test.dart b/ui/tool/screenshots/screenshots_test.dart
index a30d5d1..58810d1 100644
--- a/ui/tool/screenshots/screenshots_test.dart
+++ b/ui/tool/screenshots/screenshots_test.dart
@@ -15,6 +15,7 @@ import 'package:copysync_ui/gen/copysync/v1/daemon.pb.dart';
import 'package:copysync_ui/i18n.dart';
import 'package:copysync_ui/main.dart';
import 'package:copysync_ui/theme.dart';
+import 'package:copysync_ui/widgets/feedback_dialog.dart';
import 'package:copysync_ui/widgets/nearby_dialog.dart';
import 'package:copysync_ui/widgets/pairing_dialog.dart';
import 'package:fixnum/fixnum.dart';
@@ -48,6 +49,9 @@ class _DemoState extends AppState {
Future<ListHistoryResponse> requestSearch(String query) async =>
ListHistoryResponse(records: records.where((r) => matchesSearch(r, query)), searched: true);
+ @override
+ Future<String> exportDiagnostics({int logLines = 200}) async => _sampleReport;
+
// 不关闭的流:后台服务那边的订阅一直开着,结束就表示后台服务断开了
@override
Stream<List<NearbyDevice>> watchNearby() => (StreamController<List<NearbyDevice>>()
@@ -209,6 +213,31 @@ AppState _demo({LinkState link = LinkState.online,
return state;
}
+/// 诊断报告的样子:后台服务生成,名字、服务器、公网 IP 都已换成占位符
+const _sampleReport = '''CopySync diagnostics report
+Names, server address, public IP addresses, the user folder and file names are replaced.
+
+ Generated 2026-10-13 20:50:11 +0800
+ Background service 1.7.0
+ App 1.7.0
+ System macOS 15.6 (darwin/arm64)
+
+Settings
+ Server ws://<server>:8787/signal
+ Find devices on LAN on
+ Public STUN servers on
+ Auto-sync limit 50 MB
+ History kept 3 days
+
+Devices
+ <this-device> darwin (this device)
+ <device-1> windows direct
+ <device-2> darwin relay
+
+Log (last 200 lines)
+time=2026-10-13T20:41:02.118+08:00 level=INFO msg=信令已连接 url=ws://<server>:8787/signal
+time=2026-10-13T20:41:02.530+08:00 level=INFO msg="P2P 连接状态" device=9f2c41 state=connected''';
+
final _boundary = GlobalKey();
Future<void> _shoot(
@@ -315,6 +344,12 @@ void main() {
});
});
+ testWidgets('feedback', (tester) async {
+ await _shoot(tester, 'feedback', state: _demo(), section: Section.settings, arrange: () async {
+ showFeedbackDialog(tester.element(find.byType(Shell)));
+ });
+ });
+
testWidgets('history-dark', (tester) async {
await _shoot(tester, 'history-dark',
state: _demo(), brightness: Brightness.dark, settle: false);