@@ -388,3 +388,67 @@ def test_streaming_msg_type_deduplication(mock_catalog):
388388
389389 # After completion, msg_types is reset
390390 assert not parser .msg_types
391+
392+
393+ def test_v09_path_heuristic_relative_path (mock_catalog ):
394+ """Tests that v0.9 allows relative paths (no leading slash)."""
395+ parser = A2uiStreamParser (catalog = mock_catalog )
396+ # Disable validation to avoid needing full catalog for this test
397+ parser ._validator = None
398+
399+ # 1. Create surface
400+ chunk_cs = (
401+ A2UI_OPEN_TAG
402+ + '[{"version": "v0.9", "createSurface": {"surfaceId": "s1", "catalogId": "c1"}}]'
403+ + A2UI_CLOSE_TAG
404+ )
405+ list (parser .process_chunk (chunk_cs ))
406+
407+ # 2. Update components with a relative path
408+ chunk_uc = (
409+ A2UI_OPEN_TAG
410+ + '[{"version": "v0.9", "updateComponents": {"surfaceId": "s1", "components":'
411+ ' [{"id": "root", "component": "Text", "text": {"path":'
412+ ' "some/relative/path"}}]}}]'
413+ + A2UI_CLOSE_TAG
414+ )
415+
416+ messages = []
417+ for part in parser .process_chunk (chunk_uc ):
418+ if part .a2ui_json :
419+ messages .extend (part .a2ui_json )
420+
421+ assert len (messages ) > 0
422+ comp = messages [0 ][MSG_TYPE_UPDATE_COMPONENTS ]["components" ][0 ]
423+ assert comp ["text" ]["path" ] == "some/relative/path"
424+
425+
426+ def test_v09_path_heuristic_absolute_path (mock_catalog ):
427+ """Tests that v0.9 still supports absolute paths (leading slash)."""
428+ parser = A2uiStreamParser (catalog = mock_catalog )
429+ parser ._validator = None
430+
431+ # 1. Create surface
432+ chunk_cs = (
433+ A2UI_OPEN_TAG
434+ + '[{"version": "v0.9", "createSurface": {"surfaceId": "s1", "catalogId": "c1"}}]'
435+ + A2UI_CLOSE_TAG
436+ )
437+ list (parser .process_chunk (chunk_cs ))
438+
439+ # 2. Update components with an absolute path
440+ chunk_uc = (
441+ A2UI_OPEN_TAG
442+ + '[{"version": "v0.9", "updateComponents": {"surfaceId": "s1", "components":'
443+ ' [{"id": "root", "component": "Text", "text": {"path": "/absolute/path"}}]}}]'
444+ + A2UI_CLOSE_TAG
445+ )
446+
447+ messages = []
448+ for part in parser .process_chunk (chunk_uc ):
449+ if part .a2ui_json :
450+ messages .extend (part .a2ui_json )
451+
452+ assert len (messages ) > 0
453+ comp = messages [0 ][MSG_TYPE_UPDATE_COMPONENTS ]["components" ][0 ]
454+ assert comp ["text" ]["path" ] == "/absolute/path"
0 commit comments