Skip to content

fix(deepseek): fix history titles and resume conversation on ask#1153

Merged
jackwener merged 3 commits intojackwener:mainfrom
Benjamin-eecs:fix/deepseek-history-resume
Apr 23, 2026
Merged

fix(deepseek): fix history titles and resume conversation on ask#1153
jackwener merged 3 commits intojackwener:mainfrom
Benjamin-eecs:fix/deepseek-history-resume

Conversation

@Benjamin-eecs
Copy link
Copy Markdown
Contributor

@Benjamin-eecs Benjamin-eecs commented Apr 22, 2026

Description

Fixes two bugs reported in #1149:

  1. history shows all titles as (untitled): DeepSeek changed their sidebar DOM. The first child <div> inside each conversation link is now an empty <div class="ds-focus-ring">, so link.querySelector('div').textContent always returns ''. Switched to link.innerText which correctly returns the title text.

  2. ask creates a new conversation every time: When the workspace is recycled after idle timeout (30s for site workspaces), ensureOnDeepSeek navigates to the root URL which is always a blank new-chat page. Now when --new is false (default) and navigation was required, the adapter clicks the most recent sidebar conversation link to resume it. Model selection is skipped when inside an existing conversation since the selector is only rendered on the new-chat page.

Fixes #1149

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Documentation (if adding/modifying an adapter)

N/A (existing adapter bug fix, no new commands or args added)

Screenshots / Output

Before (history titles):

- Index: 1
  Title: (untitled)
- Index: 2
  Title: (untitled)

After (history titles):

- Index: 1
  Title: Hello World Python Code
- Index: 2
  Title: Today's date query

Conversation resume test:

$ opencli deepseek ask "say only the word banana" --new
- response: banana

# (wait 35s for workspace recycling)

$ opencli deepseek ask "what fruit did I just mention?"
- response: banana

Copilot AI review requested due to automatic review settings April 22, 2026 16:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes DeepSeek adapter regressions caused by recent DeepSeek UI / workspace behavior changes, improving history title extraction and preventing unintended new conversations on repeated ask calls.

Changes:

  • Update getConversationList() to extract conversation titles from link.innerText (instead of the first child <div>).
  • Make ensureOnDeepSeek() return whether navigation occurred, and use that in ask to attempt resuming the most recent conversation after workspace recycling.
  • Add tests covering conversation resume behavior and model-selection skipping.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
clis/deepseek/utils.js Adjusts DeepSeek page detection/navigation and fixes history title scraping for updated sidebar DOM.
clis/deepseek/ask.js Resumes a prior conversation after navigation and skips model selection inside existing threads.
clis/deepseek/ask.test.js Updates mocks for URL evaluation and adds coverage for the new resume/skip-model behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread clis/deepseek/ask.js
Comment on lines +40 to +47
// Workspace was recycled; try to resume the most recent
// conversation instead of starting a new one.
await page.evaluate(`(() => {
var link = document.querySelector('a[href*="/a/chat/s/"]');
if (link) link.click();
})()`);
await page.wait(2);
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The resume logic clicks the first sidebar conversation link, but it won’t find any links if the DeepSeek sidebar is collapsed (the codebase already handles this in getConversationList by clicking the sidebar toggle when no links are present). Consider expanding the sidebar before querying for the conversation link (or reusing the same “expand sidebar if no links” snippet) so resume works reliably after navigation.

Copilot uses AI. Check for mistakes.
Comment thread clis/deepseek/ask.js
Comment on lines +52 to +60
// Model selector is only available on the new-chat page, not inside
// an existing conversation. Skip it when we resumed a prior thread.
const currentUrl = await page.evaluate('window.location.href') || '';
const inConversation = currentUrl.includes('/a/chat/s/');

if (!inConversation) {
const wantModel = kwargs.model || 'instant';
const modelResult = await withRetry(() => selectModel(page, wantModel));
if (!modelResult?.ok) {
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

Model selection is now skipped whenever the current URL is inside an existing conversation, which means the --model flag effectively becomes a no-op in that case. Please update the CLI arg help text (or add an explicit note/error when --model is requested but cannot be applied) so users aren’t misled into thinking the model was switched.

Copilot uses AI. Check for mistakes.
- history: use link.innerText instead of link.querySelector('div') for
  title extraction. DeepSeek changed sidebar DOM; the first child div
  is now an empty ds-focus-ring element, causing all titles to show as
  (untitled).

- ask: when workspace is recycled (idle timeout) and --new is false
  (default), click the most recent sidebar conversation link to resume
  it instead of staying on the blank new-chat page. Skip model
  selection when inside an existing conversation since the selector is
  only rendered on the new-chat page.

- ensureOnDeepSeek: return boolean indicating whether navigation
  occurred, so callers can react to workspace recycling.

Closes jackwener#1149
@Benjamin-eecs Benjamin-eecs force-pushed the fix/deepseek-history-resume branch from 29d9a6b to 4a26873 Compare April 23, 2026 06:30
@jackwener jackwener merged commit c8eedee into jackwener:main Apr 23, 2026
11 checks passed
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]: deepseek ask 每次执行都创建新对话,且 history 中所有对话标题均为 (untitled)

3 participants