Skip to content
Open
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
11 changes: 11 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ class ClaudeChatProvider {
// Load saved model preference
this._selectedModel = this._context.workspaceState.get('claude.selectedModel', 'default');

// Load persisted input draft so it survives panel disposal / VS Code
// restarts, restored to the webview once ready
this._draftMessage = this._context.workspaceState.get('claudeCodeChat.inputDraft', '');

// Load cached subscription type (will be refreshed on first message)
this._subscriptionType = this._context.globalState.get('claude.subscriptionType');

Expand Down Expand Up @@ -895,6 +899,7 @@ class ClaudeChatProvider {

// Clear draft message since we're sending it
this._draftMessage = '';
this._context.workspaceState.update('claudeCodeChat.inputDraft', undefined);

// Show original user input in chat and save to conversation (without mode prefixes)
this._sendAndSaveMessage({
Expand Down Expand Up @@ -3428,6 +3433,12 @@ class ClaudeChatProvider {

private _saveInputText(text: string): void {
this._draftMessage = text || '';
// Persist so the draft survives panel disposal and VS Code restarts
if (this._draftMessage.trim()) {
this._context.workspaceState.update('claudeCodeChat.inputDraft', this._draftMessage);
} else {
this._context.workspaceState.update('claudeCodeChat.inputDraft', undefined);
}
}

private async _updateSettings(settings: { [key: string]: any }): Promise<void> {
Expand Down
13 changes: 12 additions & 1 deletion src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,14 @@ const getScript = (isTelemetryEnabled: boolean, opencreditsApiUrl: string = 'htt
messageInput.value = '';
attachedImages = [];
renderImagePreviews();

// Clear the persisted draft immediately so no stale text survives
// a restart shortly after sending
clearTimeout(saveInputTimeout);
vscode.postMessage({
type: 'saveInputText',
text: ''
});
}
}

Expand Down Expand Up @@ -3553,7 +3561,10 @@ const getScript = (isTelemetryEnabled: boolean, opencreditsApiUrl: string = 'htt

case 'restoreInputText':
const inputField = document.getElementById('messageInput');
if (inputField && message.data) {
// retainContextWhenHidden already keeps in-progress typing across tab
// switches, so this restore is only the fallback for a fresh panel /
// VS Code restart — don't clobber text the user already has
if (inputField && message.data && !inputField.value.trim()) {
inputField.value = message.data;
// Auto-resize the textarea
inputField.style.height = 'auto';
Expand Down