@@ -23,14 +23,7 @@ import { useTuiTerminalEnvironment } from "../../context/runtime"
2323import { Spinner , SPINNER_FRAMES } from "../../component/spinner"
2424import { PatchDiff } from "../../component/patch-diff"
2525import { useTheme , useThemes } from "../../context/theme"
26- import {
27- BoxRenderable ,
28- ScrollBoxRenderable ,
29- addDefaultParsers ,
30- TextAttributes ,
31- RGBA ,
32- MouseEvent ,
33- } from "@opentui/core"
26+ import { BoxRenderable , ScrollBoxRenderable , addDefaultParsers , TextAttributes , RGBA , MouseEvent } from "@opentui/core"
3427import { Prompt , type PromptRef } from "../../component/prompt"
3528import {
3629 mediaHashFromUri ,
@@ -693,13 +686,13 @@ export function Session(props: {
693686 const active = prompt ( )
694687 return Boolean (
695688 ! sessionDisposed &&
696- route . sessionID === event . data . sessionID &&
697- active &&
698- active . current . text === expectedText &&
699- ( active . current . files ?. length ?? 0 ) === expectedFiles &&
700- ( active . current . agents ?. length ?? 0 ) === expectedAgents &&
701- ( active . current . skills ?. length ?? 0 ) === expectedSkills &&
702- active . current . pasted . length === expectedPasted ,
689+ route . sessionID === event . data . sessionID &&
690+ active &&
691+ active . current . text === expectedText &&
692+ ( active . current . files ?. length ?? 0 ) === expectedFiles &&
693+ ( active . current . agents ?. length ?? 0 ) === expectedAgents &&
694+ ( active . current . skills ?. length ?? 0 ) === expectedSkills &&
695+ active . current . pasted . length === expectedPasted ,
703696 )
704697 }
705698 const canOpen = ( ) =>
@@ -779,10 +772,13 @@ export function Session(props: {
779772 ( await runPendingAction ( inboxID , ( ) => requestPending ( action , inboxID ) ) ) ?? false
780773 // The cancel releases blobs nothing else references, so media refs load into the draft first. Resolves with the
781774 // composer it wrote to, if any, once the prompt is back; undefined if the cancel failed or was already running.
782- const undoPending = ( inboxID : string , message : ProjectedPrompt , failureLabel ?: string ) =>
775+ const undoPending = ( inboxID : string , message : ProjectedPrompt ) =>
783776 runPendingAction ( inboxID , async ( ) => {
784777 const restored = await restorePrompt ( message )
785- if ( ! ( await requestPending ( "cancel" , inboxID , failureLabel ) ) ) return
778+ if ( ( await data . session . input . withdraw ( { sessionID, inboxID } ) ) === "delivered" ) {
779+ toast . show ( { message : "Prompt was already sent. Use /undo to take it back" , variant : "warning" } )
780+ return
781+ }
786782 return { composer : appendToSessionPrompt ( sessionID , restored , renderer . widthMethod ) }
787783 } )
788784 const openQueuedPrompts = ( ) =>
@@ -823,7 +819,7 @@ export function Session(props: {
823819 toast . show ( { message : "Leave shell mode before undoing a queued prompt" , variant : "error" } )
824820 return
825821 }
826- void undoPending ( queued . id , queued . payload , "undo" )
822+ void undoPending ( queued . id , queued . payload )
827823 . then ( ( undone ) => {
828824 if ( ! undone || sessionDisposed ) return
829825 dialog . clear ( )
@@ -1130,15 +1126,11 @@ export function Session(props: {
11301126 dialog . clear ( )
11311127 return
11321128 }
1133- const undo = pendingDeliveries ( ) . has ( message . id )
1134- ? undoPending ( message . id , message )
1135- : ( async ( ) => {
1136- const restored = await restorePrompt ( message )
1137- await client . api . session . interrupt ( { sessionID } )
1138- await client . api . experimental . session . wait ( { sessionID } )
1139- await client . api . session . revert . stage ( { sessionID, messageID : message . id } )
1140- appendToSessionPrompt ( sessionID , restored , renderer . widthMethod )
1141- } ) ( )
1129+ const undo = ( async ( ) => {
1130+ const restored = await restorePrompt ( message )
1131+ await data . session . undo ( { sessionID, messageID : message . id } )
1132+ appendToSessionPrompt ( sessionID , restored , renderer . widthMethod )
1133+ } ) ( )
11421134 void undo . catch ( ( error ) => toast . show ( { message : errorMessage ( error ) , variant : "error" , duration : 5000 } ) )
11431135 dialog . clear ( )
11441136 } ,
@@ -1278,7 +1270,9 @@ export function Session(props: {
12781270 } ,
12791271 run : ( ) => {
12801272 const lastAssistantMessage = messagesBeforeRevert ( ) . findLast (
1281- ( msg ) => msg . type === "assistant" || ( msg . type === "compaction" && msg . status === "completed" && msg . summary . trim ( ) !== "" ) ,
1273+ ( msg ) =>
1274+ msg . type === "assistant" ||
1275+ ( msg . type === "compaction" && msg . status === "completed" && msg . summary . trim ( ) !== "" ) ,
12821276 )
12831277 if ( ! lastAssistantMessage ) {
12841278 toast . show ( { message : "No assistant messages found" , variant : "error" } )
@@ -1582,9 +1576,7 @@ export function Session(props: {
15821576 onMouseOut = { ( ) => setLatestHovered ( false ) }
15831577 onMouseUp = { toBottom }
15841578 >
1585- < text
1586- fg = { latestHovered ( ) ? theme . text . action . secondary . hovered : theme . text . action . secondary . base }
1587- >
1579+ < text fg = { latestHovered ( ) ? theme . text . action . secondary . hovered : theme . text . action . secondary . base } >
15881580 Jump to latest ↓
15891581 </ text >
15901582 </ box >
@@ -1630,12 +1622,7 @@ export function Session(props: {
16301622 } }
16311623 </ Show >
16321624 </ Match >
1633- < Match
1634- when = {
1635- session ( ) &&
1636- currentLocation . error ?. location . directory === session ( ) ! . location . directory
1637- }
1638- >
1625+ < Match when = { session ( ) && currentLocation . error ?. location . directory === session ( ) ! . location . directory } >
16391626 < SessionLocationMissing
16401627 directory = { session ( ) ! . location . directory }
16411628 projectID = { session ( ) ! . projectID }
@@ -2929,9 +2916,7 @@ function BlockTool(props: BlockToolProps) {
29292916 < Show
29302917 when = { props . spinner }
29312918 fallback = {
2932- < text
2933- fg = { permission ( ) ? theme . text . feedback . warning . base : ( props . headerColor ?? theme . text . muted ) }
2934- >
2919+ < text fg = { permission ( ) ? theme . text . feedback . warning . base : ( props . headerColor ?? theme . text . muted ) } >
29352920 { title ( ) }
29362921 </ text >
29372922 }
@@ -3119,11 +3104,7 @@ function ShellDisplay(props: {
31193104 < Show
31203105 when = { isRunning ( ) }
31213106 fallback = {
3122- < text
3123- fg = { theme . text . base }
3124- wrapMode = { expanded ( ) ? "word" : "char" }
3125- maxHeight = { expanded ( ) ? undefined : 2 }
3126- >
3107+ < text fg = { theme . text . base } wrapMode = { expanded ( ) ? "word" : "char" } maxHeight = { expanded ( ) ? undefined : 2 } >
31273108 { limitedInput ( ) }
31283109 </ text >
31293110 }
@@ -3224,7 +3205,9 @@ function Read(props: ToolProps) {
32243205 Read { pathFormatter . format ( stringValue ( props . input . path ) ) }
32253206 < Show when = { props . input . offset !== undefined || props . input . limit !== undefined } >
32263207 :{ finiteNumber ( props . input . offset ) || 1 } -
3227- { props . input . limit ? ( finiteNumber ( props . input . offset ) || 1 ) + ( finiteNumber ( props . input . limit ) || 0 ) - 1 : "" }
3208+ { props . input . limit
3209+ ? ( finiteNumber ( props . input . offset ) || 1 ) + ( finiteNumber ( props . input . limit ) || 0 ) - 1
3210+ : "" }
32283211 </ Show >
32293212 </ InlineTool >
32303213 < For each = { loaded ( ) } >
0 commit comments