Skip to content

Commit 06a629e

Browse files
luoxuanzaoQoder-AI
andauthored
feat: polish nav-row tooltips (delay, localization, persistence) (#30)
* feat: speed up icon-button tooltips with a 300ms hover delay Obsidian's native aria-label tooltips use a 1000ms cold-start delay and a 100ms warm window, so hovering across the chat toolbar feels inconsistent and sluggish compared to common web toolbars (200-700ms initial, ~300ms warm). Route the navigation buttons (new tab, new conversation, chat history) and the tab-bar badges through a shared setButtonTooltip helper built on the official setTooltip API with a 300ms delay, keeping native rendering and accessibility intact. The obsidian test mock mirrors setTooltip so unit tests exercise the new path. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com> * fix: give the credits button a static native tooltip like other nav buttons The credits usage button set a browser `title` attribute with the live usage percentage, so its tooltip rendered in the OS/browser style and read differently from the other nav-row buttons, which use aria-label and Obsidian's native tooltip. Drop the percentage from the trigger copy in all ten locales and set a static aria-label ("Usage") instead, so the gauge button looks and behaves like its neighbors; the popover panel keeps the detailed numbers. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com> * fix: localize nav-row button tooltips and the blank tab title The nav-row buttons hardcoded English strings ("New tab", "New conversation", "Chat history") and getTabTitle fell back to a hardcoded "New Chat", so non-English locales (e.g. zh-CN) saw English tooltips next to the localized credits button. Route them through the i18n catalog: reuse commands.newTab for the new-tab button and add a nav group (newConversation / chatHistory / newChat) in all ten locales. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com> * fix: persist declarative setting changes and live-localize views on switch On Obsidian 1.13+ the declarative settings base class persists control changes into the plugin data file, but Qoderian loads its settings from .qoderian/qoderian-settings.json, so simple controls (language, auto-scroll, and the other toggles) silently reverted on restart. Per the API contract, override setControlValue to write to our own data source: mutate the settings bag and save once through saveSettings(), skipping the base class' data.json write. After a language change, open chat views also re-apply localized static text (nav-row tooltips, tab titles, and the credits button label/panel) via a new refreshLocalizedChrome() instead of keeping the old language until the view reopens. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com> * refactor: route the credits button tooltip through the shared helper The credits button still wrote its aria-label directly, keeping the default 1s native delay while the other nav-row buttons use the shared setButtonTooltip helper (300ms). Use the same helper so the button is built and hinted exactly like its neighbors; only its click behavior (opening the usage popover) differs. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com> --------- Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent b86909e commit 06a629e

21 files changed

Lines changed: 245 additions & 36 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ version with its date and start a fresh empty `[Unreleased]` above it.
7575
snapshots now carry the configured context-window tier, and zeroed
7676
snapshots can no longer overwrite an existing reading.
7777

78+
### Changed
79+
80+
- The credits usage button now shows a static "Usage" tooltip through
81+
Obsidian's native tooltip (aria-label), matching the other nav-row
82+
buttons, instead of a browser title tooltip with the live percentage.
83+
84+
### Fixed
85+
86+
- Settings changed on Obsidian 1.13+ (language, auto-scroll, and the
87+
other simple toggles) now persist across restarts: the declarative
88+
control writes were only mirrored into the plugin data file, not the
89+
`.qoderian/qoderian-settings.json` store Qoderian loads at startup.
90+
Changing the language also re-localizes open chat views immediately
91+
(nav tooltips and tab titles) instead of keeping the old language
92+
until the view is reopened.
93+
7894
## [1.0.4] - 2026-08-12
7995

8096
### Fixed

‎src/features/chat/chat-view.ts‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
scheduleAnimationFrame,
1212
type ScheduledAnimationFrame,
1313
} from '../../shared/dom/animation-frame';
14+
import { setButtonTooltip } from '../../shared/dom/tooltip';
1415
import { createIconSvg, QODER_ICON,QODERIAN_ICON_ID } from '../../shared/icons';
1516
import type { HistoryConversationStatus } from './controllers/conversation-controller';
1617
import {
@@ -44,6 +45,8 @@ export class QoderianView extends ItemView {
4445
private viewContainerEl: HTMLElement | null = null;
4546
private logoEl: HTMLElement | null = null;
4647
private newTabButtonEl: HTMLElement | null = null;
48+
private newConversationButtonEl: HTMLElement | null = null;
49+
private historyButtonEl: HTMLElement | null = null;
4750

4851
// Header elements
4952
private historyDropdown: HTMLElement | null = null;
@@ -244,14 +247,15 @@ export class QoderianView extends ItemView {
244247

245248
this.newTabButtonEl = navActionsEl.createDiv({ cls: 'qoderian-input-nav-btn qoderian-new-tab-btn' });
246249
setIcon(this.newTabButtonEl, 'square-plus');
247-
this.newTabButtonEl.setAttribute('aria-label', 'New tab');
250+
setButtonTooltip(this.newTabButtonEl, t('commands.newTab'));
248251
this.newTabButtonEl.addEventListener('click', () => {
249252
void this.createNewTab().catch(() => new Notice('Failed to create tab'));
250253
});
251254

252255
const newBtn = navActionsEl.createDiv({ cls: 'qoderian-input-nav-btn' });
253256
setIcon(newBtn, 'square-pen');
254-
newBtn.setAttribute('aria-label', 'New conversation');
257+
setButtonTooltip(newBtn, t('nav.newConversation'));
258+
this.newConversationButtonEl = newBtn;
255259
newBtn.addEventListener('click', () => {
256260
void (async () => {
257261
await this.tabManager?.createNewConversation();
@@ -263,7 +267,8 @@ export class QoderianView extends ItemView {
263267
const historyContainer = navActionsEl.createDiv({ cls: 'qoderian-history-container' });
264268
const historyBtn = historyContainer.createDiv({ cls: 'qoderian-input-nav-btn' });
265269
setIcon(historyBtn, 'history');
266-
historyBtn.setAttribute('aria-label', 'Chat history');
270+
setButtonTooltip(historyBtn, t('nav.chatHistory'));
271+
this.historyButtonEl = historyBtn;
267272

268273
this.historyDropdown = historyContainer.createDiv({ cls: 'qoderian-history-menu' });
269274

@@ -346,6 +351,17 @@ export class QoderianView extends ItemView {
346351
this.updateTabBarVisibility();
347352
}
348353

354+
/** Re-applies locale-dependent static text after a language change. */
355+
refreshLocalizedChrome(): void {
356+
if (this.newTabButtonEl) setButtonTooltip(this.newTabButtonEl, t('commands.newTab'));
357+
if (this.newConversationButtonEl) {
358+
setButtonTooltip(this.newConversationButtonEl, t('nav.newConversation'));
359+
}
360+
if (this.historyButtonEl) setButtonTooltip(this.historyButtonEl, t('nav.chatHistory'));
361+
this.creditsUsageButton?.refreshLocale();
362+
this.updateTabBar();
363+
}
364+
349365
// ============================================
350366
// Tab Management
351367
// ============================================

‎src/features/chat/tabs/tab-bar.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { scheduleAnimationFrame } from '../../../shared/dom/animation-frame';
2+
import { setButtonTooltip } from '../../../shared/dom/tooltip';
23
import type { TabBarItem, TabId } from './types';
34

45
const EXPANDED_TITLE_MAX_LENGTH = 32;
@@ -82,7 +83,7 @@ export class TabBar {
8283
});
8384

8485
// Obsidian uses aria-label for hover tooltips here; adding title causes duplicate tooltip text.
85-
badgeEl.setAttribute('aria-label', item.title);
86+
setButtonTooltip(badgeEl, item.title);
8687
badgeEl.setAttribute('data-title-expanded', isTitleExpanded ? 'true' : 'false');
8788

8889
// Click handler to switch tab

‎src/features/chat/tabs/tab-lifecycle.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { t } from '../../../i18n/i18n';
12
import type QoderianPlugin from '../../../main';
23
import { cleanupThinkingBlock } from '../rendering/thinking-block-renderer';
34
import type { TabData } from './types';
@@ -71,5 +72,5 @@ export function getTabTitle(tab: TabData, plugin: QoderianPlugin): string {
7172
const conversation = plugin.getConversationSync(tab.conversationId);
7273
if (conversation?.title) return conversation.title;
7374
}
74-
return 'New Chat';
75+
return t('nav.newChat');
7576
}

‎src/features/chat/ui/credits-usage-button.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
} from '../../../core/types/services';
88
import { getLocale, t } from '../../../i18n/i18n';
99
import { getQoderAccountUsageUrl } from '../../../qoder/config/cli-edition';
10+
import { setButtonTooltip } from '../../../shared/dom/tooltip';
1011
import { ClickPopover } from './toolbar/click-popover';
1112

1213
/** Usage snapshots older than this are refreshed when the panel opens. */
@@ -97,6 +98,12 @@ export class CreditsUsageButton {
9798
this.container.remove();
9899
}
99100

101+
/** Re-applies locale-dependent text after a language change. */
102+
refreshLocale(): void {
103+
this.updateButton();
104+
this.renderPanel();
105+
}
106+
100107
/** Fetches a fresh snapshot; cached snapshots within the TTL are kept. */
101108
async refresh(force: boolean): Promise<void> {
102109
if (this.loading) return;
@@ -125,12 +132,9 @@ export class CreditsUsageButton {
125132
};
126133

127134
private updateButton(): void {
128-
const percent = this.snapshot?.totalUsagePercentage;
129-
if (typeof percent === 'number') {
130-
this.buttonEl.setAttribute('title', t('credits.trigger', { percent: Math.round(percent) }));
131-
} else {
132-
this.buttonEl.setAttribute('title', t('credits.unavailable'));
133-
}
135+
// Same tooltip path as the other nav-row buttons (aria-label + 300ms
136+
// delay); only the click behavior (popover) differs.
137+
setButtonTooltip(this.buttonEl, t('credits.trigger'));
134138
}
135139

136140
private renderPanel(): void {

‎src/features/settings/settings-tab.ts‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,15 +417,30 @@ export class QoderianSettingTab extends PluginSettingTab {
417417
return this.plugin.saveSettings();
418418
}
419419

420-
if (key === 'mediaFolder') {
421-
return super.setControlValue(key, String(value).trim());
422-
}
420+
return this.persistControlValue(key, value);
421+
}
422+
// Unreachable: Obsidian < 1.13 never calls setControlValue.
423+
}
423424

424-
const result = super.setControlValue(key, value);
425+
/**
426+
* The declarative base class persists into the plugin data file, but
427+
* Qoderian keeps its settings in .qoderian/qoderian-settings.json, so per
428+
* the API contract ("override to write to a different data source") we
429+
* mutate the settings bag ourselves and save once through the store that
430+
* loadSettings() actually reads — no duplicate write to data.json.
431+
*/
432+
private async persistControlValue(key: string, value: unknown): Promise<void> {
433+
// Only reached from setControlValue on Obsidian 1.13+; re-checked here so
434+
// the 1.13-only view-refresh calls stay behind an explicit version guard.
435+
if (requireApiVersion('1.13.0')) {
436+
const settings = this.plugin.settings as unknown as Record<string, unknown>;
437+
settings[key] = key === 'mediaFolder' ? String(value).trim() : value;
438+
await this.plugin.saveSettings();
425439

426440
if (key === 'locale') {
427441
setLocale(this.plugin.settings.locale as Locale);
428442
this.update();
443+
this.refreshViewChrome();
429444
} else if (key === 'maxTabs') {
430445
for (const view of this.plugin.getAllViews()) {
431446
view.refreshTabControls();
@@ -435,10 +450,14 @@ export class QoderianSettingTab extends PluginSettingTab {
435450
} else if (PROMPT_SETTING_KEYS.has(key)) {
436451
this.schedulePromptRestart();
437452
}
453+
}
454+
}
438455

439-
return result;
456+
/** Re-applies locale-dependent text in open chat views after a language change. */
457+
private refreshViewChrome(): void {
458+
for (const view of this.plugin.getAllViews()) {
459+
view.refreshLocalizedChrome();
440460
}
441-
// Unreachable: Obsidian < 1.13 never calls setControlValue.
442461
}
443462

444463
/**
@@ -518,6 +537,7 @@ export class QoderianSettingTab extends PluginSettingTab {
518537
this.plugin.settings.locale = locale;
519538
await this.plugin.saveSettings();
520539
this.display();
540+
this.refreshViewChrome();
521541
});
522542
});
523543

‎src/i18n/locales/de.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"newSession": "Neue Sitzung (im aktuellen Tab)",
3939
"closeCurrentTab": "Aktuellen Tab schließen"
4040
},
41+
"nav": {
42+
"newConversation": "Neue Unterhaltung",
43+
"chatHistory": "Chatverlauf",
44+
"newChat": "Neuer Chat"
45+
},
4146
"chat": {
4247
"rewind": {
4348
"confirmMessage": "Zu diesem Punkt zurückspulen? Dateiänderungen nach dieser Nachricht werden rückgängig gemacht. Das Zurückspulen betrifft keine manuell oder über Bash bearbeiteten Dateien.",
@@ -292,7 +297,7 @@
292297
"renewsOn": "Verlängert am {date}",
293298
"usedPercent": "{percent}% verwendet",
294299
"left": "{count} übrig",
295-
"trigger": "Nutzung - {percent}%",
300+
"trigger": "Nutzung",
296301
"unavailable": "Nutzung nicht verfügbar"
297302
},
298303
"model": {

‎src/i18n/locales/en.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"newSession": "New session (in current tab)",
3939
"closeCurrentTab": "Close current tab"
4040
},
41+
"nav": {
42+
"newConversation": "New conversation",
43+
"chatHistory": "Chat history",
44+
"newChat": "New Chat"
45+
},
4146
"chat": {
4247
"rewind": {
4348
"confirmMessage": "Rewind to this point? File changes after this message will be reverted. Rewinding does not affect files edited manually or via bash.",
@@ -292,7 +297,7 @@
292297
"renewsOn": "Renews on {date}",
293298
"usedPercent": "{percent}% used",
294299
"left": "{count} left",
295-
"trigger": "Usage - {percent}%",
300+
"trigger": "Usage",
296301
"unavailable": "Usage unavailable"
297302
},
298303
"model": {

‎src/i18n/locales/es.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"newSession": "Nueva sesión (en la pestaña actual)",
3939
"closeCurrentTab": "Cerrar pestaña actual"
4040
},
41+
"nav": {
42+
"newConversation": "Nueva conversación",
43+
"chatHistory": "Historial del chat",
44+
"newChat": "Nuevo chat"
45+
},
4146
"chat": {
4247
"rewind": {
4348
"confirmMessage": "¿Rebobinar a este punto? Los cambios de archivos después de este mensaje serán revertidos. El rebobinado no afecta archivos editados manualmente o mediante bash.",
@@ -292,7 +297,7 @@
292297
"renewsOn": "Se renueva el {date}",
293298
"usedPercent": "{percent}% usado",
294299
"left": "{count} restantes",
295-
"trigger": "Uso - {percent}%",
300+
"trigger": "Uso",
296301
"unavailable": "Uso no disponible"
297302
},
298303
"model": {

‎src/i18n/locales/fr.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"newSession": "Nouvelle session (dans l'onglet actuel)",
3939
"closeCurrentTab": "Fermer l'onglet actuel"
4040
},
41+
"nav": {
42+
"newConversation": "Nouvelle conversation",
43+
"chatHistory": "Historique du chat",
44+
"newChat": "Nouveau chat"
45+
},
4146
"chat": {
4247
"rewind": {
4348
"confirmMessage": "Rembobiner jusqu'à ce point ? Les modifications de fichiers après ce message seront annulées. Le rembobinage n'affecte pas les fichiers modifiés manuellement ou via bash.",
@@ -292,7 +297,7 @@
292297
"renewsOn": "Renouvellement le {date}",
293298
"usedPercent": "{percent}% utilisés",
294299
"left": "{count} restants",
295-
"trigger": "Utilisation - {percent}%",
300+
"trigger": "Utilisation",
296301
"unavailable": "Utilisation indisponible"
297302
},
298303
"model": {

0 commit comments

Comments
 (0)