@@ -6,6 +6,7 @@ import type {
66 SessionTitleStatus ,
77 ToolCallContent ,
88} from './types'
9+ import { stripWorkspaceDirective } from '../../lib/workspace-message-scope'
910
1011export function deriveFriendlyIdFromKey ( key : string | undefined ) : string {
1112 if ( ! key ) return 'main'
@@ -52,7 +53,7 @@ function stripChannelPrefix(text: string): string {
5253 * and [Telegram/Signal/etc ...] headers, leaving just the user's text.
5354 */
5455function cleanUserText ( raw : string ) : string {
55- let text = raw
56+ let text = stripWorkspaceDirective ( raw )
5657
5758 // Remove "Conversation info (untrusted metadata):" headers + JSON block
5859 // Format: "Conversation info (untrusted metadata):\n```json\n{...}\n```\n\n"
@@ -226,15 +227,15 @@ export function normalizeSessions(
226227 : undefined
227228 const explicitTitle =
228229 typeof session . title === 'string' && session . title . trim ( ) . length > 0
229- ? session . title . trim ( )
230+ ? cleanUserText ( session . title . trim ( ) ) || session . title . trim ( )
230231 : undefined
231232 const derivedTitle =
232233 typeof session . derivedTitle === 'string' &&
233234 session . derivedTitle . trim ( ) . length > 0
234- ? session . derivedTitle . trim ( )
235+ ? cleanUserText ( session . derivedTitle . trim ( ) ) || session . derivedTitle . trim ( )
235236 : typeof session . preview === 'string' &&
236237 session . preview . trim ( ) . length > 0
237- ? session . preview . trim ( )
238+ ? cleanUserText ( session . preview . trim ( ) ) || session . preview . trim ( )
238239 : undefined
239240 const titleStatus = deriveTitleStatus (
240241 label ,
@@ -261,7 +262,10 @@ export function normalizeSessions(
261262 titleStatus,
262263 titleSource,
263264 titleError : session . titleError ?? null ,
264- preview : session . preview ?? null ,
265+ preview :
266+ typeof session . preview === 'string'
267+ ? cleanUserText ( session . preview ) || session . preview . trim ( ) || null
268+ : session . preview ?? null ,
265269 }
266270 } )
267271}
0 commit comments