@@ -197,7 +197,7 @@ class BearingApp(App):
197197 """Bearing worktree management TUI."""
198198
199199 CSS_PATH = "styles/app.tcss"
200- TITLE = "⚓ Bearing [dev-check] "
200+ TITLE = "⚓ Bearing "
201201
202202 BINDINGS = [
203203 Binding ("q" , "quit" , "Quit" ),
@@ -210,8 +210,8 @@ class BearingApp(App):
210210 Binding ("d" , "daemon" , "Daemon" ),
211211 Binding ("o" , "open_item" , "Open" , show = False ),
212212 # View switching
213- Binding ("w" , "switch_to_worktrees" , "Worktrees" , show = False ),
214- Binding ("p" , "switch_to_plans" , "Plans" , show = False ),
213+ Binding ("w" , "switch_to_worktrees" , "Work" ),
214+ Binding ("p" , "switch_to_plans" , "Plans" ),
215215 # Panel navigation by number (0-indexed)
216216 Binding ("0" , "focus_panel_0" , "Projects" , show = False ),
217217 Binding ("1" , "focus_panel_1" , "Main" , show = False ),
@@ -246,104 +246,84 @@ def __init__(self, workspace: Path | None = None):
246246
247247 def compose (self ) -> ComposeResult :
248248 """Create the app layout."""
249- yield Static ("\u2693 Bearing [dev-check] " , id = "title" )
249+ yield Static ("⚓ Bearing - Work " , id = "title" )
250250 with Horizontal (id = "main-container" ):
251251 with Vertical (id = "projects-panel" ):
252- yield Label ("[0] Projects [dev-check] " , classes = "panel-header" )
252+ yield Label ("[0] Projects " , classes = "panel-header" )
253253 yield ProjectList (id = "project-list" )
254254 with Vertical (id = "main-panel" ):
255- yield Label ("[1] Worktrees [dev-check] " , classes = "panel-header" , id = "main-panel-header" )
255+ yield Label ("[1] Worktrees " , classes = "panel-header" , id = "main-panel-header" )
256256 yield WorktreeTable (id = "worktree-table" )
257257 yield PlansTable (id = "plans-table" )
258258 yield Label ("[2] Details" , classes = "panel-header details-header" )
259259 yield DetailsPanel (id = "details-panel" )
260- yield Static (self ._get_footer_text (), id = "footer-bar" )
261-
262- def _get_footer_text (self ) -> str :
263- """Get footer text with current mode highlighted."""
264- if self ._view_mode == ViewMode .WORKTREES :
265- mode_text = "[bold cyan][w]orktrees[/] [dim][p]lans[/]"
266- else :
267- mode_text = "[dim][w]orktrees[/] [bold cyan][p]lans[/]"
268- return (
269- f"{ mode_text } "
270- "[yellow]j/k[/] nav "
271- "[yellow]o[/]pen "
272- "[yellow]r[/]efresh "
273- "[yellow]R[/] PRs "
274- "[yellow]p[/]lans "
275- "[yellow]?[/] help "
276- "[yellow]q[/]uit"
277- )
278-
279- def _update_footer (self ) -> None :
280- """Update footer with current mode."""
281- footer = self .query_one ("#footer-bar" , Static )
282- footer .update (self ._get_footer_text ())
260+ yield Footer ()
283261
284262 def _update_view (self ) -> None :
285263 """Update UI for current view mode."""
286264 worktree_table = self .query_one ("#worktree-table" , WorktreeTable )
287265 plans_table = self .query_one ("#plans-table" , PlansTable )
288266 header = self .query_one ("#main-panel-header" , Label )
267+ title = self .query_one ("#title" , Static )
289268
290269 if self ._view_mode == ViewMode .WORKTREES :
270+ title .update ("⚓ Bearing - Work" )
291271 worktree_table .display = True
292272 plans_table .display = False
293273 header .update ("[1] Worktrees" )
294274 self ._panel_order = ["project-list" , "worktree-table" , "details-panel" ]
295275 else :
276+ title .update ("⚓ Bearing - Plans" )
296277 worktree_table .display = False
297278 plans_table .display = True
298279 header .update ("[1] Plans" )
299280 self ._panel_order = ["project-list" , "plans-table" , "details-panel" ]
300281
301- self ._update_footer ()
302-
303282 # Update project list for current view
304283 if self ._view_mode == ViewMode .WORKTREES :
305284 self ._refresh_worktrees_view ()
306285 else :
307286 self ._refresh_plans_view ()
308287
309288 def _refresh_worktrees_view (self ) -> None :
310- """Refresh project list with worktree counts."""
289+ """Refresh project list with worktree counts, preserving selection ."""
311290 projects = self .state .get_projects ()
312291 local_entries = self .state .read_local ()
313292 counts : dict [str , int ] = {}
314293 for entry in local_entries :
315294 counts [entry .repo ] = counts .get (entry .repo , 0 ) + 1
316295 project_list = self .query_one (ProjectList )
317- project_list .set_projects (projects , counts )
296+ project_list .set_projects (projects , counts , preserve_selection = self . _current_project )
318297
319298 def _refresh_plans_view (self ) -> None :
320- """Refresh project list with plan counts."""
321- # Get projects that have plans
299+ """Refresh project list with plan counts, preserving selection."""
322300 plan_projects = self .state .get_plan_projects ()
323301 counts : dict [str , int ] = {}
324302 for project in plan_projects :
325303 plans = self .state .get_plans_for_project (project )
326304 counts [project ] = len (plans )
327305 project_list = self .query_one (ProjectList )
328- project_list .set_projects (plan_projects , counts )
306+ project_list .set_projects (plan_projects , counts , preserve_selection = self . _current_project )
329307
330308 def action_switch_to_worktrees (self ) -> None :
331309 """Switch to worktrees view."""
332310 if self ._view_mode != ViewMode .WORKTREES :
333311 self ._view_mode = ViewMode .WORKTREES
334312 self ._update_view ()
335- # If project selected, load its worktrees
313+ # If project selected, load its worktrees and focus panel 1
336314 if self ._current_project :
337315 self ._update_worktree_table (self ._current_project )
316+ self .query_one (WorktreeTable ).focus ()
338317
339318 def action_switch_to_plans (self ) -> None :
340319 """Switch to plans view."""
341320 if self ._view_mode != ViewMode .PLANS :
342321 self ._view_mode = ViewMode .PLANS
343322 self ._update_view ()
344- # If project selected, load its plans
323+ # If project selected, load its plans and focus panel 1
345324 if self ._current_project :
346325 self ._update_plans_table (self ._current_project )
326+ self .query_one (PlansTable ).focus ()
347327
348328 @property
349329 def _session_file (self ) -> Path :
@@ -482,16 +462,18 @@ def action_show_prs(self) -> None:
482462 self .push_screen (PRsScreen (self .workspace , self .state ))
483463
484464 def action_refresh (self ) -> None :
485- """Refresh data for current view."""
465+ """Refresh data for current view, preserving selection."""
466+ saved_project = self ._current_project
467+
486468 if self ._view_mode == ViewMode .WORKTREES :
487469 self ._refresh_worktrees_view ()
488- self .query_one (WorktreeTable ).clear_worktrees ()
470+ if saved_project :
471+ self ._update_worktree_table (saved_project )
489472 else :
490473 self ._refresh_plans_view ()
491- self .query_one (PlansTable ).clear_plans ()
474+ if saved_project :
475+ self ._update_plans_table (saved_project )
492476
493- self .query_one (DetailsPanel ).clear ()
494- self ._current_project = None
495477 self .notify ("Data refreshed" , timeout = 2 )
496478
497479 def action_focus_panel_0 (self ) -> None :
@@ -546,8 +528,10 @@ def on_project_list_project_selected(self, event: ProjectList.ProjectSelected) -
546528 self ._current_project = event .project
547529 if self ._view_mode == ViewMode .WORKTREES :
548530 self ._update_worktree_table (event .project )
531+ self .query_one (WorktreeTable ).focus ()
549532 else :
550533 self ._update_plans_table (event .project )
534+ self .query_one (PlansTable ).focus ()
551535
552536 def _update_worktree_table (self , project : str ) -> None :
553537 """Update worktree table for selected project."""
0 commit comments