Skip to content

fix(sidebar): fix rename input and prevent auto-namer overwrite#6

Open
mike-meow wants to merge 8 commits into
MrVPlusOne:jiayifrom
mike-meow:fix/sidebar-rename-input
Open

fix(sidebar): fix rename input and prevent auto-namer overwrite#6
mike-meow wants to merge 8 commits into
MrVPlusOne:jiayifrom
mike-meow:fix/sidebar-rename-input

Conversation

@mike-meow
Copy link
Copy Markdown
Contributor

@mike-meow mike-meow commented Apr 25, 2026

Summary

Two related sidebar rename fixes:

  1. Double-click rename flashes away — The first click's handleSelectSession() scheduled focusComposer() via a double-requestAnimationFrame. By the time the rename input mounted, the delayed focusComposer stole focus → onBlur → confirm → edit mode exited. Fix: Added editingSessionIdRef and skip focusComposer when a rename is active.

  2. Space key commits rename — Pressing space in the rename <input> caused the keyup event to bubble to the parent <button>, which browsers treat as a click activation. Fix: Added onKeyUp handler with stopPropagation().

  3. Auto-namer overwrites manual renames — After manually renaming, the next user message triggered the auto-namer which could overwrite the name. Fix: Added a persisted userNamed flag in session-names.ts, set on PATCH rename, checked in auto-namer to skip.

Files changed

  • web/src/components/Sidebar.tsxeditingSessionIdRef + guard in focusComposer rAF
  • web/src/components/SessionItem.tsxonKeyUp stopPropagation on rename input
  • web/src/components/SessionItem.test.tsx — Updated blur test
  • web/server/session-names.tsuserNamed Set persistence
  • web/server/routes/sessions.ts — Set userNamed flag on PATCH rename
  • web/server/index.ts — Skip auto-namer for user-named sessions
  • web/server/session-namer.test.ts — Tests for userNamed flag

Testing

  • bun run typecheck
  • bun run test
  • bun run format:check
  • Manual verification: rename works, name persists after sending messages

Review provenance

  • Implemented by AI agent
  • Verified manually by human

🤖 Generated with Claude Code

Wenxu Mao and others added 2 commits April 28, 2026 14:10
…tting

Two bugs in sidebar session rename:

1. Double-click rename flashed away because onBlur fired before the
   useEffect could focus the input. Added a 200ms grace window after
   entering edit mode to ignore transient blur events.

2. Space key committed the rename because button keyup activation
   propagated from the input. Added onKeyUp stopPropagation on the
   rename input to prevent space from activating the parent button.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…and space key

Two fixes for sidebar rename bugs:

1. Double-click rename auto-committed immediately because the first click's
   handleSelectSession fired focusComposer via double-rAF, which stole focus
   from the rename input after it mounted, triggering onBlur → confirmRename.
   Fixed by tracking editingSessionId in a ref and skipping focusComposer
   when a rename is active.

2. Space key committed the rename because keyup bubbled to the parent <button>,
   which the browser interpreted as a button activation click. Fixed by adding
   onKeyUp stopPropagation on the rename input.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mike-meow mike-meow force-pushed the fix/sidebar-rename-input branch from 9b42a4a to a09264b Compare April 28, 2026 21:11
Wenxu Mao and others added 2 commits April 28, 2026 15:49
…med sessions

Add a persisted `userNamed` set to session-names store. When a user renames
a session via PATCH /sessions/:id/name, the session is flagged as user-named.
The auto-namer skips sessions with this flag, preserving manual renames.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
removeName() now also clears the userNamed flag, preventing stale entries
from leaking into the persisted Set when sessions are deleted/archived.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mike-meow mike-meow changed the title fix(sidebar): prevent rename input from losing focus on double-click and space key fix(sidebar): fix rename input and prevent auto-namer overwrite Apr 28, 2026
Wenxu Mao and others added 4 commits April 28, 2026 16:09
The coverage gate runs on Node (not Bun), so Bun.write is undefined.
Use writeFile from node:fs/promises instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The image thumb route uses Bun.file() internally, so tests that hit
the actual route handler only work on Bun. Skip the describe block
when Bun is not available (Node-based CI runners).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MrVPlusOne MrVPlusOne changed the base branch from main to jiayi May 5, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants