返回 DeepSeek-Reasonix
remote_history_strip_test.go
根目录 / desktop / remote_history_strip_test.go
1 package main
2
3 import (
4 "strings"
5 "testing"
6 )
7
8 // RemoteTabSnapshot sanitizes user rows even when an older remote Serve
9 // returns provider-only transient blocks in /history.
10 func TestRemoteTabSnapshotStripsTransientUserBlocks(t *testing.T) {
11 fs := newFakeServe(t, "s3cret", []serveSessionEntry{{Name: "s1", Path: "/remote/sessions/s1.jsonl", Current: true}})
12 fs.mu.Lock()
13 fs.historyBody = `[{"role":"user","content":"<reasoning-language>zh</reasoning-language>\n\nhello"},{"role":"assistant","content":"three <b>bold</b> stays"}]`
14 fs.mu.Unlock()
15 kernel := &fakeRemoteKernel{
16 statuses: []RemoteConnectionStatusView{{HostID: "box", State: "connected"}},
17 ensureView: RemoteServerView{HostID: "box", State: "ready", LocalURL: fs.server.URL}, ensureToken: "s3cret",
18 }
19 seedBridgeTestHost(t, "box")
20 a := &App{remoteRuntime: kernel}
21 cleanupRemoteTabPumps(t, a)
22 meta := openReadyRemoteTab(t, a, RemoteTabOpenOptions{SessionName: "s1", SessionPath: "/remote/sessions/s1.jsonl"})
23
24 snap, err := a.RemoteTabSnapshot(meta.ID)
25 if err != nil {
26 t.Fatal(err)
27 }
28 body := string(snap.History)
29 if strings.Contains(body, "<reasoning-language>") || !strings.Contains(body, "hello") {
30 t.Fatalf("history was not sanitized: %.200s", body)
31 }
32 if !strings.Contains(body, "three <b>bold</b> stays") {
33 t.Fatalf("assistant content changed: %.200s", body)
34 }
35 }
36
36 lines GO