Skip to content

fix(desktop): recover missing topic indexes#3228

Merged
esengine merged 4 commits into
main-v2from
codex/fix-topic-index-recovery
Jun 7, 2026
Merged

fix(desktop): recover missing topic indexes#3228
esengine merged 4 commits into
main-v2from
codex/fix-topic-index-recovery

Conversation

@SivanCola
Copy link
Copy Markdown
Collaborator

Summary

  • Recreate missing desktop topic title/project indexes from open tabs or session metadata when a topic is renamed.
  • Ensure tab controller startup keeps topic indexes present for restored sessions.
  • Keep stale topic rename failures from surfacing as a full-window unhandled rejection overlay.

Testing

  • cd desktop && go test ./...
  • cd desktop/frontend && pnpm typecheck (fails in this worktree because generated Wails wailsjs bindings are missing: ../../wailsjs/go/main/App and runtime imports)

@SivanCola SivanCola requested a review from esengine as a code owner June 5, 2026 09:14
@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 5, 2026
@SivanCola
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

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

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: 1a9dd63cf5

ℹ️ 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 desktop/tabs.go
Comment thread desktop/tabs.go Outdated
@SivanCola SivanCola force-pushed the codex/fix-topic-index-recovery branch from 6d92890 to fbdcf36 Compare June 7, 2026 03:46
@github-actions github-actions Bot added the desktop Wails desktop app (desktop/**) label Jun 7, 2026
@SivanCola
Copy link
Copy Markdown
Collaborator Author

Updated this PR after resolving the merge conflict with the latest main-v2.

What changed:

  • Rebased the branch onto current main-v2; GitHub now reports the PR as mergeable.
  • Preserved the topic index recovery fixes, including serialized index writes and global topic title-source preservation.
  • Added a small test wait so topic-tab startup goroutines finish before the next isolated test mutates desktop config state.

Verified:

  • cd desktop && go test ./... passed.
  • pnpm --dir desktop/frontend build passed after generating local Wails bindings. Vite still reports the existing onboarding CSS minify warning.

@SivanCola
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

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

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: fbdcf36ee5

ℹ️ 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 desktop/tabs.go
if path != "" {
a.persistTabSessionPath(tab, path)
if strings.TrimSpace(tab.TopicID) != "" {
if err := ensureTopicIndexed(tab.Scope, tab.WorkspaceRoot, tab.TopicID, tab.TopicTitle, loadTopicTitleSource(topicTitleRoot(tab.Scope, tab.WorkspaceRoot), tab.TopicID)); err == nil {
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 Recover title from session meta before writing defaults

When a persisted tab is restored after its topic title index was deleted, createTabEntryWithID synthesizes tab.TopicTitle as defaultTopicTitle; this new recovery path then indexes that synthetic title. Because persistTabSessionPath immediately above also saves tab.TopicTitle into the session metadata, the original BranchMeta.TopicTitle that could have repaired the index is overwritten before recovery, so users with an open saved tab lose the real topic title and the sidebar is restored as “新的会话” instead of the session's title.

Useful? React with 👍 / 👎.

Comment thread desktop/tabs.go
if topicID == "" {
return fmt.Errorf("topicID is required")
}
topicIndexMu.Lock()
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 Share the project-index lock with legacy migration

This lock only serializes ensureTopicIndexed calls, but migrateLegacySessionsIntoGlobalTopics uses a different mutex while doing the same load/modify/save of desktop-projects.json. During startup one restored tab can be repairing its topic index while another tab or ListProjectTree is migrating legacy sessions, so the later save can overwrite the earlier update and drop either recovered project topics or migrated global topics.

Useful? React with 👍 / 👎.

Comment thread desktop/tabs.go
}
for i, p := range f.Projects {
if p.Root == workspaceRoot {
f.Projects[i].Topics = prependUniqueString(p.Topics, topicID)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Avoid moving already-indexed topics during recovery

When this recovery path runs for an existing project topic, prependUniqueString rewrites the ordered topic list by moving that topic to the front. Because buildTabController now calls ensureTopicIndexed for every restored open tab, simply reopening the app can reorder the sidebar's saved topic order based on startup timing instead of only repairing genuinely missing entries.

Useful? React with 👍 / 👎.

Comment on lines +1225 to +1227
try {
await renameTopic(topicId, nextTitle);
} catch {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Surface non-stale rename failures

This catches every RenameTopic failure, not just the stale-topic case mentioned in the comment. If the backend fails to write the title or projects file because of permissions, disk space, or a config I/O error, the edit mode is dismissed and the draft is discarded without refreshing or telling the user that the rename did not persist.

Useful? React with 👍 / 👎.

@esengine esengine closed this Jun 7, 2026
@esengine esengine reopened this Jun 7, 2026
@esengine esengine merged commit 647fb09 into main-v2 Jun 7, 2026
19 checks passed
@esengine esengine deleted the codex/fix-topic-index-recovery branch June 7, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants