@@ -77,7 +77,7 @@ import * as Model from "../../util/model"
7777import { formatTranscript } from "../../util/transcript"
7878import { sessionEpilogue } from "../../util/presentation"
7979import { setPreLayoutSiblingMargin } from "../../util/layout"
80- import { useTuiConfig } from "../../config"
80+ import { TuiConfig , useTuiConfig } from "../../config"
8181import { useClipboard } from "../../context/clipboard"
8282import { nextThinkingMode , reasoningSummary , useThinkingMode , type ThinkingMode } from "../../context/thinking"
8383import { getScrollAcceleration , keepScrollAnchor } from "../../util/scroll"
@@ -185,6 +185,7 @@ const context = createContext<{
185185 showTimestamps : ( ) => boolean
186186 showTurnTime : ( ) => boolean
187187 showTurnDuration : ( ) => boolean
188+ showPartTimestamp : ( type : "text" | "reasoning" | "tool" | "error" | "compaction" ) => boolean
188189 showDetails : ( ) => boolean
189190 showGenericToolOutput : ( ) => boolean
190191 diffWrapMode : ( ) => "word" | "none"
@@ -285,7 +286,6 @@ export function Session() {
285286 const thinking = useThinkingMode ( )
286287 const thinkingMode = thinking . mode
287288 const showThinking = createMemo ( ( ) => true )
288- const [ timestamps , setTimestamps ] = kv . signal < "hide" | "show" > ( "timestamps" , "hide" )
289289 const [ showDetails , setShowDetails ] = kv . signal ( "tool_details_visibility" , true )
290290 const [ showAssistantMetadata , _setShowAssistantMetadata ] = kv . signal ( "assistant_metadata_visibility" , true )
291291 const [ showScrollbar , setShowScrollbar ] = kv . signal ( "scrollbar_visible" , false )
@@ -300,14 +300,21 @@ export function Session() {
300300 if ( sidebar ( ) === "auto" && wide ( ) ) return true
301301 return false
302302 } )
303- const showTimestamps = createMemo ( ( ) => timestamps ( ) === "show" )
304303 // Read without kv.signal: its in-memory default would be persisted by the next
305304 // unrelated kv.set and then shadow later tui.json edits.
306305 const keepScrollOnSubmit = createMemo < boolean > ( ( ) =>
307306 kv . get ( "keep_scroll_on_submit" , tuiConfig . keep_scroll_on_submit ?? false ) ,
308307 )
309- // tui.json supplies the default; a palette toggle persists its own choice in kv.
310- const showTurnTime = createMemo ( ( ) => kv . get ( "turn_timing_time" , tuiConfig . turn_timing ?. time ?? false ) === true )
308+ // A tui.json `timestamps` list decides on every start and a toggle lasts until exit: kv.json usually
309+ // already holds a "timestamps" value, persisted alongside any other kv write, which would mask the config.
310+ // Without the list, the toggles persist in kv and turn_timing.time supplies the turn-time default.
311+ const timestampTypes = TuiConfig . timestampTypes ( tuiConfig . timestamps )
312+ const [ userTimestamps , setUserTimestamps ] = createSignal ( timestampTypes ?. has ( "user" ) )
313+ const [ turnTimes , setTurnTimes ] = createSignal ( timestampTypes ?. has ( "assistant" ) )
314+ const showTimestamps = createMemo ( ( ) => userTimestamps ( ) ?? kv . get ( "timestamps" , "hide" ) === "show" )
315+ const showTurnTime = createMemo (
316+ ( ) => turnTimes ( ) ?? kv . get ( "turn_timing_time" , tuiConfig . turn_timing ?. time ?? false ) === true ,
317+ )
311318 const showTurnDuration = createMemo (
312319 ( ) => kv . get ( "turn_timing_duration" , tuiConfig . turn_timing ?. duration ?? false ) === true ,
313320 )
@@ -743,7 +750,8 @@ export function Session() {
743750 aliases : [ "toggle-timestamps" ] ,
744751 } ,
745752 run : ( ) => {
746- setTimestamps ( ( prev ) => ( prev === "show" ? "hide" : "show" ) )
753+ if ( timestampTypes ) setUserTimestamps ( ! showTimestamps ( ) )
754+ else kv . set ( "timestamps" , showTimestamps ( ) ? "hide" : "show" )
747755 dialog . clear ( )
748756 } ,
749757 } ,
@@ -767,7 +775,8 @@ export function Session() {
767775 name : "turn-times" ,
768776 } ,
769777 run : ( ) => {
770- kv . set ( "turn_timing_time" , ! showTurnTime ( ) )
778+ if ( timestampTypes ) setTurnTimes ( ! showTurnTime ( ) )
779+ else kv . set ( "turn_timing_time" , ! showTurnTime ( ) )
771780 dialog . clear ( )
772781 } ,
773782 } ,
@@ -1291,6 +1300,7 @@ export function Session() {
12911300 showTimestamps,
12921301 showTurnTime,
12931302 showTurnDuration,
1303+ showPartTimestamp : ( type ) => timestampTypes ?. has ( type ) ?? false ,
12941304 showDetails,
12951305 showGenericToolOutput,
12961306 diffWrapMode,
@@ -1584,7 +1594,11 @@ function UserMessage(props: {
15841594 < box
15851595 marginTop = { 1 }
15861596 border = { [ "top" ] }
1587- title = " Compaction "
1597+ title = {
1598+ ctx . showPartTimestamp ( "compaction" )
1599+ ? ` Compaction · ${ Locale . todayTimeOrDateFirst ( props . message . time . created ) } `
1600+ : " Compaction "
1601+ }
15881602 titleAlignment = "center"
15891603 borderColor = { theme . borderActive }
15901604 />
@@ -1678,6 +1692,11 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
16781692 borderColor = { theme . error }
16791693 >
16801694 < text fg = { theme . textMuted } > { errorMessage ( props . message . error ) } </ text >
1695+ < Show when = { ctx . showPartTimestamp ( "error" ) } >
1696+ < text fg = { theme . textMuted } >
1697+ { Locale . todayTimeOrDateFirst ( props . message . time . completed ?? props . message . time . created ) }
1698+ </ text >
1699+ </ Show >
16811700 </ box >
16821701 </ Show >
16831702 < Switch >
@@ -1777,6 +1796,11 @@ function ReasoningPart(props: { last: boolean; part: ReasoningPart; message: Ass
17771796 open = { ! inMinimal ( ) || expanded ( ) }
17781797 done = { isDone ( ) }
17791798 title = { summary ( ) . title }
1799+ time = {
1800+ ctx . showPartTimestamp ( "reasoning" ) && props . part . time . end !== undefined
1801+ ? Locale . todayTimeOrDateFirst ( props . part . time . end )
1802+ : undefined
1803+ }
17801804 duration = { isDone ( ) ? Locale . duration ( duration ( ) ) : undefined }
17811805 encrypted = { opaque ( ) }
17821806 />
@@ -1804,6 +1828,7 @@ function ReasoningHeader(props: {
18041828 open : boolean
18051829 done : boolean
18061830 title : string | null
1831+ time ?: string
18071832 duration ?: string
18081833 encrypted ?: boolean
18091834} ) {
@@ -1813,8 +1838,9 @@ function ReasoningHeader(props: {
18131838 ? RGBA . fromValues ( theme . warning . r , theme . warning . g , theme . warning . b , theme . thinkingOpacity )
18141839 : theme . warning
18151840 const completed = ( ) => {
1816- if ( props . encrypted ) return `Thought${ props . duration ? ` · ${ props . duration } ` : "" } `
1817- const detail = [ props . title , props . duration ] . filter ( Boolean ) . join ( " · " )
1841+ const timing = [ props . time , props . duration ] . filter ( Boolean ) . join ( " · " )
1842+ if ( props . encrypted ) return `Thought${ timing ? ` · ${ timing } ` : "" } `
1843+ const detail = [ props . title , timing ] . filter ( Boolean ) . join ( " · " )
18181844 return `${ props . toggleable ? ( props . open ? "- " : "+ " ) : "" } Thought${ detail ? `: ${ detail } ` : "" } `
18191845 }
18201846
@@ -1856,6 +1882,9 @@ function TextPart(props: { last: boolean; part: TextPart; message: AssistantMess
18561882 fg = { theme . markdownText }
18571883 bg = { theme . background }
18581884 />
1885+ < Show when = { ctx . showPartTimestamp ( "text" ) && props . part . time ?. end } >
1886+ { ( end ) => < text fg = { theme . textMuted } > { Locale . todayTimeOrDateFirst ( end ( ) ) } </ text > }
1887+ </ Show >
18591888 </ box >
18601889 </ Show >
18611890 )
@@ -2027,6 +2056,9 @@ function InlineTool(props: {
20272056 )
20282057
20292058 const failed = createMemo ( ( ) => Boolean ( error ( ) && ! denied ( ) ) )
2059+ const timestamp = createMemo ( ( ) =>
2060+ ctx . showPartTimestamp ( "tool" ) ? formatToolTimestamp ( props . part . state ) : undefined ,
2061+ )
20302062 const clickable = createMemo ( ( ) => Boolean ( props . onClick || failed ( ) ) )
20312063 const fg = createMemo ( ( ) => {
20322064 if ( props . color ) return props . color
@@ -2053,6 +2085,8 @@ function InlineTool(props: {
20532085 failure = { props . failure }
20542086 spinner = { props . spinner }
20552087 separate = { props . separate }
2088+ timestamp = { timestamp ( ) }
2089+ timestampColor = { theme . textMuted }
20562090 onMouseOver = { ( ) => clickable ( ) && setHover ( true ) }
20572091 onMouseOut = { ( ) => setHover ( false ) }
20582092 onMouseUp = { ( ) => {
@@ -2084,6 +2118,8 @@ export function InlineToolRow(props: {
20842118 failure ?: string
20852119 spinner ?: boolean
20862120 separate ?: boolean
2121+ timestamp ?: string
2122+ timestampColor ?: RGBA
20872123 children : JSX . Element
20882124 onMouseOver ?: ( ) => void
20892125 onMouseOut ?: ( ) => void
@@ -2137,6 +2173,9 @@ export function InlineToolRow(props: {
21372173 attributes = { props . denied ? TextAttributes . STRIKETHROUGH : undefined }
21382174 >
21392175 { props . failed && ! props . complete ? ( props . failure ?? props . children ) : props . children }
2176+ < Show when = { props . timestamp } >
2177+ < span style = { { fg : props . timestampColor } } > · { props . timestamp } </ span >
2178+ </ Show >
21402179 </ text >
21412180 </ box >
21422181 </ Show >
@@ -2159,9 +2198,13 @@ function BlockTool(props: {
21592198 spinner ?: boolean
21602199} ) {
21612200 const { theme } = useTheme ( )
2201+ const ctx = use ( )
21622202 const renderer = useRenderer ( )
21632203 const [ hover , setHover ] = createSignal ( false )
21642204 const error = createMemo ( ( ) => ( props . part ?. state . status === "error" ? props . part . state . error : undefined ) )
2205+ const timestamp = createMemo ( ( ) =>
2206+ props . part && ctx . showPartTimestamp ( "tool" ) ? formatToolTimestamp ( props . part . state ) : undefined ,
2207+ )
21652208 return (
21662209 < box
21672210 id = { props . part ?. id }
@@ -2189,6 +2232,7 @@ function BlockTool(props: {
21892232 fallback = {
21902233 < text paddingLeft = { 3 } fg = { theme . textMuted } >
21912234 { title ( ) }
2235+ { timestamp ( ) ? ` · ${ timestamp ( ) } ` : "" }
21922236 </ text >
21932237 }
21942238 >
@@ -2200,6 +2244,9 @@ function BlockTool(props: {
22002244 < Show when = { error ( ) } >
22012245 < text fg = { theme . error } > { error ( ) } </ text >
22022246 </ Show >
2247+ < Show when = { ! props . title && timestamp ( ) } >
2248+ < text fg = { theme . textMuted } > { timestamp ( ) } </ text >
2249+ </ Show >
22032250 </ box >
22042251 )
22052252}
@@ -2471,6 +2518,11 @@ function Task(props: ToolProps) {
24712518 )
24722519}
24732520
2521+ export function formatToolTimestamp ( state : ToolPart [ "state" ] ) {
2522+ if ( state . status !== "completed" && state . status !== "error" ) return
2523+ return `${ Locale . todayTimeOrDateFirst ( state . time . end ) } · ${ Locale . duration ( Math . max ( 0 , state . time . end - state . time . start ) ) } `
2524+ }
2525+
24742526export function formatSubagentToolcalls ( count : number ) {
24752527 return `${ count } toolcall${ count === 1 ? "" : "s" } `
24762528}
0 commit comments