perf: reduce idle desktop load by gating plan-mode checks

- Add startup feature flag for plan mode from OPENCODE_EXPERIMENTAL* env vars.
- Stop recurring app health polling and keep a one-time startup check.
- Skip plan-mode synthetic parsing and plan tab/file work when flag is off.
This commit is contained in:
Bohdan Triapitsyn
2026-04-03 13:59:10 +03:00
parent a36b11d54e
commit 5045d21821
7 changed files with 82 additions and 15 deletions
@@ -81,15 +81,16 @@ const buildGitHubAttachmentPart = (text: string): Part | null => {
return null;
};
const shouldKeepSyntheticUserText = (text: string): boolean => {
const shouldKeepSyntheticUserText = (text: string, planModeEnabled: boolean): boolean => {
const trimmed = text.trim();
if (trimmed.startsWith('User has requested to enter plan mode')) return true;
if (trimmed.startsWith('The plan at ')) return true;
if (planModeEnabled && trimmed.startsWith('User has requested to enter plan mode')) return true;
if (planModeEnabled && trimmed.startsWith('The plan at ')) return true;
if (trimmed.startsWith('The following tool was executed by the user')) return true;
return false;
};
export const normalizeUserDisplayParts = (parts: Part[]): Part[] => {
export const normalizeUserDisplayParts = (parts: Part[], options?: { planModeEnabled?: boolean }): Part[] => {
const planModeEnabled = options?.planModeEnabled === true;
return parts
.filter((part) => {
const synthetic = (part as { synthetic?: boolean }).synthetic === true;
@@ -101,7 +102,7 @@ export const normalizeUserDisplayParts = (parts: Part[]): Part[] => {
}
const normalizedText = text.trimStart();
return shouldKeepSyntheticUserText(text)
return shouldKeepSyntheticUserText(text, planModeEnabled)
|| normalizedText.startsWith(GITHUB_ISSUE_CONTEXT_PREFIX)
|| normalizedText.startsWith(GITHUB_PR_CONTEXT_PREFIX);
})