Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Open **Settings → Qoderian**:
| Group | Contents |
|-------|----------|
| **Setup** | Qoder CLI edition and path to the `qodercli` executable (auto-detected by default) |
| **Display** | Chat view placement, maximum tabs, auto-scroll, deferred math rendering during streaming, and default expansion of file edits (the language selector sits above this group) |
| **Display** | Chat view placement, auto-scroll, deferred math rendering during streaming, and default expansion of file edits (the language selector sits above this group) |
| **Conversations** | Auto-generated titles and the model that writes them |
| **Content** | User name, custom system prompt, excluded tags, media folder |
| **Input** | Send-key behavior and vim-style navigation mappings |
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ QODER_CLI_PATH=/absolute/path/to/qodercli npm run smoke:qoder
| 分组 | 内容 |
|-------|----------|
| **设置** | Qoder CLI 版本与 `qodercli` 可执行文件路径(默认自动探测) |
| **显示** | Qoderian 打开位置、最大聊天标签数、流式传输时自动滚动、流式传输时延迟渲染数学公式、默认展开文件编辑(语言选择器在该组上方) |
| **显示** | Qoderian 打开位置、流式传输时自动滚动、流式传输时延迟渲染数学公式、默认展开文件编辑(语言选择器在该组上方) |
| **对话** | 自动生成对话标题与标题生成模型 |
| **内容** | 用户名、自定义系统提示词、排除的标签、媒体文件夹 |
| **输入** | 需要 Command/Ctrl+Enter 发送与 Vim 风格导航映射 |
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
},
"overrides": {
"@babel/core": "7.29.7",
"@hono/node-server": "2.1.5",
"@hono/node-server": "2.1.11",
"body-parser": "2.4.0",
"brace-expansion": "5.0.9",
"esbuild": "$esbuild",
"express": "5.3.0",
"express-rate-limit": "8.7.2",
"fast-uri": "^3.1.9",
"hono": "4.13.14",
"hono": "4.13.22",
"ip-address": "10.7.5",
"js-yaml": "4.3.0",
"minimatch": "10.2.5",
Expand Down
2 changes: 1 addition & 1 deletion src/app/settings/settings-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const DEFAULT_QODERIAN_SETTINGS: QoderianSettings = {

qoder: { ...DEFAULT_QODER_SETTINGS },

maxTabs: 3,
enableAutoScroll: true,
deferMathRenderingDuringStreaming: true,
expandFileEditsByDefault: false,
Expand Down Expand Up @@ -155,6 +154,7 @@ export class QoderianSettingsStorage {
envSnippets: _removedEnvironmentSnippets,
customModelAliases: _removedModelAliases,
hiddenCommands: _removedHiddenCommands,
maxTabs: _removedMaxTabs,
...storedWithoutRemovedSettings
} = stored;
const merged = {
Expand Down
1 change: 0 additions & 1 deletion src/core/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export interface QoderianSettings {
qoder: QoderSettings;

// UI preferences
maxTabs: number;
enableAutoScroll: boolean;
deferMathRenderingDuringStreaming: boolean;
expandFileEditsByDefault: boolean;
Expand Down
47 changes: 4 additions & 43 deletions src/features/chat/chat-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from './tabs/tab';
import { TabBar } from './tabs/tab-bar';
import { TabManager } from './tabs/tab-manager';
import { DEFAULT_MAX_TABS, type TabData, type TabId } from './tabs/types';
import { type TabData, type TabId } from './tabs/types';
import { CreditsUsageButton } from './ui/credits-usage-button';

type LoadableView = {
Expand Down Expand Up @@ -411,11 +411,6 @@ export class QoderianView extends ItemView {
return this.sessionTabsRedesignEnabled() ? t('nav.newSession') : t('commands.newTab');
}

/** Refreshes tab controls after settings that affect tab availability change. */
refreshTabControls(): void {
this.updateTabBarVisibility();
}

/** Re-renders tab chrome after the experimental session-tab mode changes. */
refreshSessionTabsMode(): void {
this.newConversationButtonEl?.toggleClass(
Expand Down Expand Up @@ -470,12 +465,7 @@ export class QoderianView extends ItemView {
}

async createNewTab(): Promise<void> {
const tab = await this.tabManager?.createTab();
if (!tab) {
this.noticeSessionLimit();
this.updateTabBarVisibility();
return;
}
await this.tabManager?.createTab();
this.updateTabBarVisibility();
}

Expand Down Expand Up @@ -506,24 +496,6 @@ export class QoderianView extends ItemView {
const showTabBar = tabCount >= 2;

this.tabBarContainerEl.toggleClass('qoderian-hidden', !showTabBar);

this.updateNewTabButtonVisibility();
}

private updateNewTabButtonVisibility(): void {
if (!this.newTabButtonEl || !this.tabManager) return;
if (this.sessionTabsRedesignEnabled()) return;

const canCreateTab = this.tabManager.canCreateTab();
this.newTabButtonEl.toggleClass('qoderian-hidden', !canCreateTab);
if (canCreateTab) {
this.newTabButtonEl.removeAttribute('aria-disabled');
this.newTabButtonEl.removeAttribute('aria-hidden');
return;
}

this.newTabButtonEl.setAttribute('aria-disabled', 'true');
this.newTabButtonEl.setAttribute('aria-hidden', 'true');
}

/** Ensures the fixed Qoder logo is mounted in the header. */
Expand Down Expand Up @@ -576,34 +548,23 @@ export class QoderianView extends ItemView {
private async openHistoryConversation(conversationId: string): Promise<void> {
// With the redesigned tabs, resuming a conversation must not replace the
// session in the active tab; legacy keeps opening it in the current tab.
const opened = await this.tabManager?.openConversation(conversationId, {
await this.tabManager?.openConversation(conversationId, {
preferNewTab: this.sessionTabsRedesignEnabled(),
});
if (opened === false) {
this.noticeSessionLimit();
}
this.historyDropdown?.removeClass('visible');
}

private async openHistoryConversationInNewTab(
conversationId: string,
activate = true,
): Promise<void> {
const opened = await this.tabManager?.openConversation(conversationId, {
await this.tabManager?.openConversation(conversationId, {
preferNewTab: true,
activate,
});
if (opened === false) {
this.noticeSessionLimit();
}
this.historyDropdown?.removeClass('visible');
}

private noticeSessionLimit(): void {
const maxTabs = this.plugin.settings.maxTabs ?? DEFAULT_MAX_TABS;
new Notice(t('chat.tabs.maxTabsReached', { count: String(maxTabs) }));
}

private getHistoryConversationStatus(conversationId: string): HistoryConversationStatus {
const activeTab = this.tabManager?.getActiveTab();
if (activeTab?.conversationId === conversationId) {
Expand Down
62 changes: 10 additions & 52 deletions src/features/chat/tabs/tab-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import {
wireTabInputEvents,
} from './tab';
import {
DEFAULT_MAX_TABS,
MAX_TABS,
MIN_TABS,
type PersistedTabManagerState,
type PersistedTabState,
type TabBarItem,
Expand Down Expand Up @@ -57,15 +54,6 @@ export class TabManager implements TabManagerInterface {
/** Guard to prevent concurrent tab switches. */
private isSwitchingTab = false;

/**
* Gets the current max tabs limit from settings.
* Clamps to MIN_TABS and MAX_TABS bounds.
*/
private getMaxTabs(): number {
const settingsValue = this.plugin.settings.maxTabs ?? DEFAULT_MAX_TABS;
return Math.max(MIN_TABS, Math.min(MAX_TABS, settingsValue));
}

/** Whether the experimental session-tab interaction (own tab per session) is on. */
private sessionTabsRedesignEnabled(): boolean {
return this.plugin.settings.enableSessionTabsRedesign === true;
Expand All @@ -92,26 +80,20 @@ export class TabManager implements TabManagerInterface {
* @param conversationId Optional conversation to load into the tab.
* @param tabId Optional tab ID (for restoration).
* @param options Controls whether the new tab becomes active immediately.
* @returns The created tab, or null if max tabs reached.
*/
async createTab(
conversationId?: string | null,
tabId?: TabId,
options: CreateTabOptions = {},
): Promise<TabData | null> {
): Promise<TabData> {
return this.createTabInner(conversationId, tabId, options);
}

private async createTabInner(
conversationId?: string | null,
tabId?: TabId,
options: CreateTabOptions = {},
): Promise<TabData | null> {
const maxTabs = this.getMaxTabs();
if (this.tabs.size >= maxTabs) {
return null;
}

): Promise<TabData> {
const { activate = true, draftModel } = options;

const conversation = conversationId
Expand Down Expand Up @@ -150,7 +132,7 @@ export class TabManager implements TabManagerInterface {
this.plugin,
this.view,
(forkContext) => this.handleForkRequest(forkContext),
(conversationId) => this.openConversation(conversationId).then(() => undefined),
(conversationId) => this.openConversation(conversationId),
() => this.getQoderCatalogConfig(tab),
);

Expand Down Expand Up @@ -320,11 +302,6 @@ export class TabManager implements TabManagerInterface {
return this.tabs.size;
}

/** Checks if more tabs can be created. */
canCreateTab(): boolean {
return this.tabs.size < this.getMaxTabs();
}

// ============================================
// Tab Bar Data
// ============================================
Expand Down Expand Up @@ -361,12 +338,11 @@ export class TabManager implements TabManagerInterface {
* Opens a conversation in a new tab or existing tab.
* @param conversationId The conversation to open.
* @param options Controls tab creation behavior (backward-compatible with boolean).
* @returns False when a new tab was requested but the tab limit is reached.
*/
async openConversation(
conversationId: string,
options: boolean | OpenConversationOptions = false,
): Promise<boolean> {
): Promise<void> {
const preferNewTab = typeof options === 'boolean'
? options
: options.preferNewTab ?? false;
Expand All @@ -378,7 +354,7 @@ export class TabManager implements TabManagerInterface {
for (const tab of this.tabs.values()) {
if (tab.conversationId === conversationId) {
await this.switchToTab(tab.id);
return true;
return;
}
}

Expand All @@ -390,19 +366,12 @@ export class TabManager implements TabManagerInterface {
// Focus the other view and switch to its tab instead of opening duplicate
await revealWorkspaceLeaf(this.plugin.app.workspace, crossViewResult.view.leaf);
await crossViewResult.view.getTabManager()?.switchToTab(crossViewResult.tabId);
return true;
return;
}

// Open in a new tab when requested. The redesigned tabs never replace the
// active tab silently; the legacy behavior keeps the old fallback.
if (preferNewTab) {
if (this.canCreateTab()) {
await this.createTab(conversationId, undefined, { activate });
return true;
}
if (this.sessionTabsRedesignEnabled()) {
return false;
}
await this.createTab(conversationId, undefined, { activate });
return;
}

// Open in current tab
Expand All @@ -413,7 +382,6 @@ export class TabManager implements TabManagerInterface {
if (activeTab) {
await activeTab.controllers.conversationController?.switchTo(conversationId);
}
return true;
}

/**
Expand Down Expand Up @@ -444,12 +412,7 @@ export class TabManager implements TabManagerInterface {
if (!target) return;

if (target === 'new-tab') {
const tab = await this.forkToNewTab(context);
if (!tab) {
const maxTabs = this.getMaxTabs();
new Notice(t('chat.fork.maxTabsReached', { count: String(maxTabs) }));
return;
}
await this.forkToNewTab(context);
new Notice(t('chat.fork.notice'));
} else {
const success = await this.forkInCurrentTab(context);
Expand All @@ -461,12 +424,7 @@ export class TabManager implements TabManagerInterface {
}
}

async forkToNewTab(context: ForkContext): Promise<TabData | null> {
const maxTabs = this.getMaxTabs();
if (this.tabs.size >= maxTabs) {
return null;
}

async forkToNewTab(context: ForkContext): Promise<TabData> {
const conversationId = await this.createForkConversation(context);
try {
return await this.createTab(conversationId);
Expand Down
21 changes: 0 additions & 21 deletions src/features/chat/tabs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,6 @@ import type { NavigationSidebar } from '../ui/navigation-sidebar';
import type { StatusPanel } from '../ui/status-panel';
import type { VaultDropController } from '../ui/vault-drop';

/**
* Default number of tabs allowed.
*
* Set to 3 to balance usability with resource usage:
* - Each tab has its own chat runtime and persistent query
* - More tabs = more memory and potential SDK processes
* - 3 tabs allows multi-tasking without excessive overhead
*/
export const DEFAULT_MAX_TABS = 3;

/**
* Minimum number of tabs allowed (settings floor).
*/
export const MIN_TABS = 3;

/**
* Maximum number of tabs allowed (settings ceiling).
* Users can configure up to this many tabs via settings.
*/
export const MAX_TABS = 10;

/**
* Minimal interface for the QoderianView methods used by TabManager and Tab.
* Extends Component for Obsidian integration (event handling, cleanup).
Expand Down
Loading
Loading