Skip to content

Dev to Stable - #14

Merged
LeXwDeX merged 6 commits into
stablefrom
dev
May 2, 2026
Merged

Dev to Stable#14
LeXwDeX merged 6 commits into
stablefrom
dev

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented May 2, 2026

Copy link
Copy Markdown
Owner

彻底解决计费问题

lex and others added 6 commits May 1, 2026 16:45
When submitting a prompt, the previous code expanded `[Pasted ~N lines]`
placeholders into their original content using the extmark's `start`/
`end` offsets:

    inputText.slice(0, extmark.start) + part.text + inputText.slice(extmark.end)

If the user pasted text and then moved the cursor to type characters
*before* the placeholder, the extmark's offsets in the underlying
input buffer drifted relative to `inputText`. The slice then took the
wrong range, leaving fragments of the placeholder string (for example
"d ~1 lines]") inside the submitted message.

Replace the offset-based slice with a `lastIndexOf` lookup of the
stored virtual text (`part.source.text.value`), iterating extmarks
right-to-left so duplicate placeholders are still paired correctly.
This eliminates dependence on opentui's offset tracking after edits.
The github-copilot direct-login path in quota-fetch.ts was sending
`token <refresh>` as the Authorization header when calling
/copilot_internal/user. However, the copilot plugin itself consistently
uses `Bearer <refresh>` for all GitHub API calls (copilot.ts:72,154).

The /copilot_internal/user endpoint rejects the `token` prefix format,
returning 401, which caused fetchQuota to silently return null and the
quota indicator to never display for direct OAuth users.

Change authHeaderPrefix from "token" to "Bearer" so it matches the
copilot plugin's auth format. This fixes the issue where github-proxy
users could see their quota but github-copilot direct-login users
could not.
- parseCopilotQuota 改用 snake_case 字段(quota_snapshots /
  premium_interactions / remaining / entitlement),修复 GitHub API
  响应解析全部返回 null 的问题
- readQuotaAuth → readQuotaAuths 返回 QuotaAuth[],同时收集
  github-proxy 与 github-copilot 两条来源
- fetchQuota 接收数组,依次尝试,proxy 不可达时自动降级到 copilot
- 测试同步更新,新增 fallback 降级用例,共 22 个全部通过
已知 opencode issue #8030:合成 user 消息(compaction / subtask / 图片附件)
被 copilot.ts loader.fetch 错判为 user 请求,导致每轮 agentic 循环均扣
premium quota。本提交在 fetch 出站前记录 xInitiator、hookHeader、
isAgent、lastRole、lastContentTypes、lastTextSample 供分析。

用完即删,正式修复见后续提交。
@LeXwDeX
LeXwDeX merged commit f777ce7 into stable May 2, 2026
7 checks passed
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.

1 participant