@@ -19,6 +19,7 @@ import {
1919 OrchestrationLatestTurn ,
2020 ProjectCreatedPayload ,
2121 ProjectMetaUpdatedPayload ,
22+ OrchestrationProjectShell ,
2223 OrchestrationProposedPlan ,
2324 OrchestrationSession ,
2425 OrchestrationThread ,
@@ -1557,22 +1558,88 @@ it("isProviderSendTurnSupportedImageMimeType accepts raster formats and rejects
15571558const decodeProjectIcon = Schema . decodeUnknownEffect ( ProjectIconOverride ) ;
15581559const encodeProjectIcon = Schema . encodeEffect ( ProjectIconOverride ) ;
15591560
1560- it . effect ( "ignores legacy monogram fields and preserves standalone icon variants" , ( ) =>
1561+ // Pre-monogram clients reject unknown variants; nightly clients additionally validate monogram.
1562+ const decodeOldIcon = Schema . decodeUnknownEffect (
1563+ Schema . Union ( [
1564+ Schema . Struct ( { kind : Schema . Literal ( "lucide" ) , name : Schema . String , color : Schema . String } ) ,
1565+ Schema . Struct ( { kind : Schema . Literal ( "emoji" ) , emoji : Schema . String } ) ,
1566+ ] ) ,
1567+ ) ;
1568+ const decodeNightlyIcon = Schema . decodeUnknownEffect (
1569+ Schema . Union ( [
1570+ Schema . Struct ( {
1571+ kind : Schema . Literal ( "lucide" ) ,
1572+ name : Schema . String ,
1573+ color : Schema . String ,
1574+ // Fail if this field is ever sent; old validators must never see the new text.
1575+ monogram : Schema . optional ( Schema . Never ) ,
1576+ } ) ,
1577+ Schema . Struct ( { kind : Schema . Literal ( "emoji" ) , emoji : Schema . String } ) ,
1578+ ] ) ,
1579+ ) ;
1580+
1581+ it . effect ( "sends monograms as fallback icons that old and nightly clients can decode" , ( ) =>
15611582 Effect . gen ( function * ( ) {
15621583 const fallback = { kind : "lucide" , name : "folder-code" , color : "violet" } as const ;
1563- for ( const monogram of [ "T3" , "" , { invalid : true } ] ) {
1564- const decoded = yield * decodeProjectIcon ( { ...fallback , monogram } ) ;
1565- assert . deepEqual ( decoded , fallback ) ;
1566- assert . deepEqual ( yield * encodeProjectIcon ( decoded ) , fallback ) ;
1584+ for ( const text of [ "T3" , "क्ष्म" , "e\u0301" ] ) {
1585+ const monogram = { kind : "monogram" , text, color : "violet" } as const ;
1586+ const wire = yield * encodeProjectIcon ( monogram ) ;
1587+ assert . deepEqual ( wire , { ...fallback , monogramText : text } ) ;
1588+ assert . deepEqual ( yield * decodeOldIcon ( wire ) , fallback ) ;
1589+ assert . deepEqual ( yield * decodeNightlyIcon ( wire ) , fallback ) ;
1590+ assert . deepEqual ( yield * decodeProjectIcon ( wire ) , monogram ) ;
1591+ assert . deepEqual ( yield * decodeProjectIcon ( monogram ) , monogram ) ;
1592+ assert . deepEqual ( yield * decodeProjectIcon ( { ...fallback , monogram : text } ) , monogram ) ;
15671593 }
15681594 for ( const icon of [
1569- { kind : "monogram" , text : "T3" , color : "violet" } ,
15701595 { kind : "lucide" , name : "alarm-clock" , color : "blue" } ,
15711596 { kind : "emoji" , emoji : "🚀" } ,
15721597 ] as const ) {
1573- const decoded = yield * decodeProjectIcon ( icon ) ;
1574- assert . deepEqual ( decoded , icon ) ;
1575- assert . deepEqual ( yield * encodeProjectIcon ( decoded ) , icon ) ;
1598+ assert . deepEqual ( yield * decodeProjectIcon ( icon ) , icon ) ;
1599+ assert . deepEqual ( yield * encodeProjectIcon ( icon ) , icon ) ;
15761600 }
15771601 } ) ,
15781602) ;
1603+
1604+ const encodeProjectShell = Schema . encodeEffect ( OrchestrationProjectShell ) ;
1605+ const encodeClientCommand = Schema . encodeEffect ( ClientOrchestrationCommand ) ;
1606+ const decodeLegacyShell = Schema . decodeUnknownEffect (
1607+ Schema . Struct ( {
1608+ ...OrchestrationProjectShell . fields ,
1609+ projectIcon : Schema . optional (
1610+ Schema . NullOr (
1611+ Schema . Struct ( {
1612+ kind : Schema . Literal ( "lucide" ) ,
1613+ name : Schema . String ,
1614+ color : Schema . String ,
1615+ } ) ,
1616+ ) ,
1617+ ) ,
1618+ } ) ,
1619+ ) ;
1620+
1621+ it . effect ( "encodes compatible icons inside snapshots and client commands" , ( ) =>
1622+ Effect . gen ( function * ( ) {
1623+ const projectIcon = { kind : "monogram" , text : "क्ष्म" , color : "violet" } as const ;
1624+ const shell = yield * encodeProjectShell ( {
1625+ id : ProjectId . make ( "monogram" ) ,
1626+ title : "Monogram" ,
1627+ workspaceRoot : "/tmp/monogram" ,
1628+ defaultModelSelection : null ,
1629+ scripts : [ ] ,
1630+ projectIcon,
1631+ createdAt : "2026-01-01T00:00:00.000Z" ,
1632+ updatedAt : "2026-01-01T00:00:00.000Z" ,
1633+ } ) ;
1634+ const fallback = { kind : "lucide" , name : "folder-code" , color : "violet" } as const ;
1635+ assert . deepEqual ( ( yield * decodeLegacyShell ( shell ) ) . projectIcon , fallback ) ;
1636+ const command = yield * encodeClientCommand ( {
1637+ type : "project.meta.update" ,
1638+ projectId : ProjectId . make ( "monogram" ) ,
1639+ commandId : CommandId . make ( "monogram" ) ,
1640+ projectIcon,
1641+ } ) ;
1642+ if ( command . type !== "project.meta.update" ) throw new Error ( "Unexpected command" ) ;
1643+ assert . deepEqual ( yield * decodeNightlyIcon ( command . projectIcon ) , fallback ) ;
1644+ } ) ,
1645+ ) ;
0 commit comments