@@ -70,6 +70,7 @@ const PROJECT_KEY = scopedProjectKey(scopeProjectRef(LOCAL_ENVIRONMENT_ID, PROJE
7070const NOW_ISO = "2026-03-04T12:00:00.000Z" ;
7171const BASE_TIME_MS = Date . parse ( NOW_ISO ) ;
7272const ATTACHMENT_SVG = "<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'></svg>" ;
73+ const ADD_PROJECT_SUBMENU_PLACEHOLDER = "Enter path (e.g. ~/projects/my-app)" ;
7374
7475interface TestFixture {
7576 snapshot : OrchestrationReadModel ;
@@ -1383,6 +1384,44 @@ async function waitForCommandPaletteShortcutLabel(): Promise<void> {
13831384 ) ;
13841385}
13851386
1387+ async function waitForCommandPaletteInput ( placeholder : string ) : Promise < HTMLInputElement > {
1388+ return waitForElement (
1389+ ( ) => document . querySelector ( `input[placeholder="${ placeholder } "]` ) as HTMLInputElement | null ,
1390+ `Command palette input with placeholder "${ placeholder } " did not render.` ,
1391+ ) ;
1392+ }
1393+
1394+ function getCommandPaletteLegendEntries ( ) : string [ ] {
1395+ const footer = document . querySelector ( '[data-slot="command-footer"]' ) ;
1396+ if ( ! footer ) {
1397+ return [ ] ;
1398+ }
1399+
1400+ return Array . from ( footer . querySelectorAll ( '[data-slot="kbd-group"]' ) )
1401+ . map ( ( group ) =>
1402+ Array . from ( group . children )
1403+ . map ( ( child ) => child . textContent ?. trim ( ) ?? "" )
1404+ . filter ( ( value ) => value . length > 0 )
1405+ . join ( " " ) ,
1406+ )
1407+ . filter ( ( value ) => value . length > 0 ) ;
1408+ }
1409+
1410+ async function dispatchInputKey (
1411+ input : HTMLInputElement ,
1412+ init : Pick < KeyboardEventInit , "key" | "metaKey" | "ctrlKey" | "shiftKey" | "altKey" > ,
1413+ ) : Promise < void > {
1414+ input . focus ( ) ;
1415+ input . dispatchEvent (
1416+ new KeyboardEvent ( "keydown" , {
1417+ bubbles : true ,
1418+ cancelable : true ,
1419+ ...init ,
1420+ } ) ,
1421+ ) ;
1422+ await waitForLayout ( ) ;
1423+ }
1424+
13861425async function mountChatView ( options : {
13871426 viewport : ViewportSpec ;
13881427 snapshot : OrchestrationReadModel ;
@@ -4079,6 +4118,244 @@ describe("ChatView timeline estimator parity (full app)", () => {
40794118 }
40804119 } ) ;
40814120
4121+ it ( "adds a project from browse mode with Enter when no directory is highlighted" , async ( ) => {
4122+ const mounted = await mountChatView ( {
4123+ viewport : DEFAULT_VIEWPORT ,
4124+ snapshot : createSnapshotForTargetUser ( {
4125+ targetMessageId : "msg-user-command-palette-add-project-enter" as MessageId ,
4126+ targetText : "command palette add project enter" ,
4127+ } ) ,
4128+ configureFixture : ( nextFixture ) => {
4129+ nextFixture . serverConfig = {
4130+ ...nextFixture . serverConfig ,
4131+ keybindings : [
4132+ {
4133+ command : "commandPalette.toggle" ,
4134+ shortcut : {
4135+ key : "k" ,
4136+ metaKey : false ,
4137+ ctrlKey : false ,
4138+ shiftKey : false ,
4139+ altKey : false ,
4140+ modKey : true ,
4141+ } ,
4142+ whenAst : {
4143+ type : "not" ,
4144+ node : { type : "identifier" , name : "terminalFocus" } ,
4145+ } ,
4146+ } ,
4147+ ] ,
4148+ } ;
4149+ } ,
4150+ resolveRpc : ( body ) => {
4151+ if ( body . _tag === WS_METHODS . filesystemBrowse ) {
4152+ if ( body . partialPath === "~/Development/" ) {
4153+ return {
4154+ parentPath : "~/Development/" ,
4155+ entries : [
4156+ { name : "alpha" , fullPath : "~/Development/alpha" } ,
4157+ { name : "beta" , fullPath : "~/Development/beta" } ,
4158+ ] ,
4159+ } ;
4160+ }
4161+
4162+ return {
4163+ parentPath : "~/" ,
4164+ entries : [ { name : "Development" , fullPath : "~/Development" } ] ,
4165+ } ;
4166+ }
4167+
4168+ if ( body . _tag === ORCHESTRATION_WS_METHODS . dispatchCommand ) {
4169+ return {
4170+ sequence : fixture . snapshot . snapshotSequence + 1 ,
4171+ } ;
4172+ }
4173+
4174+ return undefined ;
4175+ } ,
4176+ } ) ;
4177+
4178+ try {
4179+ await waitForServerConfigToApply ( ) ;
4180+ await waitForCommandPaletteShortcutLabel ( ) ;
4181+ const palette = page . getByTestId ( "command-palette" ) ;
4182+ await openCommandPaletteFromTrigger ( ) ;
4183+
4184+ await expect . element ( palette ) . toBeInTheDocument ( ) ;
4185+ await palette . getByText ( "Add project" , { exact : true } ) . click ( ) ;
4186+
4187+ const browseInput = await waitForCommandPaletteInput ( ADD_PROJECT_SUBMENU_PLACEHOLDER ) ;
4188+ await page . getByPlaceholder ( ADD_PROJECT_SUBMENU_PLACEHOLDER ) . fill ( "~/Development/" ) ;
4189+ await expect . element ( palette . getByText ( "alpha" , { exact : true } ) ) . toBeInTheDocument ( ) ;
4190+
4191+ await expect
4192+ . element ( palette . getByRole ( "button" , { name : "Add (Enter)" } ) )
4193+ . toBeInTheDocument ( ) ;
4194+
4195+ await dispatchInputKey ( browseInput , { key : "Enter" } ) ;
4196+
4197+ await vi . waitFor (
4198+ ( ) => {
4199+ const dispatchRequest = wsRequests . find (
4200+ ( request ) =>
4201+ request . _tag === ORCHESTRATION_WS_METHODS . dispatchCommand &&
4202+ request . type === "project.create" ,
4203+ ) as
4204+ | {
4205+ _tag : string ;
4206+ type ?: string ;
4207+ workspaceRoot ?: string ;
4208+ title ?: string ;
4209+ }
4210+ | undefined ;
4211+
4212+ expect ( dispatchRequest ) . toMatchObject ( {
4213+ _tag : ORCHESTRATION_WS_METHODS . dispatchCommand ,
4214+ type : "project.create" ,
4215+ workspaceRoot : "~/Development" ,
4216+ title : "Development" ,
4217+ } ) ;
4218+ } ,
4219+ { timeout : 8_000 , interval : 16 } ,
4220+ ) ;
4221+
4222+ await waitForURL (
4223+ mounted . router ,
4224+ ( path ) => UUID_ROUTE_RE . test ( path ) ,
4225+ "Route should have changed to a new draft thread after adding a project with Enter." ,
4226+ ) ;
4227+ } finally {
4228+ await mounted . cleanup ( ) ;
4229+ }
4230+ } ) ;
4231+
4232+ it ( "adds a project from browse mode with Mod+Enter when a directory is highlighted" , async ( ) => {
4233+ const mounted = await mountChatView ( {
4234+ viewport : DEFAULT_VIEWPORT ,
4235+ snapshot : createSnapshotForTargetUser ( {
4236+ targetMessageId : "msg-user-command-palette-add-project-mod-enter" as MessageId ,
4237+ targetText : "command palette add project mod enter" ,
4238+ } ) ,
4239+ configureFixture : ( nextFixture ) => {
4240+ nextFixture . serverConfig = {
4241+ ...nextFixture . serverConfig ,
4242+ keybindings : [
4243+ {
4244+ command : "commandPalette.toggle" ,
4245+ shortcut : {
4246+ key : "k" ,
4247+ metaKey : false ,
4248+ ctrlKey : false ,
4249+ shiftKey : false ,
4250+ altKey : false ,
4251+ modKey : true ,
4252+ } ,
4253+ whenAst : {
4254+ type : "not" ,
4255+ node : { type : "identifier" , name : "terminalFocus" } ,
4256+ } ,
4257+ } ,
4258+ ] ,
4259+ } ;
4260+ } ,
4261+ resolveRpc : ( body ) => {
4262+ if ( body . _tag === WS_METHODS . filesystemBrowse ) {
4263+ if ( body . partialPath === "~/Development/" ) {
4264+ return {
4265+ parentPath : "~/Development/" ,
4266+ entries : [
4267+ { name : "alpha" , fullPath : "~/Development/alpha" } ,
4268+ { name : "beta" , fullPath : "~/Development/beta" } ,
4269+ ] ,
4270+ } ;
4271+ }
4272+
4273+ return {
4274+ parentPath : "~/" ,
4275+ entries : [ { name : "Development" , fullPath : "~/Development" } ] ,
4276+ } ;
4277+ }
4278+
4279+ if ( body . _tag === ORCHESTRATION_WS_METHODS . dispatchCommand ) {
4280+ return {
4281+ sequence : fixture . snapshot . snapshotSequence + 1 ,
4282+ } ;
4283+ }
4284+
4285+ return undefined ;
4286+ } ,
4287+ } ) ;
4288+
4289+ try {
4290+ await waitForServerConfigToApply ( ) ;
4291+ await waitForCommandPaletteShortcutLabel ( ) ;
4292+ const palette = page . getByTestId ( "command-palette" ) ;
4293+ await openCommandPaletteFromTrigger ( ) ;
4294+
4295+ await expect . element ( palette ) . toBeInTheDocument ( ) ;
4296+ await palette . getByText ( "Add project" , { exact : true } ) . click ( ) ;
4297+
4298+ const browseInput = await waitForCommandPaletteInput ( ADD_PROJECT_SUBMENU_PLACEHOLDER ) ;
4299+ await page . getByPlaceholder ( ADD_PROJECT_SUBMENU_PLACEHOLDER ) . fill ( "~/Development/" ) ;
4300+ await expect . element ( palette . getByText ( "alpha" , { exact : true } ) ) . toBeInTheDocument ( ) ;
4301+
4302+ await dispatchInputKey ( browseInput , { key : "ArrowDown" } ) ;
4303+
4304+ const addButtonLabel = isMacPlatform ( navigator . platform )
4305+ ? "Add (\u2318 Enter)"
4306+ : "Add (Ctrl Enter)" ;
4307+ await vi . waitFor (
4308+ ( ) => {
4309+ const legendEntries = getCommandPaletteLegendEntries ( ) ;
4310+ expect ( legendEntries ) . toContain ( "Enter Select" ) ;
4311+ } ,
4312+ { timeout : 8_000 , interval : 16 } ,
4313+ ) ;
4314+ await expect
4315+ . element ( palette . getByRole ( "button" , { name : addButtonLabel } ) )
4316+ . toBeInTheDocument ( ) ;
4317+
4318+ await dispatchInputKey ( browseInput , {
4319+ key : "Enter" ,
4320+ metaKey : isMacPlatform ( navigator . platform ) ,
4321+ ctrlKey : ! isMacPlatform ( navigator . platform ) ,
4322+ } ) ;
4323+
4324+ await vi . waitFor (
4325+ ( ) => {
4326+ const dispatchRequest = wsRequests . find (
4327+ ( request ) =>
4328+ request . _tag === ORCHESTRATION_WS_METHODS . dispatchCommand &&
4329+ request . type === "project.create" ,
4330+ ) as
4331+ | {
4332+ _tag : string ;
4333+ type ?: string ;
4334+ workspaceRoot ?: string ;
4335+ title ?: string ;
4336+ }
4337+ | undefined ;
4338+
4339+ expect ( dispatchRequest ) . toMatchObject ( {
4340+ _tag : ORCHESTRATION_WS_METHODS . dispatchCommand ,
4341+ type : "project.create" ,
4342+ workspaceRoot : "~/Development" ,
4343+ title : "Development" ,
4344+ } ) ;
4345+ } ,
4346+ { timeout : 8_000 , interval : 16 } ,
4347+ ) ;
4348+
4349+ await waitForURL (
4350+ mounted . router ,
4351+ ( path ) => UUID_ROUTE_RE . test ( path ) ,
4352+ "Route should have changed to a new draft thread after adding a project with Mod+Enter." ,
4353+ ) ;
4354+ } finally {
4355+ await mounted . cleanup ( ) ;
4356+ }
4357+ } ) ;
4358+
40824359 it ( "keeps project-context thread matches available when searching by project name" , async ( ) => {
40834360 const mounted = await mountChatView ( {
40844361 viewport : DEFAULT_VIEWPORT ,
0 commit comments