Skip to content

Conversation

@sestinj
Copy link
Contributor

@sestinj sestinj commented Oct 1, 2025

model persistence, cmd+backspace, and a few other minor things that bothered me


Summary by cubic

Persisted CLI model selection across sessions for both logged-in and logged-out users, and refreshed the TUI immediately after a model change. Also scoped line-deletion shortcuts to the current line and updated the default Anthropic model slug.

  • New Features

    • Persist model selection: auth.json for authenticated users, GlobalContext for unauthenticated users; precedence is auth modelName > GlobalContext; disabled when CONTINUE_API_KEY is set.
    • Refresh the UI on model switch so the intro message shows the new model.
  • Bug Fixes

    • ctrl+u/ctrl+k and cmd+backspace/cmd+delete now delete only within the current line.
    • Updated Anthropic model slug to anthropic/claude-sonnet-4-5 and aligned tests.
    • Safer model restoration: match by name or model id; fall back to the first model on mismatch.

@sestinj sestinj requested a review from a team as a code owner October 1, 2025 06:00
@sestinj sestinj requested review from Patrick-Erichsen and removed request for a team October 1, 2025 06:00
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Oct 1, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

5 issues found across 15 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.


<file name="extensions/cli/src/ui/TextBuffer.ts">

<violation number="1" location="extensions/cli/src/ui/TextBuffer.ts:165">
deleteLineForward() returns without removing the newline when the cursor is at end-of-line, so ctrl+k/meta+Delete stop working there.</violation>
</file>

<file name="extensions/cli/src/util/yamlConfigUpdater.ts">

<violation number="1" location="extensions/cli/src/util/yamlConfigUpdater.ts:65">
By switching the filter to only exclude &quot;anthropic/claude-sonnet-4-5&quot;, existing configs that still contain &quot;anthropic/claude-4-sonnet&quot; will keep that stale entry and then add the new model, so the migration fails to swap out the old slug and leaves duplicates.</violation>
</file>

<file name="extensions/cli/src/integration/model-persistence-unauthenticated.test.ts">

<violation number="1" location="extensions/cli/src/integration/model-persistence-unauthenticated.test.ts:209">
Updating CONTINUE_API_KEY in this test overwrites any existing value and the final delete removes it instead of restoring the original. If the variable was preset before the suite, this leaves later tests without the expected key. Please capture the prior value and restore it after the assertions.</violation>
</file>

<file name="extensions/cli/src/integration/model-persistence-e2e.test.ts">

<violation number="1" location="extensions/cli/src/integration/model-persistence-e2e.test.ts:103">
Rule violated: **Don&#39;t use console.log**

New console.log statements were added to this test, but the guideline requires using the structured logger instead of console.* calls. Please swap these console logs out for the approved logging utility (and apply the same change to the other new console.log lines mentioned in the evidence).</violation>
</file>

<file name="extensions/cli/src/integration/model-persistence-user-flow.test.ts">

<violation number="1" location="extensions/cli/src/integration/model-persistence-user-flow.test.ts:95">
Rule violated: **Don&#39;t use console.log**

Please replace these new console.log statements with the approved logger API to comply with the &quot;Don&#39;t use console.log&quot; rule. All console logging in this test should be migrated to logger.info/log equivalents to maintain consistent instrumentation.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

const nextNewline = this._text.indexOf("\n", this._cursor);
const lineEnd = nextNewline === -1 ? this._text.length : nextNewline;

