@@ -24,85 +24,6 @@ use pi_acp_lib::AcpAgentTx;
2424use std:: path:: PathBuf ;
2525use std:: sync:: Arc ;
2626use std:: time:: { Duration , Instant } ;
27- /// State for the "New Worktree" popup dialog on the welcome screen.
28- #[ derive( Debug , Default ) ]
29- pub struct NewWorktreeDialogState {
30- /// Text input for the worktree label (empty = auto-generated name).
31- label : LineEditor ,
32- }
33- const MAX_WORKTREE_LABEL_BYTES : usize = 100 ;
34- impl NewWorktreeDialogState {
35- pub fn new ( ) -> Self {
36- Self {
37- label : LineEditor :: default ( ) ,
38- }
39- }
40- pub fn label ( & self ) -> & str {
41- self . label . text ( )
42- }
43- pub ( crate ) fn viewport ( & self , width : usize ) -> pi_ratatui_textarea:: SingleLineViewport {
44- self . label . viewport ( width)
45- }
46- #[ cfg( test) ]
47- pub ( crate ) fn set_label ( & mut self , label : impl Into < String > ) {
48- self . label . set_text ( label) ;
49- }
50- #[ cfg( test) ]
51- pub ( crate ) fn set_cursor_byte ( & mut self , cursor_byte : usize ) -> LineEditOutcome {
52- self . label . set_cursor_byte ( cursor_byte)
53- }
54- pub fn insert_paste ( & mut self , text : & str ) -> NewWorktreeDialogOutcome {
55- Self :: from_line_edit (
56- self . label
57- . insert_paste_with_byte_limit ( text, MAX_WORKTREE_LABEL_BYTES ) ,
58- )
59- }
60- /// Handle a key event. Returns the dialog outcome.
61- pub fn handle_key ( & mut self , key : & crossterm:: event:: KeyEvent ) -> NewWorktreeDialogOutcome {
62- use crossterm:: event:: { KeyCode , KeyModifiers } ;
63- if crate :: input:: key:: is_paste_key ( key) {
64- return crate :: clipboard:: system_clipboard_get ( )
65- . map_or ( NewWorktreeDialogOutcome :: Unchanged , |text| {
66- self . insert_paste ( & text)
67- } ) ;
68- }
69- if key. modifiers . contains ( KeyModifiers :: CONTROL )
70- && !crate :: input:: key:: is_altgr ( key. modifiers )
71- && matches ! ( key. code, KeyCode :: Char ( 'c' | 'd' | 'q' ) )
72- {
73- return NewWorktreeDialogOutcome :: Cancelled ;
74- }
75- if key. code == KeyCode :: Enter && !key. modifiers . is_empty ( ) {
76- return NewWorktreeDialogOutcome :: Unchanged ;
77- }
78- match key. code {
79- KeyCode :: Enter if key. modifiers . is_empty ( ) => {
80- let label = self . label ( ) . trim ( ) . to_string ( ) ;
81- NewWorktreeDialogOutcome :: Submitted ( if label. is_empty ( ) {
82- None
83- } else {
84- Some ( label)
85- } )
86- }
87- KeyCode :: Esc => NewWorktreeDialogOutcome :: Cancelled ,
88- _ => {
89- let remaining = MAX_WORKTREE_LABEL_BYTES . saturating_sub ( self . label ( ) . len ( ) ) ;
90- let outcome = self . label . handle_key_with_insert_policy ( key, |character| {
91- character. len_utf8 ( ) <= remaining
92- } ) ;
93- Self :: from_line_edit ( outcome)
94- }
95- }
96- }
97- fn from_line_edit ( outcome : LineEditOutcome ) -> NewWorktreeDialogOutcome {
98- match outcome {
99- LineEditOutcome :: TextChanged
100- | LineEditOutcome :: CursorChanged
101- | LineEditOutcome :: HandledNoChange => NewWorktreeDialogOutcome :: Changed ,
102- LineEditOutcome :: Unhandled => NewWorktreeDialogOutcome :: Unchanged ,
103- }
104- }
105- }
10627/// Per-visit announcement UI state on the welcome screen. Reset on every
10728/// return-to-welcome transition (see `show_welcome`) so a previously expanded
10829/// announcement can't leak into a freshly shown screen; the non-`expanded`
@@ -118,19 +39,6 @@ pub struct WelcomeAnnouncementState {
11839 /// Hit-test rect for the full announcement block (click anywhere to toggle).
11940 pub rect : Option < ratatui:: layout:: Rect > ,
12041}
121- /// Outcome of handling input in the new-worktree dialog.
122- #[ derive( Debug ) ]
123- pub enum NewWorktreeDialogOutcome {
124- /// User pressed Enter — create the worktree.
125- /// `None` means auto-generate the name.
126- Submitted ( Option < String > ) ,
127- /// User pressed Esc — close without creating.
128- Cancelled ,
129- /// Input changed (redraw needed).
130- Changed ,
131- /// Nothing happened.
132- Unchanged ,
133- }
13442/// Persisted worktree preference for `/new` and `/fork`.
13543///
13644/// Controls whether the worktree question popup is shown when starting a
@@ -841,8 +749,6 @@ pub struct AppView {
841749 /// Whether mouse capture is currently enabled. Disabled during the
842750 /// Authenticating state so the terminal handles native text selection.
843751 pub mouse_captured : bool ,
844- /// Active "New Worktree" dialog on the welcome screen.
845- pub new_worktree_dialog : Option < NewWorktreeDialogState > ,
846752 /// Resolved per-tip gates for the contextual ephemeral hints (undo tip,
847753 /// plan nudge, clipboard-image tip). Default all ON; resolved
848754 /// at startup and on settings toggles from `GROK_CONTEXTUAL_HINTS` (master)
@@ -1313,7 +1219,6 @@ impl AppView {
13131219 subagents : false ,
13141220 ask_user : false ,
13151221 mouse_captured : true ,
1316- new_worktree_dialog : None ,
13171222 contextual_hints : Default :: default ( ) ,
13181223 remote_contextual_hints : None ,
13191224 tip_seen_counts : Default :: default ( ) ,
@@ -1926,10 +1831,11 @@ impl AppView {
19261831 auth_code_input : & mut self . auth_code_input ,
19271832 prompt : & mut self . welcome_prompt ,
19281833 prompt_focused : & mut self . welcome_prompt_focused ,
1929- new_worktree_dialog : & mut self . new_worktree_dialog ,
19301834 menu_index : & mut self . welcome_menu_index ,
19311835 menu_rects : & self . welcome_menu_rects ,
1932- menu_count : if zdr_blocked { 2 } else { 3 } ,
1836+ // Access gate: CTA / Logout / Quit; otherwise Resume / Quit (or
1837+ // Logout / Quit when ZDR-blocked).
1838+ menu_count : if !zdr_blocked && !has_access { 3 } else { 2 } ,
19331839 prompt_rect : self . welcome_prompt_rect . as_ref ( ) ,
19341840 auth_url_rect : self . welcome_auth_url_rect . as_ref ( ) ,
19351841 auth_fallback_rect : self . welcome_auth_fallback_rect . as_ref ( ) ,
@@ -1954,7 +1860,6 @@ impl AppView {
19541860 sp_state : & mut self . session_picker_state ,
19551861 welcome_doc_viewer : & mut self . welcome_doc_viewer ,
19561862 has_pending_update : self . pending_update_version . is_some ( ) ,
1957- cwd_has_git_ancestor : self . cwd_has_git_ancestor ,
19581863 session_picker_grouped : self . session_picker_grouped ,
19591864 sp_pending_delete : & mut self . session_picker_pending_delete ,
19601865 } ,
@@ -2142,8 +2047,7 @@ impl AppView {
21422047}
21432048pub ( crate ) use crate :: views:: session_picker:: filter_session_entries;
21442049use crate :: views:: session_picker:: {
2145- PickerItem , SessionPickerWorktreeSelection , build_entry_map, session_picker_worktree_selection,
2146- sync_session_picker_query_expansion,
2050+ PickerItem , build_entry_map, sync_session_picker_query_expansion,
21472051} ;
21482052/// Context for welcome-view input handling.
21492053struct WelcomeInputCtx < ' a > {
@@ -2161,7 +2065,6 @@ struct WelcomeInputCtx<'a> {
21612065 auth_code_input : & ' a mut LineEditor ,
21622066 prompt : & ' a mut PromptWidget ,
21632067 prompt_focused : & ' a mut bool ,
2164- new_worktree_dialog : & ' a mut Option < NewWorktreeDialogState > ,
21652068 menu_index : & ' a mut Option < usize > ,
21662069 menu_rects : & ' a [ ratatui:: layout:: Rect ] ,
21672070 menu_count : usize ,
@@ -2201,7 +2104,6 @@ struct WelcomeInputCtx<'a> {
22012104 sp_state : & ' a mut crate :: views:: picker:: PickerState ,
22022105 welcome_doc_viewer : & ' a mut Option < crate :: views:: modal:: ActiveModal > ,
22032106 has_pending_update : bool ,
2204- cwd_has_git_ancestor : bool ,
22052107 session_picker_grouped : bool ,
22062108 sp_pending_delete : & ' a mut Option < crate :: views:: session_picker:: PendingDelete > ,
22072109}
@@ -2255,32 +2157,6 @@ fn handle_welcome_input(ev: &Event, ctx: &mut WelcomeInputCtx<'_>) -> InputOutco
22552157 }
22562158 return InputOutcome :: Unchanged ;
22572159 }
2258- if let Some ( dialog) = ctx. new_worktree_dialog . as_mut ( ) {
2259- let outcome = match ev {
2260- Event :: Key ( key) if key. kind != crossterm:: event:: KeyEventKind :: Release => {
2261- dialog. handle_key ( key)
2262- }
2263- Event :: Paste ( text) => dialog. insert_paste ( text) ,
2264- Event :: Resize ( _, _) => return InputOutcome :: Changed ,
2265- _ => NewWorktreeDialogOutcome :: Unchanged ,
2266- } ;
2267- match outcome {
2268- NewWorktreeDialogOutcome :: Submitted ( label) => {
2269- * ctx. new_worktree_dialog = None ;
2270- return InputOutcome :: Action ( Action :: NewWorktreeSession {
2271- load_session_id : None ,
2272- label,
2273- git_ref : None ,
2274- } ) ;
2275- }
2276- NewWorktreeDialogOutcome :: Cancelled => {
2277- * ctx. new_worktree_dialog = None ;
2278- return InputOutcome :: Changed ;
2279- }
2280- NewWorktreeDialogOutcome :: Changed => return InputOutcome :: Changed ,
2281- NewWorktreeDialogOutcome :: Unchanged => return InputOutcome :: Unchanged ,
2282- }
2283- }
22842160 if matches ! ( ctx. auth_state, AuthState :: Done )
22852161 && ctx. has_access
22862162 && !ctx. is_zdr_blocked
@@ -2373,22 +2249,6 @@ fn handle_welcome_input(ev: &Event, ctx: &mut WelcomeInputCtx<'_>) -> InputOutco
23732249 {
23742250 return InputOutcome :: Action ( Action :: Quit ) ;
23752251 }
2376- if let Some ( selection) = session_picker_worktree_selection (
2377- key,
2378- ctx. sp_state ,
2379- & entry_map,
2380- & non_selectable_flags,
2381- ctx. sp_entries . as_deref ( ) ,
2382- ) {
2383- return InputOutcome :: Action ( match selection {
2384- SessionPickerWorktreeSelection :: Fuzzy ( original_index) => {
2385- Action :: PickSessionInWorktree ( original_index)
2386- }
2387- SessionPickerWorktreeSelection :: Unavailable => {
2388- return InputOutcome :: Changed ;
2389- }
2390- } ) ;
2391- }
23922252 }
23932253 let selected_before = ctx. sp_state . selected ;
23942254 let outcome = handle_picker_input ( ev, ctx. sp_state , entry_count, & config) ;
@@ -2509,9 +2369,6 @@ fn handle_welcome_input(ev: &Event, ctx: &mut WelcomeInputCtx<'_>) -> InputOutco
25092369 return InputOutcome :: Action ( Action :: NewSession ) ;
25102370 }
25112371 if matches ! ( ctx. auth_state, AuthState :: Done ) {
2512- if key ! ( 'w' , CONTROL ) . matches ( key) && ctx. cwd_has_git_ancestor {
2513- return InputOutcome :: Action ( Action :: OpenNewWorktreeDialog ) ;
2514- }
25152372 if key ! ( F ( 3 ) ) . matches ( key) {
25162373 return InputOutcome :: Action ( Action :: FetchSessionList ) ;
25172374 }
@@ -2869,12 +2726,11 @@ fn dispatch_access_gate_menu_action(index: usize) -> InputOutcome {
28692726}
28702727/// Dispatch an action for a welcome menu item by index.
28712728///
2872- /// Menu order: New worktree, Resume session, Quit.
2729+ /// Menu order: Resume session, Quit.
28732730fn dispatch_menu_action ( index : usize ) -> InputOutcome {
28742731 match index {
2875- 0 => InputOutcome :: Action ( Action :: OpenNewWorktreeDialog ) ,
2876- 1 => InputOutcome :: Action ( Action :: FetchSessionList ) ,
2877- 2 => InputOutcome :: Action ( Action :: Quit ) ,
2732+ 0 => InputOutcome :: Action ( Action :: FetchSessionList ) ,
2733+ 1 => InputOutcome :: Action ( Action :: Quit ) ,
28782734 _ => InputOutcome :: Unchanged ,
28792735 }
28802736}
@@ -3226,13 +3082,6 @@ impl AppView {
32263082 self . welcome_announcement . truncated = result. announcement_truncated ;
32273083 self . welcome_announcement . rect = result. announcement_rect ;
32283084 self . session_picker_state . hit_areas = result. session_picker_hit_areas ;
3229- if let Some ( dialog) = self . new_worktree_dialog . as_ref ( ) {
3230- crate :: views:: new_worktree_dialog:: render_new_worktree_dialog (
3231- view_area,
3232- f. buffer_mut ( ) ,
3233- dialog,
3234- ) ;
3235- }
32363085 if let Some ( crate :: views:: modal:: ActiveModal :: DocViewer {
32373086 ref title,
32383087 ref content,
@@ -3496,12 +3345,9 @@ impl AppView {
34963345impl AppView {
34973346 /// True when any modal that should swallow scroll input is open.
34983347 fn is_scroll_blocking_modal_open ( & self ) -> bool {
3499- let cloud_modal_open = false ;
35003348 matches ! ( self . active_view, ActiveView :: Agent ( id) if self . agents. get( & id) . is_some_and( |a| a. active_modal. is_some( ) ) )
3501- || self . new_worktree_dialog . is_some ( )
35023349 || self . welcome_doc_viewer . is_some ( )
35033350 || self . tutorial . is_some ( )
3504- || cloud_modal_open
35053351 }
35063352 /// Store the resolved per-tip gates and propagate the prompt-relevant tips
35073353 /// (undo + plan nudge) to every agent's prompt. Reused by startup and the
0 commit comments