Skip to content

Commit 99fb512

Browse files
author
SqlRush
committed
Accept numeric remote history bool strings
1 parent bbca9c4 commit 99fb512

5 files changed

Lines changed: 10 additions & 5 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ M6 补充:content-replacement metadata 的 `agentId`、record `toolUseId` 和
102102

103103
M6 补充:remote history GraphQL/connection 分页现在接受 `hasPrevious`/`hasPreviousPage``hasOlder`/`more` 继续分页标记,以及 `previousCursor`/`prevCursor`/`beforeCursor`/`olderCursor` 等 before-id cursor 别名,避免只返回第一页历史。
104104

105-
M6 补充:remote history pagination bool 字段现在除 JSON bool 和 `true`/`false` 字符串外,也接受 `1`/`0``yes`/`no``on`/`off` 等数值/字符串布尔形态,避免 wrapper/pageInfo 中的非严格布尔值中断分页。
105+
M6 补充:remote history pagination bool 字段现在除 JSON bool 和 `true`/`false` 字符串外,也接受 `1`/`0``yes`/`no``on`/`off` 等数值/字符串布尔形态,以及 whole-number 数字字符串如 `"1.0"`/`"0.0"`避免 wrapper/pageInfo 中的非严格布尔值中断分页。
106106

107107
M6 补充:remote history pagination cursor/id 字段现在接受 JSON number 并原样转成字符串,覆盖 `next_cursor` 等 page 字段和 `edges[].cursor` 的数字形态。
108108

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ test/parity/ # golden tests against TS/official behavior
198198
- 本轮补充:TranscriptMessage 结构化读取官方 SerializedMessage 元数据 `userType``entrypoint``version``slug`,并兼容 user/entrypoint/version/slug 的 snake/camel/旧字段别名,减少旧 transcript 只能靠 raw JSON 保留元数据的情况。
199199
- 本轮补充:model-backed session memory recall prompt 现在显式写入 requested limit 和 excluded current session id,减少模型返回超量或当前 session 后再 fallback 的概率。
200200
- 本轮补充:remote history connection/pageInfo 解析接受 `hasPrevious`/`hasPreviousPage``hasOlder`/`more` 继续分页标记,以及 `previousCursor`/`prevCursor`/`beforeCursor`/`olderCursor` before-id cursor 别名,覆盖 GraphQL 向更旧事件翻页的响应形态。
201-
- 本轮补充:remote history pagination bool 字段除 JSON bool 和 `true`/`false` 字符串外,也接受 `1`/`0``yes`/`no``on`/`off` 等数值/字符串布尔形态,避免 wrapper/pageInfo 中的非严格布尔值中断分页。
201+
- 本轮补充:remote history pagination bool 字段除 JSON bool 和 `true`/`false` 字符串外,也接受 `1`/`0``yes`/`no``on`/`off` 等数值/字符串布尔形态,以及 whole-number 数字字符串如 `"1.0"`/`"0.0"`避免 wrapper/pageInfo 中的非严格布尔值中断分页。
202202
- 本轮补充:remote history pagination cursor/id 字段现在接受 JSON number 并原样转成字符串,覆盖 `next_cursor` 等 page 字段和 `edges[].cursor` 的数字形态。
203203
- 本轮补充:remote history pagination 现在接受 `nextPageToken`/`nextToken`/`pageToken`/`continuationToken` 及 snake_case 形式,响应字段和 link URL query 参数都会归一到续抓 before-id。
204204
- 本轮补充:remote history pagination 现在也接受 `previousPageToken`/`prevPageToken`/`olderPageToken``previousToken`/`prevToken`/`olderToken` 及 snake_case 形式,响应字段、link object 和 link URL query 参数都会归一到续抓 before-id。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ M6 progress now includes:
199199
- `internal/contracts`/`internal/session`: remote-history event materialization now accepts `eventType`/`event_type`/`role` type aliases, `createdAt`/`created_at` timestamp aliases, and message payload aliases such as `payload`, `data`, `body`, `metadata`, `meta`, `attributes`, `properties`, and `serializedMessage`, including role/content-only payloads.
200200
- `internal/contracts`/`internal/session`: remote-history SDK event types now canonicalize provider-style aliases such as `assistant_message`, `userMessage`, `system-event`, `result_event`, `errorEvent`, and `status_update`/`progress`, so wrapped or single-object event pages materialize transcript messages instead of being skipped as unknown types.
201201
- `internal/session`: remote-history pageInfo parsing now accepts previous/older pagination signals such as `hasPrevious`/`hasPreviousPage`, `hasOlder`/`more`, and before-id cursors such as `previousCursor`/`prevCursor`/`beforeCursor`/`olderCursor`.
202-
- `internal/session`: remote-history pagination bool parsing now accepts numeric and yes/no-style bool values in addition to JSON bools and true/false strings.
202+
- `internal/session`: remote-history pagination bool parsing now accepts numeric, whole-number numeric strings, and yes/no-style bool values in addition to JSON bools and true/false strings.
203203
- `internal/session`: remote-history pagination cursor/id parsing now accepts JSON numbers and preserves them as string cursors for page fields and `edges[].cursor`.
204204
- `internal/session`: remote-history pagination now accepts token aliases such as `nextPageToken`, `nextToken`, `pageToken`, and `continuationToken` in response fields and link query parameters, including `_`/`-` query-parameter variants in links.
205205
- `internal/session`: remote-history pagination now also accepts previous/older token aliases such as `previousPageToken`, `prevPageToken`, `olderPageToken`, and matching snake_case/token forms in response fields, link objects, and link query parameters.

internal/session/remote_history.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ func setBoolField(raw map[string]json.RawMessage, name string, target *bool) err
610610
case "0", "f", "false", "no", "n", "off":
611611
*target = false
612612
default:
613+
number, err := strconv.ParseFloat(strings.TrimSpace(text), 64)
614+
if err == nil {
615+
*target = number != 0
616+
return nil
617+
}
613618
return fmt.Errorf("%s must be a boolean", name)
614619
}
615620
return nil

internal/session/remote_history_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ func TestFetchRemoteHistoryAcceptsCursorPageFields(t *testing.T) {
259259
w.Header().Set("Content-Type", "application/json")
260260
switch r.URL.Query().Get("before_id") {
261261
case "":
262-
_, _ = w.Write([]byte(`{"data":[{"type":"status","session_id":"s","status":"latest"}],"has_next":true,"next_cursor":"evt_cursor"}`))
262+
_, _ = w.Write([]byte(`{"data":[{"type":"status","session_id":"s","status":"latest"}],"has_next":"1.0","next_cursor":"evt_cursor"}`))
263263
case "evt_cursor":
264-
_, _ = w.Write([]byte(`{"data":[{"type":"status","session_id":"s","status":"older"}],"hasNext":false,"cursor":"ignored_when_complete"}`))
264+
_, _ = w.Write([]byte(`{"data":[{"type":"status","session_id":"s","status":"older"}],"hasNext":"0.0","cursor":"ignored_when_complete"}`))
265265
default:
266266
t.Fatalf("unexpected before_id = %q", r.URL.Query().Get("before_id"))
267267
}

0 commit comments

Comments
 (0)