@@ -876,6 +876,7 @@ vi.mock("../../format.js", () => ({
876876
877877vi . mock ( "../../limits.js" , ( ) => ( {
878878 SLACK_TEXT_LIMIT : 4000 ,
879+ SLACK_EDIT_TEXT_MAX_BYTES : 4000 ,
879880} ) ) ;
880881
881882vi . mock ( "../../sent-thread-cache.js" , ( ) => ( {
@@ -2264,6 +2265,44 @@ describe("dispatchPreparedSlackMessage preview fallback", () => {
22642265 expect ( draftStream . clear ) . not . toHaveBeenCalled ( ) ;
22652266 } ) ;
22662267
2268+ it . each ( [
2269+ { description : "plain text" , finalText : "x" . repeat ( 4001 ) } ,
2270+ { description : "multibyte text" , finalText : "é" . repeat ( 2001 ) } ,
2271+ ] ) (
2272+ "delivers oversized $description intact through the normal chunked sender" ,
2273+ async ( { finalText } ) => {
2274+ const draftStream = createDraftStreamStub ( ) ;
2275+ createSlackDraftStreamMock . mockReturnValueOnce ( draftStream ) ;
2276+ mockedSlackStreamingMode = "progress" ;
2277+ mockedSlackDraftMode = "status_final" ;
2278+ mockedDispatchSequence = [ { kind : "final" , payload : { text : finalText } } ] ;
2279+ mockedReplyOptionEvents = [
2280+ {
2281+ kind : "item" ,
2282+ itemKind : "preamble" ,
2283+ itemId : "preamble-1" ,
2284+ progressText : "Checking the full answer before replying." ,
2285+ } ,
2286+ ] ;
2287+
2288+ await dispatchPreparedSlackMessage (
2289+ createPreparedSlackMessage ( {
2290+ accountConfig : {
2291+ streaming : {
2292+ mode : "progress" ,
2293+ progress : { label : false , commentary : true , toolProgress : false } ,
2294+ } ,
2295+ } ,
2296+ } ) ,
2297+ ) ;
2298+
2299+ expect ( finalizeSlackPreviewEditMock ) . not . toHaveBeenCalled ( ) ;
2300+ expect ( deliverRepliesMock ) . toHaveBeenCalledTimes ( 1 ) ;
2301+ expectDeliverReplyCall ( 0 , finalText ) ;
2302+ expect ( draftStream . clear ) . toHaveBeenCalledTimes ( 1 ) ;
2303+ } ,
2304+ ) ;
2305+
22672306 it ( "retains the progress draft when both the final edit and fallback send fail" , async ( ) => {
22682307 const draftStream = createDraftStreamStub ( ) ;
22692308 createSlackDraftStreamMock . mockReturnValueOnce ( draftStream ) ;
@@ -3744,7 +3783,39 @@ describe("dispatchPreparedSlackMessage preview fallback", () => {
37443783 ) ;
37453784
37463785 expect ( draftStream . update ) . toHaveBeenLastCalledWith (
3747- "_I’m using the `monorepo` skill on Linux x86_64._" ,
3786+ "_I’m using the `monorepo` skill on Linux x86\\_64._" ,
3787+ ) ;
3788+ } ) ;
3789+
3790+ it ( "escapes Slack mentions and formatting in commentary without losing outer italics or inline code" , async ( ) => {
3791+ const draftStream = createDraftStreamStub ( ) ;
3792+ createSlackDraftStreamMock . mockReturnValueOnce ( draftStream ) ;
3793+ mockedSlackStreamingMode = "progress" ;
3794+ mockedSlackDraftMode = "status_final" ;
3795+ mockedDispatchSequence = [ ] ;
3796+ mockedReplyOptionEvents = [
3797+ {
3798+ kind : "item" ,
3799+ itemKind : "preamble" ,
3800+ itemId : "preamble-1" ,
3801+ progressText :
3802+ "checking <@U123> in <#C123> and <!channel> with *urgent* _context_ `src/one.ts`" ,
3803+ } ,
3804+ ] ;
3805+
3806+ await dispatchPreparedSlackMessage (
3807+ createPreparedSlackMessage ( {
3808+ accountConfig : {
3809+ streaming : {
3810+ mode : "progress" ,
3811+ progress : { label : false , commentary : true , toolProgress : false } ,
3812+ } ,
3813+ } ,
3814+ } ) ,
3815+ ) ;
3816+
3817+ expect ( draftStream . update ) . toHaveBeenLastCalledWith (
3818+ "_checking <@U123> in <#C123> and <!channel> with \\*urgent\\* \\_context\\_ `src/one.ts`_" ,
37483819 ) ;
37493820 } ) ;
37503821
0 commit comments