Fallback to balanced smart context for mentioned apps because not sup… (#1886)

…ported in deep context

Fixes https://github.com/dyad-sh/dyad/issues/1715

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Deep context now only applies with no app mentions; otherwise we
fallback to balanced and pass the effective mode to the engine, with
updated history limits and new e2e coverage.
> 
> - **Smart Context behavior**:
> - Deep mode activates only when no `@app:` mentions are present;
otherwise uses `balanced`.
> - Max chat turns set to 201 only for deep-without-mentions; otherwise
use configured limit.
> - **Engine integration**:
> - Send effective smart context mode via `dyadSmartContextMode` and map
to `dyad_options.smart_context_mode` in `llm_engine_provider`.
> - Add `SmartContextMode` schema (`balanced|conservative|deep`) and use
it in settings/types.
> - Remove static `smartContextMode` from engine options; use
per-request mode instead.
> - **Tests**:
> - Add e2e test `smart context deep - mention app should fallback to
balanced` with snapshot asserting `smart_context_mode: "balanced"` and
mentioned app files.
> - **Misc**:
>   - Tighten app path validation regex in `rename-app` handler.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5aada2bd246e297d7b35e36738f75c8531b897ae. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->



<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fallback to balanced smart context when an app is mentioned in deep
mode, since deep doesn’t support mentioned apps. This keeps context
limits correct and updates engine config, with new e2e coverage.

- **Bug Fixes**
- Deep mode only applies when no apps are mentioned; otherwise we use
balanced.
- Max chat turns: 201 only for deep without mentions; otherwise use
configured limit.
- Plumb smart context mode via dyadSmartContextMode to the engine; add
SmartContextMode schema.
- Add e2e test to verify fallback in deep mode when an app is mentioned.

<sup>Written for commit 5aada2bd246e297d7b35e36738f75c8531b897ae.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
This commit is contained in:
Will Chen
2025-12-04 15:19:37 -08:00
committed by GitHub
parent 196f02c979
commit 3701886505
7 changed files with 537 additions and 13 deletions

View File

@@ -16,3 +16,25 @@ testSkipIfWindows("smart context deep - read write read", async ({ po }) => {
await po.snapshotServerDump("request");
await po.snapshotMessages({ replaceDumpPath: true });
});
testSkipIfWindows(
"smart context deep - mention app should fallback to balanced",
async ({ po }) => {
await po.setUpDyadPro();
// First, create an imported app.
await po.importApp("minimal-with-ai-rules");
await po.goToAppsTab();
const proModesDialog = await po.openProModesDialog({
location: "home-chat-input-container",
});
await proModesDialog.setSmartContextMode("deep");
await proModesDialog.close();
// Mentioned the imported app
await po.sendPrompt("[dump] @app:minimal-with-ai-rules hi");
await po.snapshotServerDump("request");
},
);