claude-code - 💡(How to fix) Fix Desktop sidebar ignores UserPromptSubmit hook `sessionTitle` output [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55951Fetched 2026-05-05 06:02:04
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×4commented ×2cross-referenced ×1

The documented hookSpecificOutput.sessionTitle from UserPromptSubmit hooks (added in v2.1.94) is honored by the CLI but not by the desktop app's sidebar. The desktop displays its own auto-generated title and ignores the hook output.

Root Cause

Manual /rename works because it sets titleSource: \"user\", so the field is honored when set through the UI's own path.

Fix Action

Fix / Workaround

Workaround attempted (and why it's not viable)

Patching local_*.json directly to titleSource: \"user\" works briefly but the desktop overwrites it on session-close/app-close — disk state at next app start is what wins, and the in-memory state is what writes last. So patches don't survive a close/reopen reliably without a constantly-running watcher daemon.

Code Example

{
     "hooks": {
       "UserPromptSubmit": [
         { "hooks": [ { "type": "command", "command": "/path/to/hook.sh" } ] }
       ]
     }
   }

---

{
     "hookSpecificOutput": {
       "hookEventName": "UserPromptSubmit",
       "sessionTitle": "[ProjectA] Test Title"
     }
   }
RAW_BUFFERClick to expand / collapse

Summary

The documented hookSpecificOutput.sessionTitle from UserPromptSubmit hooks (added in v2.1.94) is honored by the CLI but not by the desktop app's sidebar. The desktop displays its own auto-generated title and ignores the hook output.

Environment

  • Claude Code 2.1.121 (desktop)
  • macOS 14.x

Repro

  1. Add a UserPromptSubmit hook in ~/.claude/settings.json:
    {
      "hooks": {
        "UserPromptSubmit": [
          { "hooks": [ { "type": "command", "command": "/path/to/hook.sh" } ] }
        ]
      }
    }
  2. Have the hook return:
    {
      "hookSpecificOutput": {
        "hookEventName": "UserPromptSubmit",
        "sessionTitle": "[ProjectA] Test Title"
      }
    }
  3. Submit a first prompt in a desktop session.

Expected

Sidebar entry shows [ProjectA] Test Title.

Actual

  • ~/.claude/sessions/<pid>.json.name = \"[ProjectA] Test Title\"
  • Session .jsonl transcript → custom-title records contain \"[ProjectA] Test Title\"
  • ~/Library/Application Support/Claude/claude-code-sessions/.../local_*.jsontitle = \"<auto-generated summary>\", titleSource = \"auto\"

The desktop sidebar reads from the local_*.json file. The hook output never reaches it.

Manual /rename works because it sets titleSource: \"user\", so the field is honored when set through the UI's own path.

Workaround attempted (and why it's not viable)

Patching local_*.json directly to titleSource: \"user\" works briefly but the desktop overwrites it on session-close/app-close — disk state at next app start is what wins, and the in-memory state is what writes last. So patches don't survive a close/reopen reliably without a constantly-running watcher daemon.

Ask

Have the desktop sidebar honor hookSpecificOutput.sessionTitle from UserPromptSubmit hooks — same effect as /rename (i.e. set titleSource: \"user\" in local_*.json and invalidate the in-memory cache).

Use case

Auto-formatting session titles per-project (e.g. [ProjectA] …, [ProjectB] …) for users who work across multiple repos and view sessions in date-sorted mode rather than project mode.

extent analysis

TL;DR

Modify the desktop app to honor hookSpecificOutput.sessionTitle from UserPromptSubmit hooks by setting titleSource to "user" in local_*.json and invalidating the in-memory cache.

Guidance

  • Investigate the desktop app's code to find where it reads from local_*.json and overwrites the title field, to understand why the hook output is ignored.
  • Consider adding a feature to the desktop app to listen for UserPromptSubmit hooks and update the title field in local_*.json accordingly.
  • Look into the /rename command's implementation to see how it sets titleSource to "user" and apply a similar approach for UserPromptSubmit hooks.
  • Evaluate the feasibility of implementing a watcher daemon to patch local_*.json files, despite the current workaround's limitations.

Example

No code snippet is provided as the issue lacks specific implementation details.

Notes

The solution may require modifications to the desktop app's codebase, which could involve significant development and testing efforts. The current workaround's limitations, such as the need for a constantly-running watcher daemon, should be carefully considered.

Recommendation

Apply a workaround by modifying the desktop app to honor hookSpecificOutput.sessionTitle from UserPromptSubmit hooks, as this would provide the desired functionality without requiring significant changes to the underlying infrastructure.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING