[autofix] ctrip/flight: COMMAND_EXEC (DOM drift + short wait + background-window skeleton)
- Dominant language
- JavaScript
- Stars
- 29.3k
- Forks
- 2.9k
- Avg merge
- 15h 36m
- Merged PRs (30d)
- 70
Description
## Summary
OpenCLI autofix repaired this adapter locally, and the retry passed.
## Adapter
- Site: `ctrip`
- Command: `flight`
- OpenCLI version: `1.8.6`
## Original failure
- Error code: `COMMAND_EXEC`
~~~
Ctrip flight page did not render flight cards (state=timeout)
~~~
## Local fix summary
Three stacked root causes, diagnosed and verified live on 2026-09-17 (CKG→YCU, 2026-10-01):
**1. DOM drift — flight card selector changed.**
Cards moved from `.flight-list > span > div` to `.flight-list .flight-item` (each card now carries `data-testid="flight-item-N"`). The old selector matches 0 elements, so the wait probe never resolved and the extractor returned nothing. Updated the selector in all three places: the wait probe (`WAIT_FOR_FLIGHTS_JS`), the scroll helper call (`buildScrollUntilJs(...)`), and `buildFlightExtractJs()` in `utils.js`. The position-anchored innerText parser itself still matches the new DOM chunk order 1:1 — no parser logic change needed. Verified chunk order:
~~~
["厦门航空","MF8785","波音737(中)","当日低价","13:40","江北国际机场","T3","15:10","盐湖国际机场","已减¥5","白银贵宾可享","¥","855","起","经济舱","订票"]
~~~
**2. Wait window too short.**
Cold-context render takes ~14s (measured live); the hardcoded 8000ms timeout in `WAIT_FOR_FLIGHTS_JS` fired on every run. Raised to 25000ms.
**3. Background window renders skeleton only.**
With a background window, Ctrip leaves the list as skeleton placeholders (`fake-flights` / `fake-flight-summary` / `fake-flight-price` classes; `document.body.innerText.length ≈ 723`; 0 `.flight-item` after a full 25s wait). With a foreground window the real cards render. Pinned `defaultWindowMode: 'foreground'` in the `cli()` definition (same approach as `clis/mercury/check-login.js`).
After the fix, `opencli ctrip flight CKG YCU --date 2026-10-01 -f json` returns structured rows (e.g. 厦门航空 MF8785 13:40→15:10, ¥855 经济舱).
_Issue filed by OpenCLI autofix after a verified local repair._
Contributor guide
Research direction
Start with the ctrip/flight adapter and inspect WAIT_FOR_FLIGHTS_JS, the buildScrollUntilJs(...) call, and buildFlightExtractJs() in utils.js. Compare the window configuration with clis/mercury/check-login.js, then run the documented OpenCLI flight command against the cited route. Done means real flight rows are returned reliably in a foreground window after the longer cold-context wait.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100