Skip to content

fix: preserve fallback title after stopping generation#515

Merged
chenyme merged 1 commit into
devfrom
title
Jul 20, 2026
Merged

fix: preserve fallback title after stopping generation#515
chenyme merged 1 commit into
devfrom
title

Conversation

@chenyme

@chenyme chenyme commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix conversations reverting to the default “New Chat” title after the user manually stops the first model response.

The fallback title was previously persisted only by the post-billing metadata workflow. Explicit cancellation can bypass that workflow even though the first user message has already been saved.

This change:

  • Settles the fallback title as part of canceled generation finalization.
  • Uses the first user message, limited to the existing 16-character rule.
  • Runs only for explicit generation cancellation.
  • Preserves the existing successful generation and metadata workflow.
  • Does not affect ordinary upstream errors or routing failures.
  • Uses the repository’s conditional update to avoid overwriting manual or generated titles.
  • Does not invoke an auxiliary model or consume additional tokens.

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • cd backend && go test ./internal/application/conversation ./internal/infra/persistence/postgres/conversation
  • gofmt applied to changed Go files.
  • git diff --check HEAD

Screenshots, API examples, or logs

Reproduction verified through the cancellation settlement path:

  1. Disable automatic title generation.
  2. Send the first message in a new conversation.
  3. Stop model generation.
  4. Refresh the page.
  5. The conversation retains the first-message fallback title instead of reverting to “New Chat”.

Configuration, migration, and compatibility notes

No configuration, API contract, Swagger, or database migration changes are required.

Automatic title generation remains unchanged. When enabled, successful generations continue using the existing post-billing metadata workflow.

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local config, or personal data are included.
  • Conversation updates remain scoped to the existing conversation ownership context.
  • Conditional title updates prevent overwriting manually managed titles.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior is documented in this PR.
  • No generated artifacts are required for this change.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme self-assigned this Jul 20, 2026
@chenyme chenyme linked an issue Jul 20, 2026 that may be closed by this pull request
3 tasks
@chenyme
chenyme merged commit 6f2416d into dev Jul 20, 2026
11 checks passed
@chenyme
chenyme deleted the title branch July 20, 2026 03:13
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.

[Bug]: 模型输出时终止会导致标题变为新对话

1 participant