Skip to content

Commit bbd2618

Browse files
committed
fix(09): stay on NewSession screen when advancing from name entry
1 parent 07f4d2c commit bbd2618

File tree

5 files changed

+194
-13
lines changed

5 files changed

+194
-13
lines changed

.planning/ROADMAP.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ None
2222
- [x] **Phase 6: Help Text Layout** - Two-row help text with logical grouping
2323
- [x] **Phase 7: Fix Session Naming Bug** - Fix session naming bug
2424
- [x] **Phase 8: Resurrectable Session Improvements** - Improve resurrectable session handling and display
25+
- [x] **Phase 9: Fix Session Name Editing** - Fix session name editing during session creation
2526

2627
## Phase Details
2728

@@ -98,10 +99,19 @@ Plans:
9899
Plans:
99100
- [x] 08-01: Add Alt+D toggle for resurrectable sessions with pink coloring
100101

102+
### Phase 9: Fix Session Name Editing
103+
**Goal**: Fix session name editing during session creation so users can modify the auto-generated name
104+
**Depends on**: Phase 8
105+
**Research**: Complete (Enter from name entry returns to Main instead of showing layout selection)
106+
**Plans**: 1
107+
108+
Plans:
109+
- [x] 09-01: Fix NewSession Enter key after name editing
110+
101111
## Progress
102112

103113
**Execution Order:**
104-
Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8
114+
Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9
105115

106116
| Phase | Plans Complete | Status | Completed |
107117
|-------|----------------|--------|-----------|
@@ -113,3 +123,4 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8
113123
| 6. Help Text Layout | 1/1 | Complete | 2026-01-13 |
114124
| 7. Fix Session Naming Bug | 1/1 | Complete | 2026-01-13 |
115125
| 8. Resurrectable Session Improvements | 1/1 | Complete | 2026-01-14 |
126+
| 9. Fix Session Name Editing | 1/1 | Complete | 2026-01-15 |

.planning/STATE.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
See: .planning/PROJECT.md (updated 2026-01-13)
66

77
**Core value:** The session selector should feel instant and intuitive — MRU ordering, clean visual hierarchy, and responsive feedback.
8-
**Current focus:** Phase 8 — Resurrectable Session Improvements (complete)
8+
**Current focus:** Milestone complete - all 9 phases finished
99

1010
## Current Position
1111

12-
Phase: 8 of 8 (Resurrectable Session Improvements)
12+
Phase: 9 of 9 (Fix Session Name Editing)
1313
Plan: 1 of 1 in current phase
14-
Status: Phase complete
15-
Last activity: 2026-01-14 — Completed 08-01-PLAN.md
14+
Status: Complete
15+
Last activity: 2026-01-15 — Completed 09-01-PLAN.md
1616

17-
Progress: ██████████ 100% (8/8 phases)
17+
Progress: ██████████ 100% (9/9 phases)
1818

1919
## Performance Metrics
2020

2121
**Velocity:**
22-
- Total plans completed: 9
22+
- Total plans completed: 10
2323
- Average duration: 7 min
24-
- Total execution time: 61 min
24+
- Total execution time: 66 min
2525

2626
**By Phase:**
2727

@@ -35,9 +35,10 @@ Progress: ██████████ 100% (8/8 phases)
3535
| 06 | 1 | 5 min | 5 min |
3636
| 07 | 1 | 6 min | 6 min |
3737
| 08 | 1 | 5 min | 5 min |
38+
| 09 | 1 | 5 min | 5 min |
3839

3940
**Recent Trend:**
40-
- Last 3 plans: 06-01 (5 min), 07-01 (6 min), 08-01 (5 min)
41+
- Last 3 plans: 07-01 (6 min), 08-01 (5 min), 09-01 (5 min)
4142
- Trend: Stable
4243

4344
## Accumulated Context
@@ -63,6 +64,7 @@ Recent decisions affecting current work:
6364
| 07-01 | Pre-fill rename buffer with current session name | Enables easy editing vs starting from scratch |
6465
| 07-01 | Shorten help text items for Ctrl+n | "Quick create" -> "Quick", "Delete" -> "Del" |
6566
| 08-01 | Runtime toggle over config option for dead sessions | Ephemeral UI state doesn't need config persistence |
67+
| 09-01 | Check state before handle_selection() | Captures pre-transition state for correct navigation logic |
6668

6769
### Deferred Issues
6870

@@ -72,13 +74,14 @@ None yet.
7274

7375
- Phase 7 added: Fix session naming bug
7476
- Phase 8 added: Resurrectable session improvements
77+
- Phase 9 added: Fix session name editing during session creation
7578

7679
### Blockers/Concerns
7780

7881
None yet.
7982

8083
## Session Continuity
8184

82-
Last session: 2026-01-14
83-
Stopped at: Completed 08-01-PLAN.md (Alt+D toggle for resurrectable sessions)
85+
Last session: 2026-01-15
86+
Stopped at: Milestone complete - all 9 phases finished
8487
Resume file: None
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Plan 09-01: Fix NewSession Enter Key After Name Editing
2+
3+
## Problem
4+
5+
When creating a new session:
6+
1. User selects a directory → enters NewSession screen in `EnteringLayoutSearch` state
7+
2. User presses Esc to go back and edit the name → now in `EnteringName` state
8+
3. User edits the name (e.g., "vaultsync_templates")
9+
4. User presses Enter → **immediately returns to Main screen without creating session**
10+
11+
**Root cause:** In `handle_new_session_key()`, pressing Enter always sets `active_screen = Main` after calling `handle_selection()`, even when `handle_selection()` just advances from `EnteringName` to `EnteringLayoutSearch` (doesn't create the session yet).
12+
13+
```rust
14+
BareKey::Enter if key.has_no_modifiers() => {
15+
self.new_session_info.handle_selection(&self.current_session_name);
16+
self.active_screen = ActiveScreen::Main; // BUG: Always goes to Main!
17+
true
18+
}
19+
```
20+
21+
In `handle_selection()`:
22+
- `EnteringName` → just advances to `EnteringLayoutSearch` (no session created)
23+
- `EnteringLayoutSearch` → creates session, calls `hide_self()`
24+
25+
## Solution
26+
27+
Only set `active_screen = Main` when the user was already in `EnteringLayoutSearch` (meaning `handle_selection()` created the session). If user was in `EnteringName`, stay on NewSession screen to show layout selection.
28+
29+
## Changes
30+
31+
### `src/state.rs` - Fix Enter handler in `handle_new_session_key()`
32+
33+
**Location:** Lines 420-426
34+
35+
**Current code:**
36+
```rust
37+
BareKey::Enter if key.has_no_modifiers() => {
38+
// Handle session creation
39+
self.new_session_info
40+
.handle_selection(&self.current_session_name);
41+
self.active_screen = ActiveScreen::Main;
42+
true
43+
}
44+
```
45+
46+
**New code:**
47+
```rust
48+
BareKey::Enter if key.has_no_modifiers() => {
49+
// Only return to Main if we were in layout selection (session created)
50+
// If in name entry, handle_selection just advances to layout selection
51+
let was_in_layout_selection = self.new_session_info.entering_layout_search_term();
52+
self.new_session_info
53+
.handle_selection(&self.current_session_name);
54+
if was_in_layout_selection {
55+
self.active_screen = ActiveScreen::Main;
56+
}
57+
true
58+
}
59+
```
60+
61+
## Validation
62+
63+
1. Build: `cargo build --target wasm32-wasip1`
64+
2. Test manually:
65+
- Select a directory from main list
66+
- Press Esc to go back to name entry
67+
- Edit the session name
68+
- Press Enter → should show layout selection (not return to main)
69+
- Press Enter again → should create session
70+
71+
## Files Changed
72+
73+
- `src/state.rs` - Fix Enter handler in `handle_new_session_key()`
74+
75+
## Estimated Complexity
76+
77+
Trivial - single conditional check.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
phase: 09-fix-session-name-editing
3+
plan: 01
4+
subsystem: ui
5+
tags: [state-machine, new-session, keybinding]
6+
7+
# Dependency graph
8+
requires:
9+
- phase: 08-resurrectable-session-improvements
10+
provides: Resurrectable session handling complete
11+
provides:
12+
- Fixed NewSession Enter key state machine flow
13+
- Session name editing now works correctly
14+
affects: []
15+
16+
# Tech tracking
17+
tech-stack:
18+
added: []
19+
patterns:
20+
- "Check state before calling handler, use result to determine next screen"
21+
22+
key-files:
23+
created: []
24+
modified:
25+
- src/state.rs
26+
27+
key-decisions:
28+
- "Check entering_layout_search_term() before handle_selection() to determine correct navigation"
29+
30+
patterns-established:
31+
- "State machine transitions should be determined by pre-call state, not post-call state"
32+
33+
# Metrics
34+
duration: 5 min
35+
completed: 2026-01-15
36+
---
37+
38+
# Phase 9 Plan 01: Fix NewSession Enter Key After Name Editing Summary
39+
40+
**Fixed Enter key state machine in NewSession screen so editing session name then pressing Enter advances to layout selection instead of returning to Main**
41+
42+
## Performance
43+
44+
- **Duration:** 5 min
45+
- **Started:** 2026-01-15
46+
- **Completed:** 2026-01-15
47+
- **Tasks:** 1
48+
- **Files modified:** 1
49+
50+
## Accomplishments
51+
- Fixed Enter key handler to check state before calling `handle_selection()`
52+
- Session name editing now correctly advances to layout selection on Enter
53+
- Only returns to Main screen when layout selection completes (session created)
54+
55+
## Task Commits
56+
57+
Each task was committed atomically:
58+
59+
1. **Task 1: Fix Enter handler** - `8a82e56` (fix)
60+
61+
## Files Created/Modified
62+
- `src/state.rs` - Added state check before `handle_selection()`, conditional screen transition
63+
64+
## Decisions Made
65+
- Check `entering_layout_search_term()` before calling `handle_selection()` rather than after - this captures the pre-transition state needed for correct navigation logic
66+
67+
## Deviations from Plan
68+
69+
None - plan executed exactly as written.
70+
71+
## Issues Encountered
72+
73+
None
74+
75+
## User Setup Required
76+
77+
None - no external service configuration required.
78+
79+
## Next Phase Readiness
80+
- This was the final plan in Phase 9
81+
- Phase 9 complete - all session name editing bugs fixed
82+
- Milestone complete - all 9 phases finished
83+
84+
---
85+
*Phase: 09-fix-session-name-editing*
86+
*Completed: 2026-01-15*

src/state.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,14 @@ impl PluginState {
418418
fn handle_new_session_key(&mut self, key: KeyWithModifier) -> bool {
419419
match key.bare_key {
420420
BareKey::Enter if key.has_no_modifiers() => {
421-
// Handle session creation
421+
// Only return to Main if we were in layout selection (session created)
422+
// If in name entry, handle_selection just advances to layout selection
423+
let was_in_layout_selection = self.new_session_info.entering_layout_search_term();
422424
self.new_session_info
423425
.handle_selection(&self.current_session_name);
424-
self.active_screen = ActiveScreen::Main;
426+
if was_in_layout_selection {
427+
self.active_screen = ActiveScreen::Main;
428+
}
425429
true
426430
}
427431
BareKey::Enter if key.has_modifiers(&[KeyModifier::Ctrl]) => {

0 commit comments

Comments
 (0)