@@ -709,6 +709,97 @@ describe("deriveWorkLogEntries", () => {
709709 expect ( entry ?. command ) . toBe ( "bun run lint" ) ;
710710 } ) ;
711711
712+ it ( "unwraps PowerShell command wrappers for displayed command text" , ( ) => {
713+ const activities : OrchestrationThreadActivity [ ] = [
714+ makeActivity ( {
715+ id : "command-tool-windows-wrapper" ,
716+ kind : "tool.completed" ,
717+ summary : "Ran command" ,
718+ payload : {
719+ itemType : "command_execution" ,
720+ data : {
721+ item : {
722+ command : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -Command 'bun run lint'" ,
723+ } ,
724+ } ,
725+ } ,
726+ } ) ,
727+ ] ;
728+
729+ const [ entry ] = deriveWorkLogEntries ( activities , undefined ) ;
730+ expect ( entry ?. command ) . toBe ( "bun run lint" ) ;
731+ expect ( entry ?. rawCommand ) . toBe (
732+ "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -Command 'bun run lint'" ,
733+ ) ;
734+ } ) ;
735+
736+ it ( "unwraps PowerShell command wrappers from argv-style command payloads" , ( ) => {
737+ const activities : OrchestrationThreadActivity [ ] = [
738+ makeActivity ( {
739+ id : "command-tool-windows-wrapper-argv" ,
740+ kind : "tool.completed" ,
741+ summary : "Ran command" ,
742+ payload : {
743+ itemType : "command_execution" ,
744+ data : {
745+ item : {
746+ command : [ "C:\\Program Files\\PowerShell\\7\\pwsh.exe" , "-Command" , "rg -n foo ." ] ,
747+ } ,
748+ } ,
749+ } ,
750+ } ) ,
751+ ] ;
752+
753+ const [ entry ] = deriveWorkLogEntries ( activities , undefined ) ;
754+ expect ( entry ?. command ) . toBe ( "rg -n foo ." ) ;
755+ expect ( entry ?. rawCommand ) . toBe (
756+ '"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -Command "rg -n foo ."' ,
757+ ) ;
758+ } ) ;
759+
760+ it ( "extracts command text from command detail when structured command metadata is missing" , ( ) => {
761+ const activities : OrchestrationThreadActivity [ ] = [
762+ makeActivity ( {
763+ id : "command-tool-windows-detail-fallback" ,
764+ kind : "tool.completed" ,
765+ summary : "Ran command" ,
766+ payload : {
767+ itemType : "command_execution" ,
768+ detail :
769+ '"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -NoLogo -NoProfile -Command \'rg -n -F "new Date()" .\' <exited with exit code 0>' ,
770+ } ,
771+ } ) ,
772+ ] ;
773+
774+ const [ entry ] = deriveWorkLogEntries ( activities , undefined ) ;
775+ expect ( entry ?. command ) . toBe ( 'rg -n -F "new Date()" .' ) ;
776+ expect ( entry ?. rawCommand ) . toBe (
777+ `"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -NoLogo -NoProfile -Command 'rg -n -F "new Date()" .'` ,
778+ ) ;
779+ } ) ;
780+
781+ it ( "does not unwrap shell commands when no wrapper flag is present" , ( ) => {
782+ const activities : OrchestrationThreadActivity [ ] = [
783+ makeActivity ( {
784+ id : "command-tool-shell-script" ,
785+ kind : "tool.completed" ,
786+ summary : "Ran command" ,
787+ payload : {
788+ itemType : "command_execution" ,
789+ data : {
790+ item : {
791+ command : "bash script.sh" ,
792+ } ,
793+ } ,
794+ } ,
795+ } ) ,
796+ ] ;
797+
798+ const [ entry ] = deriveWorkLogEntries ( activities , undefined ) ;
799+ expect ( entry ?. command ) . toBe ( "bash script.sh" ) ;
800+ expect ( entry ?. rawCommand ) . toBeUndefined ( ) ;
801+ } ) ;
802+
712803 it ( "keeps compact Codex tool metadata used for icons and labels" , ( ) => {
713804 const activities : OrchestrationThreadActivity [ ] = [
714805 makeActivity ( {
0 commit comments