Skip to content

fix: streaming token usage - #102

Merged
pomelo-nwu merged 1 commit into
mainfrom
feature/fan/fix-token-usage
Jul 24, 2025
Merged

fix: streaming token usage#102
pomelo-nwu merged 1 commit into
mainfrom
feature/fan/fix-token-usage

Conversation

@koalazf99

Copy link
Copy Markdown
Collaborator

TLDR

Dive Deeper

Reviewer Test Plan

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage Summary

Package Lines Statements Functions Branches
CLI 72.2% 72.2% 75.22% 78.46%
Core 66.01% 66.01% 72.88% 77.19%
CLI Package - Full Text Report
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |    72.2 |    78.46 |   75.22 |    72.2 |                   
 src               |   48.18 |    53.84 |      50 |   48.18 |                   
  gemini.tsx       |   17.97 |     12.5 |   16.66 |   17.97 | ...48-265,270-344 
  ...ractiveCli.ts |    83.4 |    61.36 |     100 |    83.4 | ...46,249,272-273 
 src/config        |   86.23 |     78.8 |   76.47 |   86.23 |                   
  auth.ts          |      75 |    93.33 |      25 |      75 | ...53,56-57,60-61 
  config.ts        |   95.96 |    83.33 |    62.5 |   95.96 | ...73,280,406-410 
  extension.ts     |   81.66 |    84.37 |     100 |   81.66 | ...00-104,113-114 
  sandboxConfig.ts |   54.05 |       50 |   66.66 |   54.05 | ...43,53-69,74-91 
  settings.ts      |   86.43 |    76.92 |   92.85 |   86.43 | ...45-346,386-387 
 src/generated     |     100 |      100 |     100 |     100 |                   
  git-commit.ts    |     100 |      100 |     100 |     100 |                   
 src/services      |     100 |      100 |     100 |     100 |                   
  ...andService.ts |     100 |      100 |     100 |     100 |                   
 src/test-utils    |     100 |      100 |     100 |     100 |                   
  ...andContext.ts |     100 |      100 |     100 |     100 |                   
 src/ui            |   60.41 |    64.13 |   69.56 |   60.41 |                   
  App.tsx          |   58.25 |    58.44 |   66.66 |   58.25 | ...06-917,939-968 
  colors.ts        |   86.04 |      100 |   76.92 |   86.04 | 12-13,18-19,42-43 
  constants.ts     |       0 |        0 |       0 |       0 | 1-15              
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/ui/commands   |   99.43 |    83.87 |      90 |   99.43 |                   
  aboutCommand.ts  |     100 |    55.55 |     100 |     100 | 22-29             
  authCommand.ts   |     100 |      100 |     100 |     100 |                   
  clearCommand.ts  |     100 |      100 |     100 |     100 |                   
  helpCommand.ts   |     100 |      100 |     100 |     100 |                   
  memoryCommand.ts |     100 |      100 |     100 |     100 |                   
  ...acyCommand.ts |     100 |      100 |     100 |     100 |                   
  themeCommand.ts  |     100 |      100 |     100 |     100 |                   
  types.ts         |       0 |        0 |       0 |       0 | 1                 
 src/ui/components |   69.09 |    71.84 |      65 |   69.09 |                   
  AboutBox.tsx     |     100 |       50 |     100 |     100 | 102               
  AsciiArt.ts      |     100 |      100 |     100 |     100 |                   
  AuthDialog.tsx   |   71.53 |       85 |      40 |   71.53 | ...18-122,128-134 
  ...nProgress.tsx |   15.78 |      100 |       0 |   15.78 | 17-57             
  ...Indicator.tsx |   15.15 |      100 |       0 |   15.15 | 17-47             
  ...ryDisplay.tsx |   21.05 |      100 |       0 |   21.05 | 17-35             
  ...ryDisplay.tsx |   97.82 |    95.83 |     100 |   97.82 | 59                
  ...esDisplay.tsx |   10.52 |      100 |       0 |   10.52 | 24-82             
  ...ngsDialog.tsx |    6.76 |      100 |       0 |    6.76 | 26-168            
  Footer.tsx       |   67.44 |       10 |     100 |   67.44 | ...06-113,116-119 
  ...ngSpinner.tsx |      80 |    33.33 |     100 |      80 | 29,31-32          
  Header.tsx       |   17.07 |      100 |       0 |   17.07 | 22-63             
  Help.tsx         |    3.73 |      100 |       0 |    3.73 | 17-154            
  ...emDisplay.tsx |   68.65 |    57.14 |     100 |   68.65 | ...55-60,79-86,89 
  InputPrompt.tsx  |   81.81 |    71.81 |     100 |   81.81 | ...86,430,458-462 
  ...Indicator.tsx |     100 |      100 |     100 |     100 |                   
  ...geDisplay.tsx |   25.92 |      100 |       0 |   25.92 | 14-36             
  ...tsDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...KeyPrompt.tsx |   62.33 |    31.25 |     100 |   62.33 | ...58-111,115-123 
  ...ryDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...Indicator.tsx |   44.44 |      100 |       0 |   44.44 | 12-17             
  ...MoreLines.tsx |      60 |       25 |     100 |      60 | 24-27,33-40       
  StatsDisplay.tsx |   98.39 |    86.66 |     100 |   98.39 | 173-175           
  ...nsDisplay.tsx |   83.05 |    61.53 |     100 |   83.05 | 34-39,42-43,87-89 
  ThemeDialog.tsx  |   84.26 |    31.25 |     100 |   84.26 | ...06-111,211-222 
  Tips.tsx         |      16 |      100 |       0 |      16 | 17-45             
  ...tsDisplay.tsx |     100 |     87.5 |     100 |     100 | 30-31             
  ...ification.tsx |   36.36 |      100 |       0 |   36.36 | 15-22             
 ...nents/messages |   62.67 |     80.9 |   57.89 |   62.67 |                   
  ...onMessage.tsx |   18.51 |      100 |       0 |   18.51 | 22-49             
  DiffRenderer.tsx |   96.31 |    82.66 |     100 |   96.31 | ...01-202,206,271 
  ErrorMessage.tsx |   22.22 |      100 |       0 |   22.22 | 16-31             
  ...niMessage.tsx |   18.51 |      100 |       0 |   18.51 | 20-43             
  ...geContent.tsx |   19.04 |      100 |       0 |   19.04 | 25-43             
  InfoMessage.tsx  |     100 |      100 |     100 |     100 |                   
  ...onMessage.tsx |   38.91 |     62.5 |   33.33 |   38.91 | ...32-164,200-225 
  ...upMessage.tsx |     9.3 |      100 |       0 |     9.3 | 26-123            
  ToolMessage.tsx  |   87.76 |       80 |     100 |   87.76 | ...,91-95,169-171 
  UserMessage.tsx  |     100 |      100 |     100 |     100 |                   
  ...llMessage.tsx |   36.36 |      100 |       0 |   36.36 | 17-25             
 ...ponents/shared |   73.43 |    69.94 |   91.66 |   73.43 |                   
  MaxSizedBox.tsx  |   78.51 |    79.24 |   88.88 |   78.51 | ...36-438,537-538 
  ...tonSelect.tsx |   66.66 |    57.14 |     100 |   66.66 | ...28,156-157,184 
  text-buffer.ts   |   72.44 |    67.24 |    92.3 |   72.44 | ...1235-1238,1243 
 src/ui/contexts   |   90.57 |    86.36 |     100 |   90.57 |                   
  ...owContext.tsx |   91.07 |    81.81 |     100 |   91.07 | 46-47,59-61       
  ...onContext.tsx |   94.11 |      100 |     100 |   94.11 | 101-104           
  ...ngContext.tsx |   71.42 |       50 |     100 |   71.42 | 17-20             
 src/ui/editors    |   93.87 |    85.71 |   66.66 |   93.87 |                   
  ...ngsManager.ts |   93.87 |    85.71 |   66.66 |   93.87 | 53,67-68          
 src/ui/hooks      |   72.39 |    82.74 |   68.05 |   72.39 |                   
  ...dProcessor.ts |   82.07 |    82.75 |     100 |   82.07 | ...92-395,406-422 
  ...dProcessor.ts |      82 |    74.35 |      80 |      82 | ...15-324,328-329 
  ...dProcessor.ts |   63.71 |    76.51 |   47.36 |   63.71 | ...1191-1196,1199 
  ...uthCommand.ts |    7.81 |      100 |       0 |    7.81 | 18-88             
  ...tIndicator.ts |     100 |      100 |     100 |     100 |                   
  ...ketedPaste.ts |     100 |      100 |     100 |     100 |                   
  useCompletion.ts |   78.17 |    89.68 |      80 |   78.17 | ...14-420,497-500 
  ...leMessages.ts |   96.96 |    88.88 |     100 |   96.96 | 25-26             
  ...orSettings.ts |     100 |      100 |     100 |     100 |                   
  ...miniStream.ts |   67.53 |    70.22 |     100 |   67.53 | ...55-756,786-876 
  ...BranchName.ts |   91.66 |    84.61 |     100 |   91.66 | 57-63             
  ...oryManager.ts |   98.41 |    93.33 |     100 |   98.41 | 43                
  ...putHistory.ts |    92.5 |    85.71 |     100 |    92.5 | 62-63,71,93-95    
  useKeypress.ts   |     100 |      100 |     100 |     100 |                   
  ...gIndicator.ts |     100 |      100 |     100 |     100 |                   
  useLogger.ts     |      25 |      100 |       0 |      25 | 14-32             
  ...raseCycler.ts |    95.5 |       75 |     100 |    95.5 | ...66-167,185-187 
  ...cySettings.ts |     4.5 |      100 |       0 |     4.5 | 23-139            
  ...lScheduler.ts |   79.01 |    94.87 |     100 |   79.01 | ...00-203,293-303 
  ...oryCommand.ts |       0 |        0 |       0 |       0 | 1-7               
  ...ellHistory.ts |   91.95 |    79.16 |   83.33 |   91.95 | 28-30,41-42,87-88 
  ...oryCommand.ts |       0 |        0 |       0 |       0 | 1-75              
  ...tateAndRef.ts |   95.45 |    66.66 |     100 |   95.45 | 25                
  ...rminalSize.ts |   77.27 |      100 |      50 |   77.27 | 19-23             
  ...emeCommand.ts |   64.28 |     87.5 |     100 |   64.28 | ...,92-93,100-106 
  useTimer.ts      |   88.09 |    85.71 |     100 |   88.09 | 44-45,51-53       
 src/ui/privacy    |   13.77 |      100 |       0 |   13.77 |                   
  ...acyNotice.tsx |    9.58 |      100 |       0 |    9.58 | 20-113            
  ...acyNotice.tsx |    12.9 |      100 |       0 |    12.9 | 15-55             
  ...acyNotice.tsx |   10.81 |      100 |       0 |   10.81 | 15-58             
  ...acyNotice.tsx |   30.76 |      100 |       0 |   30.76 | 19-36,39-41       
 src/ui/themes     |   99.47 |    90.47 |     100 |   99.47 |                   
  ansi-light.ts    |     100 |      100 |     100 |     100 |                   
  ansi.ts          |     100 |      100 |     100 |     100 |                   
  atom-one-dark.ts |     100 |      100 |     100 |     100 |                   
  ayu-light.ts     |     100 |      100 |     100 |     100 |                   
  ayu.ts           |     100 |      100 |     100 |     100 |                   
  default-light.ts |     100 |      100 |     100 |     100 |                   
  default.ts       |     100 |      100 |     100 |     100 |                   
  dracula.ts       |     100 |      100 |     100 |     100 |                   
  github-dark.ts   |     100 |      100 |     100 |     100 |                   
  github-light.ts  |     100 |      100 |     100 |     100 |                   
  googlecode.ts    |     100 |      100 |     100 |     100 |                   
  no-color.ts      |     100 |      100 |     100 |     100 |                   
  qwen-dark.ts     |     100 |      100 |     100 |     100 |                   
  qwen-light.ts    |     100 |      100 |     100 |     100 |                   
  ...-of-purple.ts |     100 |      100 |     100 |     100 |                   
  theme-manager.ts |    90.9 |    86.95 |     100 |    90.9 | ...14-119,124-125 
  theme.ts         |   98.44 |    94.73 |     100 |   98.44 | 304-307           
  xcode.ts         |     100 |      100 |     100 |     100 |                   
 src/ui/utils      |   74.97 |    88.84 |      94 |   74.97 |                   
  ...Colorizer.tsx |   77.11 |       84 |     100 |   77.11 | ...19-122,159-183 
  ...olePatcher.ts |   60.97 |      100 |   66.66 |   60.97 | 35-39,49-60       
  ...nRenderer.tsx |   26.51 |       75 |     100 |   26.51 | 32-137            
  ...wnDisplay.tsx |   86.19 |    87.69 |     100 |   86.19 | ...71-279,311-332 
  ...eRenderer.tsx |   78.09 |    76.19 |     100 |   78.09 | 55-83             
  ...boardUtils.ts |   32.25 |     37.5 |     100 |   32.25 | ...55-114,129-145 
  commandUtils.ts  |     100 |      100 |     100 |     100 |                   
  computeStats.ts  |     100 |      100 |     100 |     100 |                   
  displayUtils.ts  |     100 |      100 |     100 |     100 |                   
  errorParsing.ts  |     100 |     92.5 |     100 |     100 | 73,77,83          
  formatters.ts    |   90.47 |    95.83 |     100 |   90.47 | 57-60             
  ...nUtilities.ts |   69.84 |    85.71 |     100 |   69.84 | 75-91,100-101     
  textUtils.ts     |   81.81 |      100 |      80 |   81.81 | 13-18             
  updateCheck.ts   |     100 |      100 |     100 |     100 |                   
 src/utils         |   10.94 |    83.33 |   63.63 |   10.94 |                   
  cleanup.ts       |      64 |    66.66 |   66.66 |      64 | 18-26,35          
  package.ts       |   88.88 |    85.71 |     100 |   88.88 | 33-34             
  readStdin.ts     |    3.44 |      100 |       0 |    3.44 | 7-39              
  sandbox.ts       |       0 |        0 |       0 |       0 | 1-871             
  ...upWarnings.ts |   23.07 |      100 |       0 |   23.07 | 14-40             
  ...upWarnings.ts |     100 |      100 |     100 |     100 |                   
  version.ts       |     100 |       50 |     100 |     100 | 11                
-------------------|---------|----------|---------|---------|-------------------
Core Package - Full Text Report
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |   66.01 |    77.19 |   72.88 |   66.01 |                   
 src               |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
 src/__mocks__/fs  |     100 |      100 |     100 |     100 |                   
  promises.ts      |     100 |      100 |     100 |     100 |                   
 src/code_assist   |   66.94 |    75.75 |   68.29 |   66.94 |                   
  codeAssist.ts    |    23.8 |      100 |       0 |    23.8 | 13-29             
  converter.ts     |   89.06 |    96.15 |   81.81 |   89.06 | 176-180,199-209   
  oauth2.ts        |   79.34 |    65.11 |      80 |   79.34 | ...38-339,351-357 
  server.ts        |    36.4 |    81.81 |      50 |    36.4 | ...67-291,294-296 
  setup.ts         |   72.41 |     62.5 |     100 |   72.41 | 52-53,64-66,75-85 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/config        |    79.6 |    83.33 |   60.31 |    79.6 |                   
  config.ts        |    79.4 |    83.33 |   60.31 |    79.4 | ...72-579,585-586 
  models.ts        |     100 |      100 |     100 |     100 |                   
 src/core          |   56.29 |     66.6 |   72.41 |   56.29 |                   
  client.ts        |   74.04 |    76.34 |   83.33 |   74.04 | ...75,677-678,681 
  ...tGenerator.ts |   80.19 |       76 |     100 |   80.19 | ...22,152,163-180 
  ...lScheduler.ts |   72.07 |    69.33 |   81.25 |   72.07 | ...51-657,674-683 
  geminiChat.ts    |   62.85 |    71.79 |   64.28 |   62.85 | ...17,632,636-644 
  geminiRequest.ts |     100 |      100 |     100 |     100 |                   
  logger.ts        |   82.71 |    78.26 |     100 |   82.71 | ...72-276,285-286 
  modelCheck.ts    |   76.74 |       25 |     100 |   76.74 | 26-27,56-60,64-67 
  ...olExecutor.ts |     100 |    66.66 |     100 |     100 | 64,99             
  ...tGenerator.ts |   24.51 |    29.59 |   43.47 |   24.51 | ...1747,1753-1774 
  prompts.ts       |   81.25 |    68.18 |      50 |   81.25 | ...61-266,282-339 
  tokenLimits.ts   |      15 |      100 |       0 |      15 | 15-31             
  turn.ts          |   82.03 |    82.14 |     100 |   82.03 | ...32-235,248-249 
 src/services      |   84.52 |    86.66 |   80.76 |   84.52 |                   
  ...eryService.ts |   77.33 |       75 |   85.71 |   77.33 | ...1-62,84,91-103 
  gitService.ts    |   77.52 |      100 |      60 |   77.52 | ...08-112,115-119 
  ...ionService.ts |   96.03 |    88.46 |     100 |   96.03 | 90-91,101-102     
 src/telemetry     |   70.87 |    84.21 |   82.35 |   70.87 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...t.circular.ts |       0 |        0 |       0 |       0 | 1-62              
  ...t.circular.ts |       0 |        0 |       0 |       0 | 1-119             
  loggers.ts       |   79.13 |    81.81 |      80 |   79.13 | 186-225,294-311   
  metrics.ts       |   60.36 |    95.65 |    62.5 |   60.36 | ...36-158,161-184 
  sdk.ts           |   82.85 |    28.57 |     100 |   82.85 | ...18,126-127,133 
  types.ts         |   83.54 |    93.75 |   88.23 |   83.54 | 83-92,162-191     
  uiTelemetry.ts   |   99.18 |    95.65 |     100 |   99.18 | 119               
 ...learcut-logger |   81.85 |    79.41 |   73.68 |   81.85 |                   
  ...cut-logger.ts |   81.59 |    78.78 |   77.77 |   81.59 | ...66-478,481-483 
  ...tadata-key.ts |      84 |      100 |       0 |      84 | 163-173           
 src/tools         |   64.53 |    78.36 |   70.58 |   64.53 |                   
  diffOptions.ts   |     100 |      100 |     100 |     100 |                   
  edit.ts          |   77.41 |    82.85 |   81.81 |   77.41 | ...30-431,435-470 
  glob.ts          |   85.22 |    80.95 |   83.33 |   85.22 | ...67-268,276-283 
  grep.ts          |   57.25 |     75.8 |   72.72 |   57.25 | ...31-536,541-545 
  ls.ts            |    9.82 |      100 |   14.28 |    9.82 | ...58-163,171-284 
  mcp-client.ts    |   49.34 |    75.75 |   35.71 |   49.34 | ...01-405,409-412 
  mcp-tool.ts      |   91.75 |    85.71 |     100 |   91.75 | ...36,142,147-148 
  memoryTool.ts    |   97.45 |    84.84 |     100 |   97.45 | 94,96,98-99       
  ...iable-tool.ts |     100 |    84.61 |     100 |     100 | 90,97             
  read-file.ts     |   98.29 |    96.15 |     100 |   98.29 | 112-113           
  ...many-files.ts |   80.53 |    70.45 |      80 |   80.53 | ...30-431,438-439 
  shell.ts         |      65 |       65 |   78.57 |      65 | ...54,471,477-489 
  tool-registry.ts |   58.39 |     74.5 |   78.57 |   58.39 | ...00-305,311-312 
  tools.ts         |   76.31 |      100 |      40 |   76.31 | ...44-145,154-159 
  web-fetch.ts     |   27.46 |    72.22 |   66.66 |   27.46 | ...15-216,244-388 
  web-search.ts    |   12.17 |      100 |      20 |   12.17 | ...03-104,107-196 
  write-file.ts    |   80.95 |    83.67 |   77.77 |   80.95 | ...00-305,367-397 
 src/utils         |   70.37 |    81.62 |   77.53 |   70.37 |                   
  LruCache.ts      |   70.96 |     62.5 |     100 |   70.96 | 20-22,28,30-34    
  bfsFileSearch.ts |   92.45 |    86.66 |     100 |   92.45 | 53-54,67-68       
  editCorrector.ts |   77.35 |    61.11 |   91.66 |   77.35 | ...70-682,716,730 
  editor.ts        |   97.33 |    93.75 |     100 |   97.33 | 134,196,199-200   
  ...rReporting.ts |   83.52 |    84.61 |     100 |   83.52 | 81-85,106-114     
  errors.ts        |   41.46 |       60 |      75 |   41.46 | 17-21,37-52,56-62 
  fetch.ts         |   34.04 |      100 |       0 |   34.04 | 22-27,31-57       
  fileUtils.ts     |   94.69 |    91.54 |     100 |   94.69 | ...45-249,318-324 
  ...eUtilities.ts |   96.03 |       96 |     100 |   96.03 | 28-29,57-58       
  ...rStructure.ts |      95 |    93.42 |     100 |      95 | ...66-167,344-346 
  ...noreParser.ts |   96.36 |     90.9 |     100 |   96.36 | 70-71             
  gitUtils.ts      |   46.34 |    66.66 |      50 |   46.34 | 24-25,40-41,50-73 
  ...yDiscovery.ts |    80.7 |    75.43 |      75 |    80.7 | ...12-313,316-317 
  ...tProcessor.ts |   86.86 |    88.46 |     100 |   86.86 | 115-124,131-140   
  ...Inspectors.ts |     100 |      100 |     100 |     100 |                   
  ...kerChecker.ts |   83.51 |    83.33 |     100 |   83.51 | ...95-100,108-114 
  ...iAnalytics.ts |    4.78 |        0 |       0 |    4.78 | ...44-339,343-360 
  ...iLogViewer.ts |    6.94 |        0 |       0 |    6.94 | ...29-146,150-197 
  openaiLogger.ts  |    19.1 |      100 |   33.33 |    19.1 | ...96-116,124-131 
  paths.ts         |   63.21 |    73.33 |   57.14 |   63.21 | ...24-134,140-141 
  ...rDetection.ts |   32.83 |    36.36 |      80 |   32.83 | ...00-101,107-112 
  retry.ts         |   62.55 |    73.21 |     100 |   62.55 | ...54-274,319-334 
  ...nStringify.ts |     100 |      100 |     100 |     100 |                   
  ...aValidator.ts |   86.66 |    73.33 |     100 |   86.66 | 22-23,25-26,43-44 
  session.ts       |     100 |      100 |     100 |     100 |                   
  summarizer.ts    |    92.1 |       75 |     100 |    92.1 | 46-47,57-58,74-75 
  testUtils.ts     |   84.44 |    72.72 |   83.33 |   84.44 | 27-28,34-35,70-72 
  user_account.ts  |   97.72 |    97.05 |     100 |   97.72 | 102-103           
  user_id.ts       |   60.97 |    33.33 |      75 |   60.97 | ...33,46-48,52-57 
-------------------|---------|----------|---------|---------|-------------------

For detailed HTML reports, please see the 'coverage-reports-22.x' artifact from the main CI run.

@koalazf99

Copy link
Copy Markdown
Collaborator Author

@pomelo-nwu

@pomelo-nwu

Copy link
Copy Markdown
Collaborator

lgtm

@pomelo-nwu
pomelo-nwu merged commit b8e2891 into main Jul 24, 2025
7 checks passed
@koalazf99
koalazf99 deleted the feature/fan/fix-token-usage branch July 24, 2025 15:32
xaelistic pushed a commit to xaelistic/qwen-code that referenced this pull request Jun 7, 2026
yiliang114 added a commit that referenced this pull request Aug 27, 2026
… Stage 1-pre

The per-issue loop legend said OPEN -> proceed to 1a while the aggregate bullets said any closed-as-completed issue enters the closer flow, so 'fixes #101 and fixes #102' with #101 OPEN, #102 CLOSED-COMPLETED had two contradictory outcomes. Make the loop collect-only and state one fixed precedence (not-planned > completed > all-open), so an OPEN issue never short-circuits a CLOSED one. Pin the precedence.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
chiga0 pushed a commit to chiga0/qwen-code that referenced this pull request Aug 28, 2026
…M#10292)

* feat(triage): add duplicate / already-fixed gate (Stage 1-pre)

A PR opened after its linked issue was already fixed by a merged PR
stays open forever: no existing gate looks at the linked issue's
state, and triage has no close action at all. Add a deterministic
Stage 1-pre check that resolves the linked issue's closer via GraphQL
and, only when the PR's production diff is fully subsumed by the
merged fix, posts a bilingual terminal comment and closes the PR.
Any remaining delta requests changes instead; ambiguity escalates to
the maintainer. Register the gate in SKILL.md so it is not treated as
a fabricated policy.

* fix(triage): correct Stage 1-pre subsumption, base scope, and linkage

- Define subsumption over the entire diff (added lines present AND
  deleted lines absent in the default branch) so deletions-only and
  tests-only diffs can never reach the close branch.
- Run Stage 1-pre only for PRs targeting the default branch; backports
  to release/* branches legitimately carry changes already on the
  default branch.
- Extract linked issues via GitHub's closingIssuesReferences instead of
  a keyword grep that missed 6 of 9 closing-keyword forms and matched
  substrings like "prefixes".
- Pin all three invariants in qwen-triage-workflow.test.js.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(triage): align Stage 1-pre exits, closer query, and state mechanics

- Name both Stage 1-pre request-changes exits in the terminal gate
  exception and the footer rule, give each an explicit
  `gh pr review --request-changes` command like 1a/1b, and note the
  duplicate-close exit posts its terminal comment and closes instead of
  submitting a review; extend SKILL.md's rejection exception clause to
  cover them.
- Closer query: window the LAST 20 CLOSED_EVENTs and take only the most
  recent close's closer (older closes belong to reopen cycles), null-guard
  the jq filter, and spell out that a failed or empty query means the
  closer is unresolved (a PR number or missing issue must not hard-error).
- Add the per-issue state loop that assigns $N and produces the
  state/stateReason the branch bullets consume.

Co-authored-by: Qwen-Coder <qwen-coder @alibabacloud.com>

* fix(triage): scope Stage 1-pre linkage to same-repo closing references

The closingIssuesReferences extraction kept only the bare issue number, so a
cross-repo closing reference resolved against this repo's same-numbered
unrelated issue and could drive the wrong-issue gate branches. Filter the
extraction to references whose repository matches the triaged repo and state
that cross-repo closing references are skipped.

Co-authored-by: Qwen-Coder <qwen-coder @alibabacloud.com>

* fix(triage): guard the Stage 1-pre duplicate close against human reopens

An explicit /triage re-run on a PR a maintainer reopened after a 1-pre
duplicate-close re-derives identical inputs and closes again, indefinitely
overriding the deliberate reopen. Before the close exit posts and closes,
require that no stage=1-pre comment exists yet on the open PR; if one does,
escalate to the maintainer instead of re-closing.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* test(triage): pin Stage 1-pre state dispatch and ambiguity prohibition

The per-issue state dispatch (OPEN / CLOSED NOT_PLANNED / CLOSED COMPLETED)
and the "never close on ambiguity" bullet had no test witness: deleting or
inverting either kept the suite green. Add toContain pins binding each state
to its action and one pinning the ambiguity escalation rule.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(triage): drop production qualifier from Stage 1-pre exits in SKILL.md

The exit summary qualified both sides with 'production' (remaining production delta -> request-changes; entire production diff fully subsumed -> close), contradicting pr-workflow.md's operational definition: request-changes fires on ANY remaining delta including non-production additions, and a diff with NO production changes is never fully subsumed. A tests-only PR got opposite instructions from the two files. Align SKILL.md with pr-workflow.md and pin the boundary in the suite.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(triage): define fixed precedence for mixed linked-issue states in Stage 1-pre

The per-issue loop legend said OPEN -> proceed to 1a while the aggregate bullets said any closed-as-completed issue enters the closer flow, so 'fixes QwenLM#101 and fixes QwenLM#102' with QwenLM#101 OPEN, QwenLM#102 CLOSED-COMPLETED had two contradictory outcomes. Make the loop collect-only and state one fixed precedence (not-planned > completed > all-open), so an OPEN issue never short-circuits a CLOSED one. Pin the precedence.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(triage): make Stage 1-pre linkage prose honest about its verification

The doc promised linkage is 'input to verify against the issue's actual state, never as proof by itself', but the issue state check is the only verification, so an accidental prose linkage (e.g. 'resolves QwenLM#123's closer') still drove the branches off an unrelated issue. Reword to state the truth: there is no deterministic intent check, the linkage decides which issues are read, and the blast radius is bounded because close additionally requires the diff to be fully subsumed by the default branch (true only when the change already landed), so an accidental linkage reaches at worst a visible, reversible request-changes or escalation.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder @alibabacloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants