@@ -31,6 +31,7 @@ const {
3131 COMPUTER_USE_UI_ENV_VAR,
3232 COMPUTER_USE_UI_SETTINGS_KEY,
3333 applyLinuxComputerUseFeaturePatch,
34+ applyLinuxComputerUseHostPlatformPatch,
3435 applyLinuxComputerUseInstallFlowPatch,
3536 applyLinuxNativeDesktopAppsHandlerPatch,
3637 applyLinuxComputerUsePluginGatePatch,
@@ -983,6 +984,7 @@ test("default core patch descriptors are grouped and unique", () => {
983984 "subagent-nickname-metadata-shape",
984985 "local-environment-action-modal-draft",
985986 "linux-computer-use-ui-availability",
987+ "linux-computer-use-host-platform",
986988 "linux-computer-use-install-flow",
987989 "linux-app-updater-bridge",
988990 "browser-annotation-screenshot",
@@ -1036,11 +1038,21 @@ test("default core patch descriptors are grouped and unique", () => {
10361038 const computerUseInstallFlow = descriptors.find((descriptor) => descriptor.id === "linux-computer-use-install-flow");
10371039 assert.equal(
10381040 computerUseInstallFlow.pattern.test(
1039- "app-initial~artifact-tab-content.electron~app-main~pull-request-route~pull-request-code-rev~jgoqfqy2 -current.js",
1041+ "app-initial~avatarOverlayCompositionSurface~ artifact-tab-content.electron~notebook-preview-~iaq4jiqv -current.js",
10401042 ),
10411043 true,
10421044 );
10431045 assert.equal(computerUseInstallFlow.pattern.test("app-initial~app-main-current.js"), false);
1046+ const computerUseHostPlatform = descriptors.find(
1047+ (descriptor) => descriptor.id === "linux-computer-use-host-platform",
1048+ );
1049+ assert.equal(
1050+ computerUseHostPlatform.pattern.test(
1051+ "app-initial~artifact-tab-content.electron~notebook-preview-panel~app-main~settings-command-~ekwfx4j1-current.js",
1052+ ),
1053+ true,
1054+ );
1055+ assert.equal(computerUseHostPlatform.pattern.test("app-initial~app-main-current.js"), false);
10441056 assert.equal(
10451057 descriptors.find((descriptor) => descriptor.id === "linux-terminal-user-path")?.ciPolicy,
10461058 "optional",
@@ -8348,40 +8360,40 @@ test("keeps Browser Use route liveness fallback inactive when ambiguous", () =>
83488360test("Computer Use availability descriptor matches the current settings bundle name", () => {
83498361 const [descriptor] = require("./patches/core/all-linux/webview/computer-use-ui/patch.js");
83508362
8351- assert.match("computer-use-settings-CyEHLFtH .js", descriptor.pattern);
8363+ assert.match("computer-use-settings-DsM_pz8i .js", descriptor.pattern);
83528364 assert.doesNotMatch("use-model-settings-5PHNqYL4.js", descriptor.pattern);
83538365 assert.doesNotMatch("use-is-plugins-enabled-current.js", descriptor.pattern);
83548366 assert.doesNotMatch("use-native-apps.electron-DhuUEit1.js", descriptor.pattern);
83558367});
83568368
83578369test("enables the current Computer Use settings contract on Linux", () => {
83588370 const source =
8359- "function Ut (){let e=cache(24),{selectedHostId:t}=host(),n=data(t),r ={hostId:t};" +
8360- "let i =useAvailability(r ),{platform:a }=usePlatform(),o =hostKind(t)===`local`,s =flag(`188145323`);" +
8361- "let d =jsx(Settings,{computerUseAvailability:i ,platform:a });" +
8362- "let m=i .available?jsx(AllowedApps,{}):null;return jsx(Page,{children:[d,m ]})}" +
8363- "function Gt (e){let{computerUseAvailability:n,platform:r }=e,{selectedHostId:o }=host();" +
8364- "let h;h =[];let g =usePlugins(o,h),y =useMarketplacePath(o), b=useFlag(flagArg ),x;" +
8365- "x=selectPlugin(g .availablePlugins,pluginName,y );return x}";
8371+ "function Ht (){let e=cache(24),{selectedHostId:t}=host(),n=data(t),i ={hostId:t};" +
8372+ "let a =useAvailability(i ),{platform:o }=usePlatform(),s =hostKind(t)===`local`,c =flag(`188145323`);" +
8373+ "let f =jsx(Settings,{computerUseAvailability:a ,platform:o });" +
8374+ "let h=a .available?jsx(AllowedApps,{}):null;return jsx(Page,{children:[f,h ]})}" +
8375+ "function Wt (e){let t=cache(35), {computerUseAvailability:n,platform:i }=e,{selectedHostId:s }=host();" +
8376+ "let g =[];let _ =usePlugins(s,g),v =useMarketplacePath(s),y=useFlag(firstFlag), b=useFlag(secondFlag ),x;" +
8377+ "x=selectPlugin(_ .availablePlugins,computerUsePluginName,v );return x}";
83668378
83678379 const patched = applyPatchTwice(applyLinuxComputerUseRendererAvailabilityPatch, source);
83688380
83698381 assert.match(
83708382 patched,
8371- /a ===`linux`&&\(i =\{\.\.\.i ,available:!0,isFetching:!1,isLoading:!1\}\);/,
8383+ /o ===`linux`&&\(a =\{\.\.\.a ,available:!0,isFetching:!1,isLoading:!1\}\);/,
83728384 );
83738385 assert.match(patched, /marketplaceName:`openai-bundled`/);
83748386});
83758387
83768388test("does not report partial current Computer Use settings patches as applied", () => {
83778389 const source =
8378- "function Ut (){let i =useAvailability(arg),{platform:a }=usePlatform(),o =hostKind(hostId);" +
8379- "let d =jsx(Settings,{computerUseAvailability:i ,platform:a });" +
8380- "let m=i .available?jsx(AllowedApps,{}):null;return jsx(Page,{children:[d,m ]})}" +
8381- "function Gt (e){let{computerUseAvailability:n,platform:r }=e;" +
8382- "let g =usePlugins(hostId,empty),y =useMarketplacePath(hostId),b=useFlag(flagArg );" +
8383- "r ===`linux`&&!g .availablePlugins.some(e=>e.plugin?.name===pluginName||e.plugin?.id?.split(`@`)[0]===pluginName)&&(g ={...g ,availablePlugins:[...g .availablePlugins,{marketplaceName:`openai-bundled`,marketplacePath:y ,logoPath:new URL(`computer-use-plugin-icon-linux.png`,import.meta.url).href,logoDarkPath:new URL(`computer-use-plugin-icon-linux.png`,import.meta.url).href,plugin:{id:pluginName,name:pluginName,installed:!0,enabled:!0}}]});" +
8384- "let x;x=selectPlugin(g .availablePlugins,pluginName,y );return x}";
8390+ "function Ht (){let a =useAvailability(arg),{platform:o }=usePlatform(),s =hostKind(hostId);" +
8391+ "let f =jsx(Settings,{computerUseAvailability:a ,platform:o });" +
8392+ "let h=a .available?jsx(AllowedApps,{}):null;return jsx(Page,{children:[f,h ]})}" +
8393+ "function Wt (e){let{computerUseAvailability:n,platform:i }=e;" +
8394+ "let _ =usePlugins(hostId,empty),v =useMarketplacePath(hostId),y=useFlag(firstFlag), b=useFlag(secondFlag );" +
8395+ "i ===`linux`&&!_ .availablePlugins.some(e=>e.plugin?.name===pluginName||e.plugin?.id?.split(`@`)[0]===pluginName)&&(_ ={..._ ,availablePlugins:[..._ .availablePlugins,{marketplaceName:`openai-bundled`,marketplacePath:v ,logoPath:new URL(`computer-use-plugin-icon-linux.png`,import.meta.url).href,logoDarkPath:new URL(`computer-use-plugin-icon-linux.png`,import.meta.url).href,plugin:{id:pluginName,name:pluginName,installed:!0,enabled:!0}}]});" +
8396+ "let x;x=selectPlugin(_ .availablePlugins,pluginName,v );return x}";
83858397
83868398 const { value: patched, warnings } = captureWarns(() =>
83878399 applyLinuxComputerUseRendererAvailabilityPatch(source),
@@ -8393,21 +8405,49 @@ test("does not report partial current Computer Use settings patches as applied",
83938405 ]);
83948406});
83958407
8408+ test("allows the current Computer Use host platform on Linux", () => {
8409+ const source =
8410+ "function Se(e){return e===`macOS`||e===`windows`}" +
8411+ "function Ce(e){let t=cache(16),{enabled:n,hostId:r}=e,i=n===void 0?!0:n,{isLoading:a,platform:o}=usePlatform(),s=flag(`1506311413`),c;t[0]===r?c=t[1]:(c={featureName:`computer_use`,hostId:r},t[0]=r,t[1]=c);let l=useFeature(c),u=o===`windows`&&!a,d=i&&u,f;t[2]===d?f=t[3]:(f={enabled:d},t[2]=d,t[3]=f);let p=useWindowsFeature(f),m=l.isLoading||u&&p.isLoading,h=l.enabled&&(!u||p.enabled),g;t[4]!==h||t[5]!==i||t[6]!==m||t[7]!==s||t[8]!==a||t[9]!==o?(g=resolveAvailability({areRequiredFeaturesEnabled:h,enabled:i,isAnyFeatureLoading:m,isComputerUseGateEnabled:s,isHostCompatiblePlatform:Se(o),isPlatformLoading:a,windowType:`electron`}),t[4]=h,t[5]=i,t[6]=m,t[7]=s,t[8]=a,t[9]=o,t[10]=g):g=t[10];return g}";
8412+
8413+ const patched = applyPatchTwice(applyLinuxComputerUseHostPlatformPatch, source);
8414+
8415+ assert.match(
8416+ patched,
8417+ /g=resolveAvailability\(\{areRequiredFeaturesEnabled:h,enabled:i,isAnyFeatureLoading:m,isComputerUseGateEnabled:s,isHostCompatiblePlatform:o===`linux`\|\|Se\(o\),isPlatformLoading:a,windowType:`electron`\}\)/,
8418+ );
8419+ assert.doesNotMatch(patched, /areRequiredFeaturesEnabled:o===`linux`|isComputerUseGateEnabled:o===`linux`/);
8420+ });
8421+
8422+ test("rejects current Computer Use host-platform drift byte-identically", () => {
8423+ const source =
8424+ "const feature={featureName:`computer_use`};" +
8425+ "result=helper({areRequiredFeaturesEnabled:a,enabled:b,isAnyFeatureLoading:c,isComputerUseGateEnabled:d,isHostCompatiblePlatform:drifted(platform,other),isPlatformLoading:e,windowType:`electron`})";
8426+
8427+ const { value: patched, warnings } = captureWarns(() =>
8428+ applyLinuxComputerUseHostPlatformPatch(source),
8429+ );
8430+
8431+ assert.equal(patched, source);
8432+ assert.deepEqual(warnings, [
8433+ "WARN: Could not find current Computer Use host-platform gate — skipping Linux Computer Use host-platform patch",
8434+ ]);
8435+ });
8436+
83968437test("loads current Computer Use plugin details on Linux despite the upstream availability gate", () => {
83978438 const source =
8398- "function usePluginDetail(e){let{hostId:n,marketplacePath:r,pluginName:i,remoteMarketplaceName:a,enabled:o}=e," +
8399- "s=o===void 0?!0:o,c=n??`local`,u=hostReady(c),f;i==null?f=!1:f=isAvailabilityGated(i);" +
8400- "cache[2]===i?f=cache[3]:(f=i!=null&&isAvailabilityGated(i),cache[2]=i,cache[3]=f);" +
8401- "let p=f,m;cache[4]!==c||cache[5]!==p?(m={enabled:p,hostId:c},cache[4]=c,cache[5]=p):m=cache[6];" +
8402- "let h=useComputerUseAvailability(m),g=(r!=null||a!=null)&&i!=null," +
8403- "loading=u&&s&&g&&p&&h.isLoading,v=u&&s&&g&&(!p||h.available);" +
8404- "let query=()=>{if(i==null)throw Error(`plugin detail query requires pluginName`);return read(`read-plugin`,{hostId:c,pluginName:i})};" +
8405- "return useQuery({queryFn:query,enabled:v})}";
8439+ "function Ke(e){let t=cache(31),{hostId:n,marketplacePath:r,pluginName:i,remoteMarketplaceName:a,enabled:o}=e," +
8440+ "c=o===void 0?!0:o,l=n??`local`,d;t[0]===l?d=t[1]:(d={hostId:l},t[0]=l,t[1]=d);" +
8441+ "let f=hostReady(d),p=environment(),m;t[2]===i?m=t[3]:(m=i!=null&&isAvailabilityGated(i),t[2]=i,t[3]=m);" +
8442+ "let g=m,_;t[4]!==l||t[5]!==g?(_={enabled:g,hostId:l},t[4]=l,t[5]=g,t[6]=_):_=t[6];" +
8443+ "let v=useComputerUseAvailability(_),y=(r!=null||a!=null)&&i!=null,b=f&&c&&y&&g&&v.isLoading,x=f&&c&&y&&(!g||v.available);" +
8444+ "let query=async()=>{if(i==null)throw Error(`plugin detail query requires pluginName`);return read(`read-plugin`,{hostId:l,pluginName:i})};" +
8445+ "return useQuery({queryFn:query,enabled:x})}";
84068446
84078447 const patched = applyPatchTwice(applyLinuxComputerUseInstallFlowPatch, source);
84088448
8409- assert.match(patched, /let p=f &&i!==`computer-use`,m ;/);
8410- assert.doesNotMatch(patched, /let p=f,m ;/);
8449+ assert.match(patched, /let g=m &&i!==`computer-use`,_ ;/);
8450+ assert.doesNotMatch(patched, /let g=m,_ ;/);
84118451});
84128452
84138453test("rejects current Computer Use plugin detail drift byte-identically", () => {
@@ -9274,50 +9314,71 @@ test("patchExtractedApp scans current Computer Use settings bundles when UI is e
92749314 ].join(""),
92759315 );
92769316 fs.writeFileSync(
9277- path.join(assetsDir, "computer-use-settings-CyEHLFtH.js"),
9278- "function Ut(){let i=useAvailability(arg),{platform:a}=usePlatform(),o=hostKind(hostId);" +
9279- "let d=jsx(Settings,{computerUseAvailability:i,platform:a});let m=i.available?jsx(AllowedApps,{}):null;return jsx(Page,{children:[d,m]})}" +
9280- "function Gt(e){let{computerUseAvailability:n,platform:r}=e;let h;h=[];" +
9281- "let g=usePlugins(hostId,h),y=useMarketplacePath(hostId),b=useFlag(flagArg),x;" +
9282- "x=selectPlugin(g.availablePlugins,pluginName,y);return x}",
9317+ path.join(assetsDir, "computer-use-settings-DsM_pz8i.js"),
9318+ "function Ht(){let e=cache(24),{selectedHostId:t}=host(),n=data(t),i={hostId:t};" +
9319+ "let a=useAvailability(i),{platform:o}=usePlatform(),s=hostKind(t)===`local`,c=flag(`188145323`);" +
9320+ "let f=jsx(Settings,{computerUseAvailability:a,platform:o});let h=a.available?jsx(AllowedApps,{}):null;return jsx(Page,{children:[f,h]})}" +
9321+ "function Wt(e){let t=cache(35),{computerUseAvailability:n,platform:i}=e,{selectedHostId:s}=host();" +
9322+ "let g=[];let _=usePlugins(s,g),v=useMarketplacePath(s),y=useFlag(firstFlag),b=useFlag(secondFlag),x;" +
9323+ "x=selectPlugin(_.availablePlugins,computerUsePluginName,v);return x}",
9324+ );
9325+ fs.writeFileSync(
9326+ path.join(
9327+ assetsDir,
9328+ "app-initial~avatarOverlayCompositionSurface~artifact-tab-content.electron~notebook-preview-~iaq4jiqv-current.js",
9329+ ),
9330+ "function Ke(e){let t=cache(31),{hostId:n,marketplacePath:r,pluginName:i,remoteMarketplaceName:a,enabled:o}=e," +
9331+ "c=o===void 0?!0:o,l=n??`local`,d;t[0]===l?d=t[1]:(d={hostId:l},t[0]=l,t[1]=d);" +
9332+ "let f=hostReady(d),p=environment(),m;t[2]===i?m=t[3]:(m=i!=null&&isAvailabilityGated(i),t[2]=i,t[3]=m);" +
9333+ "let g=m,_;t[4]!==l||t[5]!==g?(_={enabled:g,hostId:l},t[4]=l,t[5]=g,t[6]=_):_=t[6];" +
9334+ "let v=useComputerUseAvailability(_),y=(r!=null||a!=null)&&i!=null,b=f&&c&&y&&g&&v.isLoading,x=f&&c&&y&&(!g||v.available);" +
9335+ "let query=async()=>{if(i==null)throw Error(`plugin detail query requires pluginName`);return read(`read-plugin`,{hostId:l,pluginName:i})};" +
9336+ "return useQuery({queryFn:query,enabled:x})}",
92839337 );
92849338 fs.writeFileSync(
92859339 path.join(
92869340 assetsDir,
9287- "app-initial~artifact-tab-content.electron~app-main~pull-request-route~pull-request-code-rev~jgoqfqy2 -current.js",
9341+ "app-initial~artifact-tab-content.electron~notebook-preview-panel~ app-main~settings-command-~ekwfx4j1 -current.js",
92889342 ),
9289- "function usePluginDetail(e){let{hostId:n,marketplacePath:r,pluginName:i,remoteMarketplaceName:a,enabled:o}=e," +
9290- "s=o===void 0?!0:o,c=n??`local`,u=hostReady(c),f;i==null?f=!1:f=isAvailabilityGated(i);" +
9291- "cache[2]===i?f=cache[3]:(f=i!=null&&isAvailabilityGated(i),cache[2]=i,cache[3]=f);" +
9292- "let p=f,m;cache[4]!==c||cache[5]!==p?(m={enabled:p,hostId:c},cache[4]=c,cache[5]=p):m=cache[6];" +
9293- "let h=useComputerUseAvailability(m),g=(r!=null||a!=null)&&i!=null," +
9294- "loading=u&&s&&g&&p&&h.isLoading,v=u&&s&&g&&(!p||h.available);" +
9295- "let query=()=>{if(i==null)throw Error(`plugin detail query requires pluginName`);return read(`read-plugin`,{hostId:c,pluginName:i})};" +
9296- "return useQuery({queryFn:query,enabled:v})}",
9343+ "function Se(e){return e===`macOS`||e===`windows`}" +
9344+ "function Ce(e){let t=cache(16),{enabled:n,hostId:r}=e,i=n===void 0?!0:n,{isLoading:a,platform:o}=usePlatform(),s=flag(`1506311413`),c;t[0]===r?c=t[1]:(c={featureName:`computer_use`,hostId:r},t[0]=r,t[1]=c);let l=useFeature(c),u=o===`windows`&&!a,d=i&&u,f;t[2]===d?f=t[3]:(f={enabled:d},t[2]=d,t[3]=f);let p=useWindowsFeature(f),m=l.isLoading||u&&p.isLoading,h=l.enabled&&(!u||p.enabled),g;t[4]!==h||t[5]!==i||t[6]!==m||t[7]!==s||t[8]!==a||t[9]!==o?(g=resolveAvailability({areRequiredFeaturesEnabled:h,enabled:i,isAnyFeatureLoading:m,isComputerUseGateEnabled:s,isHostCompatiblePlatform:Se(o),isPlatformLoading:a,windowType:`electron`}),t[4]=h,t[5]=i,t[6]=m,t[7]=s,t[8]=a,t[9]=o,t[10]=g):g=t[10];return g}",
92979345 );
92989346 fs.writeFileSync(path.join(tempRoot, "package.json"), JSON.stringify({ name: "codex" }));
92999347
93009348 const firstReport = createPatchReport();
93019349 patchExtractedApp(tempRoot, { report: firstReport });
93029350
9303- const settingsPath = path.join(assetsDir, "computer-use-settings-CyEHLFtH .js");
9351+ const settingsPath = path.join(assetsDir, "computer-use-settings-DsM_pz8i .js");
93049352 const detailPath = path.join(
93059353 assetsDir,
9306- "app-initial~artifact-tab-content.electron~app-main~pull-request-route~pull-request-code-rev~jgoqfqy2-current.js",
9354+ "app-initial~avatarOverlayCompositionSurface~artifact-tab-content.electron~notebook-preview-~iaq4jiqv-current.js",
9355+ );
9356+ const hostPlatformPath = path.join(
9357+ assetsDir,
9358+ "app-initial~artifact-tab-content.electron~notebook-preview-panel~app-main~settings-command-~ekwfx4j1-current.js",
93079359 );
93089360 const patchedSettings = fs.readFileSync(settingsPath, "utf8");
93099361 const patchedDetail = fs.readFileSync(detailPath, "utf8");
9362+ const patchedHostPlatform = fs.readFileSync(hostPlatformPath, "utf8");
93109363
93119364 assert.match(
93129365 patchedSettings,
9313- /a ===`linux`&&\(i =\{\.\.\.i ,available:!0,isFetching:!1,isLoading:!1\}\);/,
9366+ /o ===`linux`&&\(a =\{\.\.\.a ,available:!0,isFetching:!1,isLoading:!1\}\);/,
93149367 );
93159368 assert.match(patchedSettings, /marketplaceName:`openai-bundled`/);
9316- assert.match(patchedDetail, /let p=f &&i!==`computer-use`,m ;/);
9369+ assert.match(patchedDetail, /let g=m &&i!==`computer-use`,_ ;/);
93179370 assert.equal(
93189371 firstReport.patches.find((patch) => patch.name === "linux-computer-use-ui-availability")?.status,
93199372 "applied",
93209373 );
9374+ assert.match(
9375+ patchedHostPlatform,
9376+ /g=resolveAvailability\(\{areRequiredFeaturesEnabled:h,enabled:i,isAnyFeatureLoading:m,isComputerUseGateEnabled:s,isHostCompatiblePlatform:o===`linux`\|\|Se\(o\),isPlatformLoading:a,windowType:`electron`\}\)/,
9377+ );
9378+ assert.equal(
9379+ firstReport.patches.find((patch) => patch.name === "linux-computer-use-host-platform")?.status,
9380+ "applied",
9381+ );
93219382 assert.equal(
93229383 firstReport.patches.find((patch) => patch.name === "linux-computer-use-install-flow")?.status,
93239384 "applied",
@@ -9328,10 +9389,15 @@ test("patchExtractedApp scans current Computer Use settings bundles when UI is e
93289389
93299390 assert.equal(fs.readFileSync(settingsPath, "utf8"), patchedSettings);
93309391 assert.equal(fs.readFileSync(detailPath, "utf8"), patchedDetail);
9392+ assert.equal(fs.readFileSync(hostPlatformPath, "utf8"), patchedHostPlatform);
93319393 assert.equal(
93329394 secondReport.patches.find((patch) => patch.name === "linux-computer-use-ui-availability")?.status,
93339395 "already-applied",
93349396 );
9397+ assert.equal(
9398+ secondReport.patches.find((patch) => patch.name === "linux-computer-use-host-platform")?.status,
9399+ "already-applied",
9400+ );
93359401 assert.equal(
93369402 secondReport.patches.find((patch) => patch.name === "linux-computer-use-install-flow")?.status,
93379403 "already-applied",
0 commit comments