if (lineEnd === this._cursor) {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 1, 2025

Choose a reason for hiding this comment

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

deleteLineForward() returns without removing the newline when the cursor is at end-of-line, so ctrl+k/meta+Delete stop working there.

Prompt for AI agents
Address the following comment on extensions/cli/src/ui/TextBuffer.ts at line 165:

<comment>deleteLineForward() returns without removing the newline when the cursor is at end-of-line, so ctrl+k/meta+Delete stop working there.</comment>

<file context>
@@ -137,6 +137,38 @@ export class TextBuffer {
+    const nextNewline = this._text.indexOf(&quot;\n&quot;, this._cursor);
+    const lineEnd = nextNewline === -1 ? this._text.length : nextNewline;
+
+    if (lineEnd === this._cursor) {
+      return;
+    }
</file context>
Fix with Cubic

// Filter out existing anthropic models
config.models = config.models.filter(
(model: any) => !model || model.uses !== "anthropic/claude-4-sonnet",
(model: any) => !model || model.uses !== "anthropic/claude-sonnet-4-5",
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 1, 2025

Choose a reason for hiding this comment

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

By switching the filter to only exclude "anthropic/claude-sonnet-4-5", existing configs that still contain "anthropic/claude-4-sonnet" will keep that stale entry and then add the new model, so the migration fails to swap out the old slug and leaves duplicates.

Prompt for AI agents
Address the following comment on extensions/cli/src/util/yamlConfigUpdater.ts at line 65:

<comment>By switching the filter to only exclude &quot;anthropic/claude-sonnet-4-5&quot;, existing configs that still contain &quot;anthropic/claude-4-sonnet&quot; will keep that stale entry and then add the new model, so the migration fails to swap out the old slug and leaves duplicates.</comment>

<file context>
@@ -62,7 +62,7 @@ export function updateAnthropicModelInYaml(
     // Filter out existing anthropic models
     config.models = config.models.filter(
-      (model: any) =&gt; !model || model.uses !== &quot;anthropic/claude-4-sonnet&quot;,
+      (model: any) =&gt; !model || model.uses !== &quot;anthropic/claude-sonnet-4-5&quot;,
     );
 
</file context>
Suggested change
(model: any) => !model || model.uses !== "anthropic/claude-sonnet-4-5",
(model: any) => !model || (model.uses !== "anthropic/claude-sonnet-4-5" && model.uses !== "anthropic/claude-4-sonnet"),
Fix with Cubic

updateModelName(null);
expect(getPersistedModelName()).toBeNull();

process.env.CONTINUE_API_KEY = "test-api-key";
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 1, 2025

Choose a reason for hiding this comment

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

Updating CONTINUE_API_KEY in this test overwrites any existing value and the final delete removes it instead of restoring the original. If the variable was preset before the suite, this leaves later tests without the expected key. Please capture the prior value and restore it after the assertions.

Prompt for AI agents
Address the following comment on extensions/cli/src/integration/model-persistence-unauthenticated.test.ts at line 209:

<comment>Updating CONTINUE_API_KEY in this test overwrites any existing value and the final delete removes it instead of restoring the original. If the variable was preset before the suite, this leaves later tests without the expected key. Please capture the prior value and restore it after the assertions.</comment>

<file context>
@@ -0,0 +1,236 @@
+    updateModelName(null);
+    expect(getPersistedModelName()).toBeNull();
+
+    process.env.CONTINUE_API_KEY = &quot;test-api-key&quot;;
+
+    updateModelName(&quot;Claude 3.5 Sonnet&quot;);
</file context>

✅ Addressed in ad14fcc

let service = new ModelService();
let state = await service.initialize(mockAssistant, mockAuthConfig);

console.log("Initial model:", state.model?.name);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 1, 2025

Choose a reason for hiding this comment

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

Rule violated: Don't use console.log

New console.log statements were added to this test, but the guideline requires using the structured logger instead of console.* calls. Please swap these console logs out for the approved logging utility (and apply the same change to the other new console.log lines mentioned in the evidence).

Prompt for AI agents
Address the following comment on extensions/cli/src/integration/model-persistence-e2e.test.ts at line 103:

<comment>New console.log statements were added to this test, but the guideline requires using the structured logger instead of console.* calls. Please swap these console logs out for the approved logging utility (and apply the same change to the other new console.log lines mentioned in the evidence).</comment>

<file context>
@@ -0,0 +1,205 @@
+    let service = new ModelService();
+    let state = await service.initialize(mockAssistant, mockAuthConfig);
+
+    console.log(&quot;Initial model:&quot;, state.model?.name);
+    expect(state.model?.name).toBe(&quot;GPT-4&quot;);
+
</file context>
Fix with Cubic

});

test("should persist model choice exactly as user experiences it", async () => {
console.log("\n=== SESSION 1: User opens cn and switches model ===");
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 1, 2025

Choose a reason for hiding this comment

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

Rule violated: Don't use console.log

Please replace these new console.log statements with the approved logger API to comply with the "Don't use console.log" rule. All console logging in this test should be migrated to logger.info/log equivalents to maintain consistent instrumentation.

Prompt for AI agents
Address the following comment on extensions/cli/src/integration/model-persistence-user-flow.test.ts at line 95:

<comment>Please replace these new console.log statements with the approved logger API to comply with the &quot;Don&#39;t use console.log&quot; rule. All console logging in this test should be migrated to logger.info/log equivalents to maintain consistent instrumentation.</comment>

<file context>
@@ -0,0 +1,154 @@
+  });
+
+  test(&quot;should persist model choice exactly as user experiences it&quot;, async () =&gt; {
+    console.log(&quot;\n=== SESSION 1: User opens cn and switches model ===&quot;);
+
+    // Session 1: User starts CLI
</file context>
Fix with Cubic

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Oct 1, 2025
@sestinj sestinj merged commit 9cb2766 into main Oct 1, 2025
52 of 61 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Issues and PRs Oct 1, 2025
@sestinj sestinj deleted the nate/cn-nitpicks branch October 1, 2025 07:06
@github-actions github-actions bot locked and limited conversation to collaborators Oct 1, 2025
@sestinj
Copy link
Contributor Author

sestinj commented Oct 1, 2025

🎉 This PR is included in version 1.24.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor Author

sestinj commented Oct 1, 2025

🎉 This PR is included in version 1.21.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor Author

sestinj commented Oct 15, 2025

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

released size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants