feat(daemon-beta t14/t15/t17): supervisor log 檔+removed 清本地卡+托盤建新資料夾
- t14 supervisor:子行程 stdout(tee)/stderr 全落 ~/.arcrun-rag/collector.log, >5MB 改名 .old 重開(兩代輪替);落 log 失敗一律吞掉不擋看守。新增 2 測試 (輸出進檔+輪替觸發)。 - t15 direct removed(extractor 模式):雲端 takedown 2xx 後同步刪本地 system-dev/wiki/cards/<頁名>.md(存在才刪;刪失敗只記 warning 不擋)。 新增 2 測試(刪原檔→本地卡被清/卡已不在照常下架)。 - t17 arcrun-tray:tray 選單+設定視窗加「建立新資料夾並看守…」—— widget.Entry 輸入名稱→ ~/ 底下 mkdir(已存在沿用;擋路徑分隔與 ..)→ addWatchFolder+saveConfig+重啟看守+rebuildTray。 collector: go vet ✓、go test -count=1 ./... 43/43 綠;arcrun-tray: go build ✓(產物已刪) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,10 +17,12 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
neturl "net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"arcrun-rag/collector/supervisor"
|
||||
|
||||
@@ -206,6 +208,51 @@ func main() {
|
||||
}, win)
|
||||
}
|
||||
|
||||
// t17:fyne 內建 folder picker 無法輸入名稱建新資料夾(leo 07-24 親測)——
|
||||
// 補一條「建立新資料夾並看守…」:文字輸入+確定 → 在 ~/ 底下 mkdir(已存在則沿用)→ 看守。
|
||||
newFolderAction := func() {
|
||||
win.Show()
|
||||
win.RequestFocus()
|
||||
entry := widget.NewEntry()
|
||||
entry.SetPlaceHolder("例如:我的知識庫")
|
||||
content := container.NewVBox(
|
||||
widget.NewLabel("輸入新資料夾名稱(會建立在你的家目錄底下):"),
|
||||
entry,
|
||||
)
|
||||
dialog.ShowCustomConfirm("建立新資料夾並看守", "確定", "取消", content, func(ok bool) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
name := strings.TrimSpace(entry.Text)
|
||||
if name == "" {
|
||||
return
|
||||
}
|
||||
// 只收「單層名稱」:擋路徑分隔與 ..(避免建到家目錄之外)
|
||||
if strings.ContainsAny(name, `/\`) || name == "." || name == ".." {
|
||||
dialog.ShowError(errors.New("名稱不能包含 / 或 \\,也不能是 . 或 .."), win)
|
||||
return
|
||||
}
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
dialog.ShowError(err, win)
|
||||
return
|
||||
}
|
||||
p := filepath.Join(home, name)
|
||||
if err := os.MkdirAll(p, 0o755); err != nil { // 已存在=直接沿用
|
||||
dialog.ShowError(err, win)
|
||||
return
|
||||
}
|
||||
addWatchFolder(cfg, p)
|
||||
if err := saveConfig(cfg); err != nil {
|
||||
dialog.ShowError(err, win)
|
||||
return
|
||||
}
|
||||
restartWatch()
|
||||
rebuildTray()
|
||||
win.Hide()
|
||||
}, win)
|
||||
}
|
||||
|
||||
var pauseItem *fyne.MenuItem
|
||||
pauseItem = fyne.NewMenuItem("暫停看守", func() {
|
||||
st := sup.Status()
|
||||
@@ -246,6 +293,7 @@ func main() {
|
||||
}
|
||||
items = append(items,
|
||||
fyne.NewMenuItem("+ 新增知識資料夾…", addAction),
|
||||
fyne.NewMenuItem("+ 建立新資料夾並看守…", newFolderAction), // t17
|
||||
fyne.NewMenuItemSeparator(),
|
||||
pauseItem,
|
||||
)
|
||||
@@ -274,6 +322,7 @@ func main() {
|
||||
widget.NewLabelWithStyle("Arcrun RAG 知識同步", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
|
||||
widget.NewLabel("把檔案丟進你選的資料夾,就會自動進你的知識庫。\n這個程式會待在選單列/系統匣,關掉視窗它仍在背景看守。"),
|
||||
widget.NewButton("新增知識資料夾…", func() { addAction() }),
|
||||
widget.NewButton("建立新資料夾並看守…", func() { newFolderAction() }), // t17
|
||||
))
|
||||
|
||||
// 開機即看守(若設定完整)
|
||||
|
||||
Reference in New Issue
Block a user