@@ -5,6 +5,7 @@ import * as Schema from "effect/Schema";
55import { CommandId , ProjectId , ThreadId } from "./baseSchemas.ts" ;
66
77import {
8+ ProjectIconOverride ,
89 DEFAULT_PROVIDER_INTERACTION_MODE ,
910 DEFAULT_RUNTIME_MODE ,
1011 type ChatImageAttachment ,
@@ -17,9 +18,8 @@ import {
1718 OrchestrationGetTurnDiffInput ,
1819 OrchestrationLatestTurn ,
1920 ProjectCreatedPayload ,
20- OrchestrationProjectShell ,
21- ProjectIconColor ,
2221 ProjectMetaUpdatedPayload ,
22+ OrchestrationProjectShell ,
2323 OrchestrationProposedPlan ,
2424 OrchestrationSession ,
2525 OrchestrationThread ,
@@ -42,18 +42,6 @@ import { ProviderInstanceId } from "./providerInstance.ts";
4242const decodeTurnDiffInput = Schema . decodeUnknownEffect ( OrchestrationGetTurnDiffInput ) ;
4343const decodeFullThreadDiffInput = Schema . decodeUnknownEffect ( OrchestrationGetFullThreadDiffInput ) ;
4444const decodeThreadTurnDiff = Schema . decodeUnknownEffect ( ThreadTurnDiff ) ;
45- // The icon shape understood by clients released before monograms.
46- const legacyProjectIcon = Schema . Union ( [
47- Schema . Struct ( { kind : Schema . Literal ( "lucide" ) , name : Schema . String , color : ProjectIconColor } ) ,
48- Schema . Struct ( { kind : Schema . Literal ( "emoji" ) , emoji : Schema . String } ) ,
49- ] ) ;
50- const decodeLegacyProjectShell = Schema . decodeUnknownEffect (
51- Schema . Struct ( {
52- ...OrchestrationProjectShell . fields ,
53- projectIcon : Schema . optional ( Schema . NullOr ( legacyProjectIcon ) ) ,
54- } ) ,
55- ) ;
56- const encodeProjectShell = Schema . encodeEffect ( OrchestrationProjectShell ) ;
5745const decodeProjectCreateCommand = Schema . decodeUnknownEffect ( ProjectCreateCommand ) ;
5846const decodeProjectCreatedPayload = Schema . decodeUnknownEffect ( ProjectCreatedPayload ) ;
5947const decodeProjectMetaUpdatedPayload = Schema . decodeUnknownEffect ( ProjectMetaUpdatedPayload ) ;
@@ -1508,31 +1496,13 @@ it.effect("project icon overrides accept Lucide icons, colors, and emoji", () =>
15081496 } ) ,
15091497) ;
15101498
1511- it . effect ( "older clients decode monogram projects as their fallback icon" , ( ) =>
1512- Effect . gen ( function * ( ) {
1513- const encoded = yield * encodeProjectShell ( {
1514- id : ProjectId . make ( "project-monogram" ) ,
1515- title : "Monogram" ,
1516- workspaceRoot : "/tmp/monogram" ,
1517- defaultModelSelection : null ,
1518- scripts : [ ] ,
1519- createdAt : "2026-01-01T00:00:00.000Z" ,
1520- updatedAt : "2026-01-01T00:00:00.000Z" ,
1521- projectIcon : { kind : "lucide" , name : "folder-code" , color : "violet" , monogram : "T3" } ,
1522- } ) ;
1523- const decoded = yield * decodeLegacyProjectShell ( encoded ) ;
1524- assert . deepEqual ( decoded . projectIcon , { kind : "lucide" , name : "folder-code" , color : "violet" } ) ;
1525- } ) ,
1526- ) ;
1527-
15281499it . effect ( "project monograms validate text and palette colors" , ( ) =>
15291500 Effect . gen ( function * ( ) {
15301501 for ( const text of [ "A" , "T3" , "É" , "文書" , "कि" , "किखि" , "e\u0301" ] ) {
15311502 const projectIcon = {
1532- kind : "lucide" ,
1533- name : "folder-code" ,
1503+ kind : "monogram" ,
15341504 color : "violet" ,
1535- monogram : text ,
1505+ text,
15361506 } as const ;
15371507 const command = yield * decodeOrchestrationCommand ( {
15381508 type : "project.meta.update" ,
@@ -1542,16 +1512,14 @@ it.effect("project monograms validate text and palette colors", () =>
15421512 } ) ;
15431513 assert . strictEqual ( command . type , "project.meta.update" ) ;
15441514 if ( command . type === "project.meta.update" )
1545- assert . deepEqual ( command . projectIcon , projectIcon ) ;
1515+ assert . deepEqual ( command . projectIcon , { kind : "monogram" , text , color : "violet" } ) ;
15461516 }
15471517 for ( const projectIcon of [
1548- { kind : "lucide" , name : "folder-code" , monogram : "" , color : "blue" } ,
1549- { kind : "lucide" , name : "folder-code" , monogram : "ABC" , color : "blue" } ,
1550- { kind : "lucide" , name : "folder-code" , monogram : "किखिगि" , color : "blue" } ,
1551- { kind : "lucide" , name : "folder-code" , monogram : "\u0301" , color : "blue" } ,
1552- { kind : "lucide" , name : "folder-code" , monogram : "A B" , color : "blue" } ,
1553- { kind : "lucide" , name : "folder-code" , monogram : "🚀" , color : "blue" } ,
1554- { kind : "lucide" , name : "folder-code" , monogram : "T3" , color : "ultraviolet" } ,
1518+ { kind : "monogram" , text : "" , color : "blue" } ,
1519+ { kind : "monogram" , text : "\u0301" , color : "blue" } ,
1520+ { kind : "monogram" , text : "A B" , color : "blue" } ,
1521+ { kind : "monogram" , text : "🚀" , color : "blue" } ,
1522+ { kind : "monogram" , text : "T3" , color : "ultraviolet" } ,
15551523 ] ) {
15561524 const result = yield * Effect . exit (
15571525 decodeOrchestrationCommand ( {
@@ -1586,3 +1554,92 @@ it("isProviderSendTurnSupportedImageMimeType accepts raster formats and rejects
15861554 assert . strictEqual ( isProviderSendTurnSupportedImageMimeType ( "IMAGE/JPEG" ) , true ) ;
15871555 assert . strictEqual ( isProviderSendTurnSupportedImageMimeType ( "image/svg+xml" ) , false ) ;
15881556} ) ;
1557+
1558+ const decodeProjectIcon = Schema . decodeUnknownEffect ( ProjectIconOverride ) ;
1559+ const encodeProjectIcon = Schema . encodeEffect ( ProjectIconOverride ) ;
1560+
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" , ( ) =>
1582+ Effect . gen ( function * ( ) {
1583+ const fallback = { kind : "lucide" , name : "folder-code" , color : "violet" } as const ;
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 ) ;
1593+ }
1594+ for ( const icon of [
1595+ { kind : "lucide" , name : "alarm-clock" , color : "blue" } ,
1596+ { kind : "emoji" , emoji : "🚀" } ,
1597+ ] as const ) {
1598+ assert . deepEqual ( yield * decodeProjectIcon ( icon ) , icon ) ;
1599+ assert . deepEqual ( yield * encodeProjectIcon ( icon ) , icon ) ;
1600+ }
1601+ } ) ,
1602+ ) ;
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