Merge branch 'worktree-agent-abc9e7b0a4e0a0f54'

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 20:05:02 +00:00
49 changed files with 3067 additions and 133 deletions
+13 -3
View File
@@ -33,6 +33,9 @@ func newChatToolFixture(t *testing.T) *chatToolFixture {
f.hub.shown = store
f.service = newChatToolService(store, store, f.hub, store)
f.service.home = func() (string, error) { return f.home, nil }
f.service.snapshotRoot = func() (string, error) {
return filepath.Join(f.home, ".local", "share", "pipelines", "chat-shown"), nil
}
f.service.notify = func(_ context.Context, sessionID string, notice chatToolNotice) chatToolDelivery {
f.notified = append(f.notified, sessionID+": "+notice.Title)
return chatToolDelivery{App: true, Phone: true}
@@ -135,9 +138,12 @@ func TestShowFileStaysInsideHome(t *testing.T) {
}
realHome, _ := filepath.EvalSymlinks(f.home)
got := f.items(t, "ses_f")
if len(got) != 1 || got[0].Path != filepath.Join(realHome, "work", "report.md") || got[0].Name != "report.md" || got[0].Size != 9 || !strings.HasPrefix(got[0].Mime, "text/") {
if len(got) != 1 || got[0].Source != filepath.Join(realHome, "work", "report.md") || !got[0].Snapshot || got[0].Name != "report.md" || got[0].Size != 9 || !strings.HasPrefix(got[0].Mime, "text/") {
t.Fatalf("item = %+v", got)
}
if copied, err := os.ReadFile(got[0].Path); err != nil || string(copied) != "# Report\n" || !strings.HasPrefix(got[0].Path, f.home) {
t.Fatalf("the snapshot %s inside home holds the shown content: %q %v", got[0].Path, copied, err)
}
if r := f.call(token, "show_file", `{"path":"report.md"}`); r.IsError {
t.Fatalf("a relative path resolves against the chat's directory: %v", r)
}
@@ -167,7 +173,8 @@ func TestShowImageAcceptsHomeImagesAndHTTPSOnly(t *testing.T) {
if r := f.call(token, "show_image", `{"url_or_path":"`+image+`","alt":"A plot"}`); r.IsError {
t.Fatal(r.Text)
}
if r := f.call(token, "show_image", `{"url_or_path":"https://example.com/a.png","title":"Remote"}`); r.IsError {
web := f.imageServer(t)
if r := f.call(token, "show_image", `{"url_or_path":"`+web.URL+`/a.png","title":"Remote"}`); r.IsError {
t.Fatal(r.Text)
}
for _, refused := range []string{"http://example.com/a.png", "https://user:pw@example.com/a.png", "javascript:alert(1)", "file:///etc/passwd", filepath.Join(f.home, "notes.txt")} {
@@ -176,9 +183,12 @@ func TestShowImageAcceptsHomeImagesAndHTTPSOnly(t *testing.T) {
}
}
got := f.items(t, "ses_i")
if len(got) != 2 || got[0].Kind != protocol.ChatShownImage || got[0].Mime != "image/png" || got[0].Alt != "A plot" || got[1].URL != "https://example.com/a.png" || got[1].Path != "" {
if len(got) != 2 || got[0].Kind != protocol.ChatShownImage || got[0].Mime != "image/png" || got[0].Alt != "A plot" || got[1].URL != web.URL+"/a.png" || !got[1].Snapshot || got[1].Name != "a.png" || got[1].Mime != "image/png" {
t.Fatalf("items = %+v", got)
}
if data, err := os.ReadFile(got[1].Path); err != nil || string(data) != string(testPNG) {
t.Fatalf("the fetched image is kept as a snapshot: %v", err)
}
}
func TestShowHTMLSizeLimitAndRetention(t *testing.T) {