Skip to content

Stop AI-generated titles overwriting user-renamed session names#46

Merged
abasiri merged 1 commit into
doctly:mainfrom
HaydnG:fix/ai-title-clobbers-user-name
May 20, 2026
Merged

Stop AI-generated titles overwriting user-renamed session names#46
abasiri merged 1 commit into
doctly:mainfrom
HaydnG:fix/ai-title-clobbers-user-name

Conversation

@HaydnG

@HaydnG HaydnG commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • PR fix: pick up ai-title entries so session names display #42 collapsed `customTitle` and `aiTitle` into a single field returned by `readSessionFile` (`customTitle: customTitle || aiTitle`). `session-cache.js` then promotes `customTitle` into `session_meta.name` via `setName` — the same DB column that stores user renames done in the Switchboard UI. As a result, every re-index of a JSONL containing an `ai-title` entry overwrites the user's manual rename.
  • This PR separates the two title sources end-to-end so the user's manual rename column (`session_meta.name`) reverts to being user-only.
  • `Why not show the session name? #33`'s original goal (AI titles displayed in the sidebar instead of raw first prompts) is preserved via a new `session.aiTitle` field carried through the cache to the renderer.

Changes

  • `read-session-file.js` returns `customTitle` and `aiTitle` as separate fields.
  • `db.js` — `session_cache` gains an `aiTitle` column; v3 migration adds it and clears the cache so the next index repopulates.
  • `session-cache.js` plumbs `aiTitle` through to the API output. `setName` is only called with a JSONL `custom-title` — never with an AI title.
  • Display priority everywhere (`sidebar.js`, `app.js`, `dialogs.js`, `grid-view.js`, `jsonl-viewer.js`): `session.name` (user rename) → `session.aiTitle` → `session.summary`.

Test plan

  • Rename a session in the UI. Wait for re-index (or trigger one). Name persists.
  • Open a session that has an `ai-title` entry in its JSONL but no manual rename. Sidebar shows the AI title, not the raw first prompt.
  • Rename a session that previously displayed its AI title. The user rename takes over; another index pass does not overwrite it.
  • Search FTS still surfaces sessions by their AI title.
  • `npm test` passes.

Limitations

  • Pre-fix DB pollution (existing rows where an AI title was already written into `session_meta.name` before this fix) is not auto-cleaned. Those sessions will keep their AI-title-as-name until the user renames them manually. We do not store provenance on `session_meta.name`, so we can't safely distinguish AI-title pollution from genuine user renames retroactively.

Fixes regression introduced by #42 / #33.

PR doctly#42 (b88b19f) wired ai-title entries into the customTitle field returned
by readSessionFile via `customTitle: customTitle || aiTitle`. session-cache.js
then calls setName(sessionId, customTitle) on every index pass, which writes
to session_meta.name — the same column that stores user renames done via the
Switchboard UI (rename-session in main.js). So every re-index of a file that
contains an ai-title entry clobbers the user's manual rename.

The PR description claimed "User-set customTitle still takes precedence", but
that only holds for JSONL custom-title entries (Claude `/title`), not for
in-app UI renames.

Fix: separate the two title sources end-to-end.

- read-session-file.js now returns customTitle and aiTitle as separate fields.
- session_cache table gains an aiTitle column; v3 migration adds the column
  and clears the cache so a fresh index repopulates it.
- session-cache.js carries aiTitle through to the API output. setName is now
  only ever called with a JSONL customTitle — ai-title never touches the DB.
- Sidebar/grid/dialog/jsonl-viewer display priority is now:
  user rename (session.name) > AI title (session.aiTitle) > raw first prompt.

doctly#33's original intent (AI titles displayed in the sidebar instead of raw
prompts) is preserved through session.aiTitle, but the DB session_meta.name
column reverts to being user-only — manual renames are now durable.

Note: pre-fix DB pollution (existing rows where ai-title was already
written into session_meta.name) is not auto-cleaned — those sessions
will keep their AI-title-as-name until renamed manually.
@HaydnG HaydnG marked this pull request as ready for review May 19, 2026 08:29
@abasiri abasiri merged commit b98c2f8 into doctly:main May 20, 2026
5 checks passed
aaaronmiller added a commit to aaaronmiller/switchboard that referenced this pull request May 30, 2026
Merge upstream changes from doctly/switchboard including:
- v0.0.27: WebGL terminal renderer
- v0.0.28: CI republish fixes
- v0.0.29: Sidebar duplicate fix, cursor blink reduction
- v0.0.30: Merge duplicate project groups, AI title support
- doctly#46: Stop AI titles overwriting user renames

Conflicts resolved:
- build.yml: Rewrote with proper release creation
- package.json: Keep fork version (0.0.34), upstream deps merged
- package-lock.json: Regenerated
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