Skip to content

Commit eb74e08

Browse files
committed
fix: default Workflow collapse when meta missing
1 parent b373d66 commit eb74e08

5 files changed

Lines changed: 9 additions & 6 deletions

File tree

docs/AI_OPERATOR_MANUAL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Rule: “Workflow” must contain everything before the final answer (reasoning/
4040
- `"collapse"`: show Workflow, default collapsed
4141
- `"expand"`: show Workflow, default expanded
4242
- `"disable"`: disable feature (upstream behavior)
43-
- Default behavior: if unset, the patched extension defaults to `"collapse"` (so the feature works without extra configuration)
43+
- Default behavior: if unset (or the injected `<meta>` is missing), the patched webview defaults to `"collapse"` (so the feature works without extra configuration)
4444
- Restart: VS Code restart is required after changes
4545

4646
## Install / Uninstall (deterministic)

docs/INSTALL_FOR_AI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This project does **not** use `%USERPROFILE%\\.codex\\config.toml` anymore. The
5454
- `"collapse"`: show Workflow, default collapsed (recommended)
5555
- `"expand"`: show Workflow, default expanded
5656
- `"disable"`: disable feature (upstream behavior)
57-
- Default: if unset, the patched extension behaves like `"collapse"`.
57+
- Default: if unset (or the injected `<meta>` is missing), the patched webview behaves like `"collapse"`.
5858

5959
## What gets modified on the user machine
6060

docs/remote/codex-folding-install.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function patchExtensionHostJs(source) {
122122
}
123123

124124
function patchWebviewBundleJs(source) {
125-
if (source.includes("CODEX_WORKFLOW_FOLD_PATCH_V3")) return source;
125+
if (source.includes("CODEX_WORKFLOW_FOLD_PATCH_V4")) return source;
126126

127127
const exportIdx = source.lastIndexOf("export{");
128128
if (exportIdx === -1) {
@@ -133,7 +133,8 @@ function patchWebviewBundleJs(source) {
133133
/* CODEX_WORKFLOW_FOLD_PATCH */
134134
/* CODEX_WORKFLOW_FOLD_PATCH_V2 */
135135
/* CODEX_WORKFLOW_FOLD_PATCH_V3 */
136-
function __codexWorkflowCollapseMode(){const m=globalThis.document?.querySelector('meta[name="codex-workflow-collapse"]');const v=m?.getAttribute("content")?.trim();return v==="collapse"||v==="expand"||v==="disable"?v:"disable"}
136+
/* CODEX_WORKFLOW_FOLD_PATCH_V4 */
137+
function __codexWorkflowCollapseMode(){const m=globalThis.document?.querySelector('meta[name="codex-workflow-collapse"]');const v=m?.getAttribute("content")?.trim();return v==="collapse"||v==="expand"||v==="disable"?v:"collapse"}
137138
function __codexWorkflowFormatElapsed(ms){const s=Math.max(0,Math.floor(ms/1e3));const h=Math.floor(s/3600),m=Math.floor((s%3600)/60),ss=s%60;const p=n=>String(n).padStart(2,"0");if(h>0)return \`\${h}h\${p(m)}m\${p(ss)}s\`;return \`\${m}m\${p(ss)}s\`}
138139
function __codexWorkflowFoldItems(items,mode){if(mode==="disable")return items;if(!Array.isArray(items))return items;const out=[];let inTurn=!1;let children=[];let turnIndex=-1;const pushWorkflow=()=>{if(children.length===0)return;out.push({type:"workflow",id:\`workflow-\${turnIndex}\`,children,defaultCollapsed:mode==="collapse"})};for(const it of items){if(it?.type==="user-message"){inTurn=!0;turnIndex++;out.push(it);children=[];continue}if(inTurn&&it?.type==="assistant-message"){pushWorkflow();out.push(it);inTurn=!1;children=[];continue}if(inTurn)children.push(it);else out.push(it)}inTurn&&pushWorkflow();return out}
139140
const __codexOrigMapStateToLocalConversationItems=typeof mapStateToLocalConversationItems==="function"?mapStateToLocalConversationItems:null;

tools/workflow-fold/patcher.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function patchExtensionHostJs(source) {
3838
}
3939

4040
export function patchWebviewBundleJs(source) {
41-
if (source.includes("CODEX_WORKFLOW_FOLD_PATCH_V3")) return source;
41+
if (source.includes("CODEX_WORKFLOW_FOLD_PATCH_V4")) return source;
4242

4343
const exportIdx = source.lastIndexOf("export{");
4444
if (exportIdx === -1) {
@@ -49,7 +49,8 @@ export function patchWebviewBundleJs(source) {
4949
/* CODEX_WORKFLOW_FOLD_PATCH */
5050
/* CODEX_WORKFLOW_FOLD_PATCH_V2 */
5151
/* CODEX_WORKFLOW_FOLD_PATCH_V3 */
52-
function __codexWorkflowCollapseMode(){const m=globalThis.document?.querySelector('meta[name="codex-workflow-collapse"]');const v=m?.getAttribute("content")?.trim();return v==="collapse"||v==="expand"||v==="disable"?v:"disable"}
52+
/* CODEX_WORKFLOW_FOLD_PATCH_V4 */
53+
function __codexWorkflowCollapseMode(){const m=globalThis.document?.querySelector('meta[name="codex-workflow-collapse"]');const v=m?.getAttribute("content")?.trim();return v==="collapse"||v==="expand"||v==="disable"?v:"collapse"}
5354
function __codexWorkflowFormatElapsed(ms){const s=Math.max(0,Math.floor(ms/1e3));const h=Math.floor(s/3600),m=Math.floor((s%3600)/60),ss=s%60;const p=n=>String(n).padStart(2,"0");if(h>0)return \`\${h}h\${p(m)}m\${p(ss)}s\`;return \`\${m}m\${p(ss)}s\`}
5455
function __codexWorkflowFoldItems(items,mode){if(mode==="disable")return items;if(!Array.isArray(items))return items;const out=[];let inTurn=!1;let children=[];let turnIndex=-1;const pushWorkflow=()=>{if(children.length===0)return;out.push({type:"workflow",id:\`workflow-\${turnIndex}\`,children,defaultCollapsed:mode==="collapse"})};for(const it of items){if(it?.type==="user-message"){inTurn=!0;turnIndex++;out.push(it);children=[];continue}if(inTurn&&it?.type==="assistant-message"){pushWorkflow();out.push(it);inTurn=!1;children=[];continue}if(inTurn)children.push(it);else out.push(it)}inTurn&&pushWorkflow();return out}
5556
const __codexOrigMapStateToLocalConversationItems=typeof mapStateToLocalConversationItems==="function"?mapStateToLocalConversationItems:null;

tools/workflow-fold/patcher.test.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test("patchWebviewBundleJs injects workflow fold patch marker", () => {
2323
assert.match(out, /CODEX_WORKFLOW_FOLD_PATCH/);
2424
assert.match(out, /CODEX_WORKFLOW_FOLD_PATCH_V2/);
2525
assert.match(out, /CODEX_WORKFLOW_FOLD_PATCH_V3/);
26+
assert.match(out, /CODEX_WORKFLOW_FOLD_PATCH_V4/);
2627
assert.match(out, /Array\.isArray/);
2728
assert.match(out, /workflow/);
2829
});

0 commit comments

Comments
 (0)