Skip to content

fix(app): keep the unsent draft when New session is clicked in the inbox - #65518

Closed
hearnadam wants to merge 1 commit into
anomalyco:devfrom
hearnadam:inbox-draft-keep
Closed

hearnadam wants to merge 1 commit into
anomalyco:devfrom
hearnadam:inbox-draft-keep

Conversation

@hearnadam

@hearnadam hearnadam commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

In the Inbox layout the sidebar doesn't show drafts. If you click New session, type something, open an existing session and then click New session again, the app makes a brand-new empty draft. The earlier draft keeps its text, but nothing in the UI can open it again.

In the Inbox layout, openNewTab now opens the newest draft that still has text, an attachment or a context item before making a new one. Other layouts are unchanged, because drafts show as tabs there.

Known limit: the check only reads composer states already loaded in memory, so a draft saved in an earlier run and not opened since isn't found.

There's an alternative PR that shows drafts in the Inbox sidebar instead: #65525. Only one of the two should land.

How did you verify your code works?

  • tsc -b in packages/app
  • The repo's pre-push checks

I haven't run it in the app.

Screenshots / recordings

None (no visible UI change).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added contributor needs:compliance This means the issue will auto-close after 2 hours. labels Nov 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • No issue referenced. Please add Closes #<number> linking to the relevant issue.
  • Not all checklist items are checked. Please confirm you have tested locally and have not included unrelated changes.

Please edit this PR description to address the above within 72 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed by reading the code; not verified in a running app. The change only affects the web/desktop app's Inbox layout, which I couldn't drive here. tsc -b in packages/app passes, and the titlebar and tabs unit tests pass.

The public API is unchanged.

The approach is reasonable, but two behaviours need a look before merge (see inline comments):

  • The reused draft is picked from any server or project, so New session can jump away from the project you're working in.
  • While any draft has content, New session can no longer start an empty one. If you're already on that draft, the click does nothing.

The known limit (drafts restored from disk aren't detected) means some drafts can still end up out of reach. Showing drafts in the Inbox sidebar would avoid this whole class of problem. That's only a thought, not a request for this PR.

const openNewTab = () => {
const kept =
settings.appearance.tabLayout() === "inbox"
? tabsStore.findLast((tab) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This picks the newest draft with content from any server or project. openDraft places a new draft in the current session's or draft's server and directory (or the home selection). So clicking New session while viewing a session in project B can reopen a draft from project A on another server. Could the search be limited to drafts in the same server/directory that openDraft would use for the current route?

When a draft with content exists, this always selects it. If you're already on that draft, New session (button and tab.new) does nothing, and in the Inbox layout there's no other way to start a second, empty draft. Should this fall through to openDraft(uuid()) when kept is the current tab, or skip the current tab when searching?

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Nov 23, 2026
@hearnadam hearnadam closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant