惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
M
MIT News - Artificial intelligence
D
Docker
量子位
T
Tailwind CSS Blog
人人都是产品经理
人人都是产品经理
月光博客
月光博客
有赞技术团队
有赞技术团队
J
Java Code Geeks
A
About on SuperTechFans
P
Proofpoint News Feed
Jina AI
Jina AI
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
V
V2EX
GbyAI
GbyAI
F
Fortinet All Blogs

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(slack): backfill fresh dm history · openclaw/openclaw...
steipete · 2026-05-02 · via Recent Commits to openclaw:main

@@ -776,6 +776,118 @@ describe("slack prepareSlackMessage inbound contract", () => {

776776

expect(replies).toHaveBeenCalledTimes(2);

777777

});

778778779+

it("injects Slack DM history for new top-level DM sessions", async () => {

780+

const { storePath } = storeFixture.makeTmpStorePath();

781+

const history = vi.fn().mockResolvedValue({

782+

messages: [

783+

{ text: "current answer", user: "U1", ts: "300.000" },

784+

{ text: "please choose A or B", bot_id: "B1", ts: "299.000" },

785+

{ text: "earlier user context", user: "U1", ts: "298.000" },

786+

],

787+

});

788+

const slackCtx = createInboundSlackCtx({

789+

cfg: {

790+

session: { store: storePath },

791+

channels: { slack: { enabled: true, dmHistoryLimit: 2 } },

792+

} as OpenClawConfig,

793+

appClient: { conversations: { history } } as unknown as App["client"],

794+

dmHistoryLimit: 2,

795+

});

796+

slackCtx.resolveUserName = async (id: string) => ({ name: id === "U1" ? "Alice" : id });

797+798+

const prepared = await prepareMessageWith(

799+

slackCtx,

800+

createSlackAccount({ dmHistoryLimit: 2 }),

801+

createSlackMessage({ text: "current answer", ts: "300.000" }),

802+

);

803+804+

expect(prepared).toBeTruthy();

805+

expect(history).toHaveBeenCalledWith({

806+

token: "token",

807+

channel: "D123",

808+

latest: "300.000",

809+

inclusive: true,

810+

limit: 3,

811+

});

812+

expect(prepared!.ctxPayload.Body).toContain("earlier user context");

813+

expect(prepared!.ctxPayload.Body).toContain("please choose A or B");

814+

expect(

815+

Array.from(

816+

(prepared!.ctxPayload.Body ?? "").matchAll(/\[slack message id: 300\.000 channel: D123\]/g),

817+

),

818+

).toHaveLength(1);

819+

expect(prepared!.ctxPayload.InboundHistory).toEqual([

820+

{

821+

sender: "Alice (user)",

822+

body: "earlier user context",

823+

timestamp: 298000,

824+

},

825+

{

826+

sender: "Assistant (assistant)",

827+

body: "please choose A or B",

828+

timestamp: 299000,

829+

},

830+

]);

831+

});

832+833+

it("uses per-DM Slack history limits and skips existing DM sessions", async () => {

834+

const { storePath } = storeFixture.makeTmpStorePath();

835+

const cfg = {

836+

session: { store: storePath },

837+

channels: {

838+

slack: {

839+

enabled: true,

840+

dmHistoryLimit: 4,

841+

dms: { U1: { historyLimit: 1 } },

842+

},

843+

},

844+

} as OpenClawConfig;

845+

const history = vi.fn().mockResolvedValue({

846+

messages: [

847+

{ text: "current", user: "U1", ts: "400.000" },

848+

{ text: "only one previous", user: "U1", ts: "399.000" },

849+

],

850+

});

851+

const slackCtx = createInboundSlackCtx({

852+

cfg,

853+

appClient: { conversations: { history } } as unknown as App["client"],

854+

dmHistoryLimit: 4,

855+

});

856+

slackCtx.resolveUserName = async () => ({ name: "Alice" });

857+858+

const account = createSlackAccount({

859+

dmHistoryLimit: 4,

860+

dms: { U1: { historyLimit: 1 } },

861+

});

862+

const prepared = await prepareMessageWith(

863+

slackCtx,

864+

account,

865+

createSlackMessage({ text: "current", ts: "400.000" }),

866+

);

867+868+

expect(prepared).toBeTruthy();

869+

expect(history).toHaveBeenCalledWith(

870+

expect.objectContaining({

871+

limit: 2,

872+

}),

873+

);

874+875+

history.mockClear();

876+

fs.writeFileSync(

877+

storePath,

878+

JSON.stringify({ [prepared!.ctxPayload.SessionKey!]: { updatedAt: Date.now() } }, null, 2),

879+

);

880+

const existing = await prepareMessageWith(

881+

slackCtx,

882+

account,

883+

createSlackMessage({ text: "next", ts: "401.000" }),

884+

);

885+886+

expect(existing).toBeTruthy();

887+

expect(history).not.toHaveBeenCalled();

888+

expect(existing!.ctxPayload.InboundHistory).toBeUndefined();

889+

});

890+779891

it("uses room users allowlist for thread context filtering", async () => {

780892

const { prepared, replies } = await prepareThreadContextAllowlistCase({

781893

channel: "C123",

@@ -1632,6 +1744,7 @@ describe("prepareSlackMessage sender prefix", () => {

16321744

teamId: "T1",

16331745

apiAppId: "A1",

16341746

historyLimit: 0,

1747+

dmHistoryLimit: 0,

16351748

channelHistories: new Map(),

16361749

sessionScope: "per-sender",

16371750

mainKey: "agent:main:main",