portacode 2.2.28.dev3__py3-none-any.whl → 2.2.28.dev4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- portacode/_version.py +2 -2
- portacode/connection/handlers/codex_handlers.py +20 -11
- portacode/tests/test_codex_handlers.py +81 -0
- {portacode-2.2.28.dev3.dist-info → portacode-2.2.28.dev4.dist-info}/METADATA +1 -1
- {portacode-2.2.28.dev3.dist-info → portacode-2.2.28.dev4.dist-info}/RECORD +9 -9
- {portacode-2.2.28.dev3.dist-info → portacode-2.2.28.dev4.dist-info}/WHEEL +0 -0
- {portacode-2.2.28.dev3.dist-info → portacode-2.2.28.dev4.dist-info}/entry_points.txt +0 -0
- {portacode-2.2.28.dev3.dist-info → portacode-2.2.28.dev4.dist-info}/licenses/LICENSE +0 -0
- {portacode-2.2.28.dev3.dist-info → portacode-2.2.28.dev4.dist-info}/top_level.txt +0 -0
portacode/_version.py
CHANGED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '2.2.28.
|
|
22
|
-
__version_tuple__ = version_tuple = (2, 2, 28, '
|
|
21
|
+
__version__ = version = '2.2.28.dev4'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 2, 28, 'dev4')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -21,6 +21,7 @@ MAX_LIVE_TEXT_BYTES = 512 * 1024
|
|
|
21
21
|
MAX_LIVE_ITEMS_PER_THREAD = 64
|
|
22
22
|
MAX_LIVE_SNAPSHOT_BYTES = 4 * 1024 * 1024
|
|
23
23
|
MAX_TRACKED_LIVE_THREADS = 64
|
|
24
|
+
MAX_HISTORY_TURNS = 80
|
|
24
25
|
MAX_DELEGATED_RESULT_BYTES = 16 * 1024
|
|
25
26
|
MAX_DELEGATED_DIAGNOSTIC_BYTES = 8 * 1024
|
|
26
27
|
|
|
@@ -579,23 +580,18 @@ async def _resume_thread_history(
|
|
|
579
580
|
thread = _thread_from_result(resume_result)
|
|
580
581
|
turns = thread.get("turns") if isinstance(thread.get("turns"), list) else []
|
|
581
582
|
if turns:
|
|
583
|
+
turns = turns[-MAX_HISTORY_TURNS:]
|
|
582
584
|
return resume_result, _items_from_turns(turns), _active_turn_from_turns(turns)
|
|
583
585
|
else:
|
|
584
586
|
raise
|
|
585
587
|
|
|
586
|
-
# Newer servers may embed a first page on resume.
|
|
587
|
-
page = resume_result.get("initialTurnsPage") if isinstance(resume_result, dict) else None
|
|
588
|
-
turns = _turns_from_page(page)
|
|
589
|
-
if turns:
|
|
590
|
-
return resume_result, _items_from_turns(turns), _active_turn_from_turns(turns)
|
|
591
|
-
|
|
592
588
|
try:
|
|
593
589
|
turns_page = await manager.bridge.call(
|
|
594
590
|
"thread/turns/list",
|
|
595
591
|
{
|
|
596
592
|
"threadId": thread_id,
|
|
597
|
-
"limit":
|
|
598
|
-
"sortDirection": "
|
|
593
|
+
"limit": MAX_HISTORY_TURNS,
|
|
594
|
+
"sortDirection": "desc",
|
|
599
595
|
# Summary view can intentionally omit user content, producing
|
|
600
596
|
# empty bubbles after a browser reload. Attachments are stored
|
|
601
597
|
# as lightweight path items, so full view does not embed the
|
|
@@ -604,11 +600,20 @@ async def _resume_thread_history(
|
|
|
604
600
|
},
|
|
605
601
|
timeout=120.0,
|
|
606
602
|
)
|
|
607
|
-
|
|
603
|
+
# Fetch just the newest page; restore chronology locally, without
|
|
604
|
+
# walking cursors or sending the omitted history through the broker.
|
|
605
|
+
turns = list(reversed(_turns_from_page(turns_page)[:MAX_HISTORY_TURNS]))
|
|
608
606
|
return resume_result, _items_from_turns(turns), _active_turn_from_turns(turns)
|
|
609
607
|
except (CodexAppServerError, asyncio.TimeoutError):
|
|
610
608
|
LOGGER.debug("thread/turns/list unavailable; trying lightweight thread/read", exc_info=True)
|
|
611
609
|
|
|
610
|
+
# Embedded pages have no guaranteed newest-first selection. Use them only
|
|
611
|
+
# for compatibility when the explicit newest-page API is unavailable.
|
|
612
|
+
page = resume_result.get("initialTurnsPage") if isinstance(resume_result, dict) else None
|
|
613
|
+
turns = _turns_from_page(page)[-MAX_HISTORY_TURNS:]
|
|
614
|
+
if turns:
|
|
615
|
+
return resume_result, _items_from_turns(turns), _active_turn_from_turns(turns)
|
|
616
|
+
|
|
612
617
|
# Avoid includeTurns:true — attachment-heavy rollouts hang Codex app-server.
|
|
613
618
|
try:
|
|
614
619
|
read_result = await manager.bridge.call(
|
|
@@ -617,12 +622,13 @@ async def _resume_thread_history(
|
|
|
617
622
|
timeout=30.0,
|
|
618
623
|
)
|
|
619
624
|
page = read_result.get("initialTurnsPage") if isinstance(read_result, dict) else None
|
|
620
|
-
turns = _turns_from_page(page)
|
|
625
|
+
turns = _turns_from_page(page)[-MAX_HISTORY_TURNS:]
|
|
621
626
|
if turns:
|
|
622
627
|
return resume_result, _items_from_turns(turns), _active_turn_from_turns(turns)
|
|
623
628
|
thread = _thread_from_result(read_result)
|
|
624
629
|
inline = thread.get("turns") if isinstance(thread.get("turns"), list) else []
|
|
625
630
|
if inline:
|
|
631
|
+
inline = inline[-MAX_HISTORY_TURNS:]
|
|
626
632
|
return resume_result, _items_from_turns(inline), _active_turn_from_turns(inline)
|
|
627
633
|
except (CodexAppServerError, asyncio.TimeoutError):
|
|
628
634
|
LOGGER.warning(
|
|
@@ -872,7 +878,10 @@ class CodexThreadResumeHandler(CodexAsyncHandler):
|
|
|
872
878
|
cwd=cwd,
|
|
873
879
|
already_active=str(thread_id) in manager._thread_active_turn,
|
|
874
880
|
)
|
|
875
|
-
|
|
881
|
+
# History travels once, in `items`. Legacy resume responses may embed
|
|
882
|
+
# the complete rollout in thread.turns; do not forward that duplicate.
|
|
883
|
+
thread = {key: value for key, value in _thread_from_result(resume_result).items()
|
|
884
|
+
if key not in {"turns", "initialTurnsPage"}}
|
|
876
885
|
if not active_turn:
|
|
877
886
|
known_turn_id = manager._thread_active_turn.get(str(thread_id))
|
|
878
887
|
if known_turn_id:
|
|
@@ -288,9 +288,90 @@ async def test_codex_thread_resume():
|
|
|
288
288
|
turns_call = next(c for c in manager.bridge.calls if c[0] == "thread/turns/list")
|
|
289
289
|
assert turns_call[1]["threadId"] == "th-1"
|
|
290
290
|
assert turns_call[1]["itemsView"] == "full"
|
|
291
|
+
assert turns_call[1]["sortDirection"] == "desc"
|
|
292
|
+
assert turns_call[1]["limit"] == 80
|
|
291
293
|
assert not any(c[0] == "thread/read" for c in manager.bridge.calls)
|
|
292
294
|
|
|
293
295
|
|
|
296
|
+
@pytest.mark.asyncio
|
|
297
|
+
@pytest.mark.parametrize("count", [0, 1, 80, 81, 300])
|
|
298
|
+
@pytest.mark.parametrize("already_active", [False, True])
|
|
299
|
+
async def test_resume_keeps_latest_page_in_chronological_order(count, already_active):
|
|
300
|
+
channel = DummyControlChannel()
|
|
301
|
+
context = _context()
|
|
302
|
+
manager = CodexChatManager(channel, context)
|
|
303
|
+
manager.bridge = FakeBridge()
|
|
304
|
+
context["codex_manager"] = manager
|
|
305
|
+
turns = [{"id": f"turn-{i}", "status": "inProgress" if i == count - 1 else "completed",
|
|
306
|
+
"items": [{"id": f"user-{i}", "text": f"question {i}"},
|
|
307
|
+
{"id": f"answer-{i}", "text": f"answer {i}"}]} for i in range(count)]
|
|
308
|
+
if already_active and count:
|
|
309
|
+
manager._thread_active_turn["th-1"] = f"turn-{count - 1}"
|
|
310
|
+
|
|
311
|
+
async def call(method, params, timeout=60):
|
|
312
|
+
manager.bridge.calls.append((method, params))
|
|
313
|
+
if method == "thread/resume":
|
|
314
|
+
# A first embedded page must not override explicit newest selection.
|
|
315
|
+
return {"thread": {"id": "th-1"}, "initialTurnsPage": {"data": turns[:80]}}
|
|
316
|
+
assert method == "thread/turns/list"
|
|
317
|
+
ordered = list(reversed(turns)) if params["sortDirection"] == "desc" else turns
|
|
318
|
+
return {"data": ordered[:params["limit"]], "nextCursor": "older-page"}
|
|
319
|
+
|
|
320
|
+
manager.bridge.call = call
|
|
321
|
+
await CodexThreadResumeHandler(channel, context).handle(
|
|
322
|
+
{"cmd": "codex_thread_resume", "threadId": "th-1", "project_id": "p-1"}, reply_channel="rc-1")
|
|
323
|
+
assert len(channel.sent) == 1
|
|
324
|
+
payload = channel.sent[0]
|
|
325
|
+
assert [i["id"] for i in payload["items"]] == [
|
|
326
|
+
item["id"] for turn in turns[-80:] for item in turn["items"]]
|
|
327
|
+
if count:
|
|
328
|
+
assert payload["activeTurn"]["id"] == f"turn-{count - 1}"
|
|
329
|
+
assert [method for method, _ in manager.bridge.calls] == (
|
|
330
|
+
[] if already_active and count else ["thread/resume"]) + ["thread/turns/list"]
|
|
331
|
+
assert all("cursor" not in params for _, params in manager.bridge.calls)
|
|
332
|
+
assert all("_portacode_turn_id" not in item for turn in turns for item in turn["items"])
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
@pytest.mark.asyncio
|
|
336
|
+
@pytest.mark.parametrize("fallback", ["legacy_resume", "read_inline", "read_page", "resume_page"])
|
|
337
|
+
async def test_resume_fallback_caps_history_without_duplicate_rollout(fallback):
|
|
338
|
+
from portacode.connection.codex_app_server import CodexAppServerError
|
|
339
|
+
|
|
340
|
+
channel = DummyControlChannel()
|
|
341
|
+
context = _context()
|
|
342
|
+
manager = CodexChatManager(channel, context)
|
|
343
|
+
manager.bridge = FakeBridge()
|
|
344
|
+
context["codex_manager"] = manager
|
|
345
|
+
turns = [{"id": f"t-{i}", "items": [{"id": f"m-{i}", "text": str(i)}]} for i in range(100)]
|
|
346
|
+
|
|
347
|
+
async def call(method, params, timeout=60):
|
|
348
|
+
manager.bridge.calls.append((method, params))
|
|
349
|
+
if method == "thread/resume":
|
|
350
|
+
if fallback == "legacy_resume":
|
|
351
|
+
if params.get("excludeTurns"):
|
|
352
|
+
raise CodexAppServerError("unknown excludeTurns")
|
|
353
|
+
return {"thread": {"id": "th-1", "name": "preserved", "turns": turns}}
|
|
354
|
+
if fallback == "resume_page":
|
|
355
|
+
return {"thread": {"id": "th-1"}, "initialTurnsPage": {"data": turns}}
|
|
356
|
+
return {"thread": {"id": "th-1"}}
|
|
357
|
+
if method == "thread/turns/list":
|
|
358
|
+
raise CodexAppServerError("unknown method")
|
|
359
|
+
assert method == "thread/read" and params["excludeTurns"]
|
|
360
|
+
return ({"initialTurnsPage": {"data": turns}} if fallback == "read_page"
|
|
361
|
+
else {"thread": {"id": "th-1", "turns": turns}})
|
|
362
|
+
|
|
363
|
+
manager.bridge.call = call
|
|
364
|
+
await CodexThreadResumeHandler(channel, context).handle(
|
|
365
|
+
{"cmd": "codex_thread_resume", "threadId": "th-1", "project_id": "p-1"}, reply_channel="rc-1")
|
|
366
|
+
assert len(channel.sent) == 1
|
|
367
|
+
payload = channel.sent[0]
|
|
368
|
+
assert [i["id"] for i in payload["items"]] == [f"m-{i}" for i in range(20, 100)]
|
|
369
|
+
assert "turns" not in payload["thread"]
|
|
370
|
+
assert "initialTurnsPage" not in payload["thread"]
|
|
371
|
+
if fallback == "legacy_resume":
|
|
372
|
+
assert payload["thread"]["name"] == "preserved"
|
|
373
|
+
|
|
374
|
+
|
|
294
375
|
@pytest.mark.asyncio
|
|
295
376
|
async def test_codex_turn_start():
|
|
296
377
|
channel = DummyControlChannel()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
portacode/README.md,sha256=R76fnJCKOnLiBEirTtc7fj4A6j5vAN1pdYMGNGqu1cs,1215
|
|
2
2
|
portacode/__init__.py,sha256=Hwk8wm5KA79qi06r0qKJKT2kjUlHrWaDtH4CyhnWFw8,1086
|
|
3
3
|
portacode/__main__.py,sha256=jmHTGC1hzmo9iKJLv-SSYe9BSIbPPZ2IOpecI03PlTs,296
|
|
4
|
-
portacode/_version.py,sha256=
|
|
4
|
+
portacode/_version.py,sha256=mhSi29noqMvVUbIxGHnRwsqmA8CBjsybZmIH-BNQSRI,535
|
|
5
5
|
portacode/browser_cli.py,sha256=MEc_WxTeezR4WP9wKcC89FGDeXbLyN6Ybfs-foUnrEY,5995
|
|
6
6
|
portacode/browser_prepare.py,sha256=xZRMkSEDZxw1YYz4LbiiYbmF9nOkXLcGsgkbGtVFfmQ,4805
|
|
7
7
|
portacode/browser_runtime.py,sha256=YR0duDqZaZrgSy0I9HrfZqV2fzcU2kIvUG1VyBiC93c,4276
|
|
@@ -50,7 +50,7 @@ portacode/connection/handlers/browser_handlers.py,sha256=FRSxxkexiqJVq7zivDoPwEA
|
|
|
50
50
|
portacode/connection/handlers/chunked_content.py,sha256=h6hXRmxSeOgnIxoU8CkmvEf2Odv-ajPrpHIe_W3GKcA,9251
|
|
51
51
|
portacode/connection/handlers/cloudflare_forwarding.py,sha256=v7jLFnSYoECakB8O8cEKArhk1SuD8NYsRr_YE-QT0f8,49528
|
|
52
52
|
portacode/connection/handlers/cloudflare_tunnel.py,sha256=qHBrm2rATxFmvfoC49YOBj0EUXjh_FETiWw66krxCIg,6655
|
|
53
|
-
portacode/connection/handlers/codex_handlers.py,sha256=
|
|
53
|
+
portacode/connection/handlers/codex_handlers.py,sha256=TOMH5i-kWq9uK-TzNc1dX5gZPCreW6YB-pVsnj8vLi8,54363
|
|
54
54
|
portacode/connection/handlers/diff_handlers.py,sha256=coN8gfY85KctBEs_bL9RCrZ6iymbP7zaB4Mzwgqrsck,24676
|
|
55
55
|
portacode/connection/handlers/file_handlers.py,sha256=ZPenZ14fJu7TTZSS79pLrAF2PKHMdbgmpzz5xZalW2I,44093
|
|
56
56
|
portacode/connection/handlers/file_transfer_handlers.py,sha256=otUb6x4roms-zFuuomyZFH68CNY5abr0A-eUMVgYAO8,7746
|
|
@@ -108,7 +108,7 @@ portacode/tests/test_browser_cli.py,sha256=ZmmNdRkIdLbTybWCKW6lCjktLRHvjK48wy1tQ
|
|
|
108
108
|
portacode/tests/test_browser_prepare.py,sha256=a75un88L1E5vX1B-1Qeh0ng6I_HictNcZ-Wf-F8uqKs,5395
|
|
109
109
|
portacode/tests/test_cli_service_logs.py,sha256=Fog68tVDMEe8zOcpfA1ukPRodhgjOwbTQ6Rm4leH6dQ,1733
|
|
110
110
|
portacode/tests/test_codex_app_server.py,sha256=xUiCno_Gx3Z5KrrhoxN38c5nGJBDgJ9bT7TDvFGZDMs,13993
|
|
111
|
-
portacode/tests/test_codex_handlers.py,sha256=
|
|
111
|
+
portacode/tests/test_codex_handlers.py,sha256=CuGx-YxqezmQDhsAWTYwcTEXfIH4eSJInV3cTPMvYDg,39556
|
|
112
112
|
portacode/tests/test_codex_loopback_proxy.py,sha256=W51wtATGxNMzODXY-tmRG5IU5N2FqIN8hvqQNxNv1xg,10423
|
|
113
113
|
portacode/tests/test_codex_prepare.py,sha256=n0LyedZq8IVP5OqR1pkd0h6Qvjax5_vDOwOnJGfUou8,13331
|
|
114
114
|
portacode/tests/test_codex_prepare_cli.py,sha256=hhhU3FDbLGfsSv2uC-sLzECfEScgeyyUXc_5JLNFBzw,2666
|
|
@@ -135,7 +135,7 @@ portacode/utils/diff_apply.py,sha256=ArkT-vEQ7iyA1Nfqufq1AiNtRLhoCMnC75FCRh2kNgI
|
|
|
135
135
|
portacode/utils/diff_renderer.py,sha256=S76StnQ2DLfsz4Gg0m07UwPfRp8270PuzbNaQq-rmYk,13850
|
|
136
136
|
portacode/utils/ntp_clock.py,sha256=VqCnWCTehCufE43W23oB-WUdAZGeCcLxkmIOPwInYHc,2499
|
|
137
137
|
portacode/utils/runtime_paths.py,sha256=G9ROho5f5gnDhoQ7vpEAX2XifBzoJTvqTylkF2Hkx8E,1660
|
|
138
|
-
portacode-2.2.28.
|
|
138
|
+
portacode-2.2.28.dev4.dist-info/licenses/LICENSE,sha256=iiV44E3po4OL77NL8diCk3WtYvCNGu6gUci2TYxVUgQ,5520
|
|
139
139
|
test_modules/README.md,sha256=Do_agkm9WhSzueXjRAkV_xEj6Emy5zB3N3VKY5Roce8,9274
|
|
140
140
|
test_modules/__init__.py,sha256=1LcbHodIHsB0g-g4NGjSn6AMuCoGbymvXPYLOb6Z7F0,53
|
|
141
141
|
test_modules/test_device_online.py,sha256=QtYq0Dq9vME8Gp2O4fGSheqVf8LUtpsSKosXXk56gGM,1654
|
|
@@ -161,8 +161,8 @@ testing_framework/core/playwright_manager.py,sha256=asMe7zQg8Kp3a71F7pv92OiFt63B
|
|
|
161
161
|
testing_framework/core/runner.py,sha256=t3fq0mGCVUCE_TbieEPwmLKjxe44ez29SzW8G33ACME,19746
|
|
162
162
|
testing_framework/core/shared_cli_manager.py,sha256=BESSNtyQb7BOlaOvZmm04T8Uezjms4KCBs2MzTxvzYQ,8790
|
|
163
163
|
testing_framework/core/test_discovery.py,sha256=2FZ9fJ8Dp5dloA-fkgXoJ_gCMC_nYPBnA3Hs2xlagzM,4928
|
|
164
|
-
portacode-2.2.28.
|
|
165
|
-
portacode-2.2.28.
|
|
166
|
-
portacode-2.2.28.
|
|
167
|
-
portacode-2.2.28.
|
|
168
|
-
portacode-2.2.28.
|
|
164
|
+
portacode-2.2.28.dev4.dist-info/METADATA,sha256=VgKlw1fTAbiBoQSzyT_LbjG8x0xLdyzHlEqSLo61GzM,12881
|
|
165
|
+
portacode-2.2.28.dev4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
166
|
+
portacode-2.2.28.dev4.dist-info/entry_points.txt,sha256=0cV_SuIztVnLWACUY5KMR8K8pWdAsLiaFbLXE5He0rk,151
|
|
167
|
+
portacode-2.2.28.dev4.dist-info/top_level.txt,sha256=TGhTYUxfW8SyVZc_zGgzjzc24gGT7nSw8Qf73liVRKM,41
|
|
168
|
+
portacode-2.2.28.dev4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|