Skip to content

Keep Agent Mode session titles consistent across tabs and history - #3380

Open
logancyang wants to merge 4 commits into
masterfrom
codex/3378-session-titles
Open

logancyang wants to merge 4 commits into
masterfrom
codex/3378-session-titles

Conversation

@logancyang

@logancyang logancyang commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Relates to #3378

Why

A user can rename an Agent Mode tab, then open Recent Chats or the previous-sessions list and still see the first prompt instead. Saved chat notes kept the tab label and history title in different fields, so finding a named workflow meant reopening chats one by one.

What

Before: Rename a saved session in its tab; history can keep the original prompt title. Rename it in history; its reopened tab can keep the older label.

After: Both views show the latest user-assigned title, including after reopening the chat. Clearing a title restores the filename fallback.

Existing chats use their saved history title, then their saved tab label, then the filename. Native-only sessions continue to use their local session index.

Non goal

  • Generate AI-written titles.
  • Rename saved Markdown files or the coding agent's own session store.

Screenshot

No screenshot is attached because the dedicated dev vault displays unrelated note content beside Agent Chat. The live UI checks and saved-note inspection are recorded below.

Risk

High — this changes writes to saved chat notes and serializes a rename with an in-flight autosave. The existing frontmatter fields remain compatible with older chats, but a revert cannot undo a title the user changed while running this version.

Criterion Status Reason
No behavior change, or a cosmetic/copy/docs/config change visible where it renders, or deterministic tests cover the changed behavior ✅ Regression tests cover both rename orders, reload precedence, stale metadata, hidden folders, clearing, and overlapping save and rename.
A defect would fail CI or be obvious on first use ✅ The title cases run in CI; a wrong visible title appears on opening history or the tab.
A revert fully restores prior state, including persisted data ❌ User renames write existing note frontmatter; reverting code does not undo a renamed note.
No auth, permissions, secrets, or input-handling surface changes ✅ Rename input and permissions are unchanged.
No public API, plugin API, message, or on-disk contract changes ✅ Existing topic and agentLabel fields are reused; no schema or external interface changes.
No core-path concurrency, async-lifecycle, or state-machine changes ❌ Saved-note rename and autosave writes now execute in order per note.
No hot-path behavior lacks deterministic coverage ✅ Saved and native title resolution and the write overlap have deterministic regression tests.
No new dependency ✅ Dependency manifests are unchanged.
Human-only behavior stays in one feature area and surfaces quickly ✅ The changed result is the Agent Mode tab and history title on the next open.

Review: inspect AgentChatPersistenceManager.saveSession(), updateTopic(), and readExistingMeta() in src/agentMode/session/AgentChatPersistenceManager.ts, then AgentSessionManager.getChatHistoryItems(), updateChatTitle(), readSessionRefFromFile(), and renameSession() in src/agentMode/session/AgentSessionManager.ts. Run Verification steps 1–4, including the clear-title and overlapping-save cases.

Verification

  1. In a disposable Obsidian vault, create an Agent Mode chat, send a prompt, rename its tab, and confirm Recent Chats and Chat History show the new name without opening the chat.
  2. Save that chat as a Markdown note, rename it from history, reopen it, and confirm the tab uses the new name. Rename the tab again and confirm the list follows. Restart Obsidian and check both names again.
  3. Repeat with chat autosave off and a configured hidden conversations folder. Clear a saved title and confirm history falls back to its filename instead of the old name.
  4. Rename a saved chat while it is autosaving, then reopen it; the most recent user name should remain. Check an older chat with no saved label still has its prior fallback title.

Observed in Obsidian (logan-dev-vault): The built plugin was loaded and its new title code was confirmed at runtime. Renaming an existing Claude session tab changed Chat History and Recent Chats; opening it from Recent Chats kept the title. On a saved Markdown chat, a later tab rename updated the note’s agentLabel and Recent Chats. The saved title remained after disabling and re-enabling the plugin. I restored the test chat’s original title afterward. One immediate rename during the first manual save exposed a race; a deterministic red/green regression test now covers the reconciliation. The other edge cases in steps 3–4 are covered by unit tests, not a live UI run. Obsidian reported no captured errors.

@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
obsidian-copilot-docs Ignored Ignored Sep 28, 2026 6:04am UTC

Request Review

@logancyang

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T06:11:48.913953Z 36faf3f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c450f1d222

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agentMode/session/AgentChatPersistenceManager.ts
@logancyang
logancyang marked this pull request as ready for review September 27, 2026 01:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e65c4d8c4f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agentMode/session/AgentChatPersistenceManager.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5ea6096df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3172 to +3173
if (loaded.topic) session.setLabel(loaded.topic);
else if (loaded.label) session.setLabel(loaded.label);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the filename fallback when restoring a cleared title

When a saved title is cleared, both topic and agentLabel are blank, so neither branch sets a session label when the note is reopened. The history row now falls back to the note filename, but the tab falls back to the backend display name (for example, “opencode”), leaving the two views inconsistent in the exact clear-and-reopen flow this change supports. Restore the same filename-derived title here when both persisted fields are absent.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36faf3f3f0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3172 to +3173
if (loaded.topic) session.setLabel(loaded.topic);
else if (loaded.label) session.setLabel(loaded.label);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve later legacy tab renames on reopen

For an existing note renamed first in history and later from its tab, the persisted fields legitimately differ: topic contains the older history name while agentLabel contains the newer tab name. This branch now always restores topic, and the ensuing autosave writes that stale value back into agentLabel, permanently discarding the user's latest rename. Existing conflicting records need migration or ordering metadata rather than assuming topic is newer.

AGENTS.md reference: AGENTS.md:L85-L90

Useful? React with 👍 / 👎.

Comment on lines +3172 to +3173
if (loaded.topic) session.setLabel(loaded.topic);
else if (loaded.label) session.setLabel(loaded.label);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse the reopened topic before preferring it

When an existing note uses valid YAML such as topic: >- with indented title lines, loadFile() still obtains loaded.topic from the line-based splitFrontmatter() parser, so this new preference sets the tab label to the literal >- instead of the folded title. Although the autosave metadata path now uses parseYaml, the fresh reopen path does not; parse the loaded frontmatter with the same full YAML parser before choosing topic.

AGENTS.md reference: AGENTS.md:L85-L90

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant