diff --git a/STATS.md b/STATS.md index 9a8b7938b9a..210303798df 100644 --- a/STATS.md +++ b/STATS.md @@ -1,19 +1,184 @@ # Download Stats -| Date | GitHub Downloads | npm Downloads | Total | -| ---------- | ---------------- | --------------- | ----------------- | -| 2025-06-29 | 18,789 (+0) | 39,420 (+0) | 58,209 (+0) | -| 2025-06-30 | 20,127 (+1,338) | 41,059 (+1,639) | 61,186 (+2,977) | -| 2025-07-01 | 22,108 (+1,981) | 43,745 (+2,686) | 65,853 (+4,667) | -| 2025-07-02 | 24,814 (+2,706) | 46,168 (+2,423) | 70,982 (+5,129) | -| 2025-07-03 | 27,834 (+3,020) | 49,955 (+3,787) | 77,789 (+6,807) | -| 2025-07-04 | 30,608 (+2,774) | 54,758 (+4,803) | 85,366 (+7,577) | -| 2025-07-05 | 32,524 (+1,916) | 58,371 (+3,613) | 90,895 (+5,529) | -| 2025-07-06 | 33,766 (+1,242) | 59,694 (+1,323) | 93,460 (+2,565) | -| 2025-07-08 | 38,052 (+4,286) | 64,468 (+4,774) | 102,520 (+9,060) | -| 2025-07-10 | 43,796 (+5,744) | 71,402 (+6,934) | 115,198 (+12,678) | -| 2025-07-11 | 46,982 (+3,186) | 77,462 (+6,060) | 124,444 (+9,246) | -| 2025-07-12 | 49,302 (+2,320) | 82,177 (+4,715) | 131,479 (+7,035) | -| 2025-07-13 | 50,803 (+1,501) | 86,394 (+4,217) | 137,197 (+5,718) | -| 2025-07-14 | 53,283 (+2,480) | 87,860 (+1,466) | 141,143 (+3,946) | -| 2025-07-15 | 57,590 (+4,307) | 91,036 (+3,176) | 148,626 (+7,483) | +| Date | GitHub Downloads | npm Downloads | Total | +| ---------- | ------------------- | ------------------- | ------------------- | +| 2025-06-29 | 18,789 (+0) | 39,420 (+0) | 58,209 (+0) | +| 2025-06-30 | 20,127 (+1,338) | 41,059 (+1,639) | 61,186 (+2,977) | +| 2025-07-01 | 22,108 (+1,981) | 43,745 (+2,686) | 65,853 (+4,667) | +| 2025-07-02 | 24,814 (+2,706) | 46,168 (+2,423) | 70,982 (+5,129) | +| 2025-07-03 | 27,834 (+3,020) | 49,955 (+3,787) | 77,789 (+6,807) | +| 2025-07-04 | 30,608 (+2,774) | 54,758 (+4,803) | 85,366 (+7,577) | +| 2025-07-05 | 32,524 (+1,916) | 58,371 (+3,613) | 90,895 (+5,529) | +| 2025-07-06 | 33,766 (+1,242) | 59,694 (+1,323) | 93,460 (+2,565) | +| 2025-07-08 | 38,052 (+4,286) | 64,468 (+4,774) | 102,520 (+9,060) | +| 2025-07-10 | 43,796 (+5,744) | 71,402 (+6,934) | 115,198 (+12,678) | +| 2025-07-11 | 46,982 (+3,186) | 77,462 (+6,060) | 124,444 (+9,246) | +| 2025-07-12 | 49,302 (+2,320) | 82,177 (+4,715) | 131,479 (+7,035) | +| 2025-07-13 | 50,803 (+1,501) | 86,394 (+4,217) | 137,197 (+5,718) | +| 2025-07-14 | 53,283 (+2,480) | 87,860 (+1,466) | 141,143 (+3,946) | +| 2025-07-15 | 57,590 (+4,307) | 91,036 (+3,176) | 148,626 (+7,483) | +| 2025-07-16 | 62,343 (+4,753) | 95,258 (+4,222) | 157,601 (+8,975) | +| 2025-07-17 | 66,382 (+4,039) | 100,048 (+4,790) | 166,430 (+8,829) | +| 2025-07-18 | 70,404 (+4,022) | 102,587 (+2,539) | 172,991 (+6,561) | +| 2025-07-19 | 73,498 (+3,094) | 105,904 (+3,317) | 179,402 (+6,411) | +| 2025-07-20 | 76,454 (+2,956) | 109,044 (+3,140) | 185,498 (+6,096) | +| 2025-07-21 | 79,990 (+3,536) | 113,537 (+4,493) | 193,527 (+8,029) | +| 2025-07-22 | 84,278 (+4,288) | 118,073 (+4,536) | 202,351 (+8,824) | +| 2025-07-23 | 88,606 (+4,328) | 121,436 (+3,363) | 210,042 (+7,691) | +| 2025-07-24 | 92,480 (+3,874) | 124,091 (+2,655) | 216,571 (+6,529) | +| 2025-07-25 | 96,430 (+3,950) | 126,985 (+2,894) | 223,415 (+6,844) | +| 2025-07-26 | 100,646 (+4,216) | 131,411 (+4,426) | 232,057 (+8,642) | +| 2025-07-27 | 102,645 (+1,999) | 134,736 (+3,325) | 237,381 (+5,324) | +| 2025-07-28 | 105,467 (+2,822) | 136,016 (+1,280) | 241,483 (+4,102) | +| 2025-07-29 | 109,022 (+3,555) | 137,542 (+1,526) | 246,564 (+5,081) | +| 2025-07-30 | 113,571 (+4,549) | 140,317 (+2,775) | 253,888 (+7,324) | +| 2025-07-31 | 118,339 (+4,768) | 143,344 (+3,027) | 261,683 (+7,795) | +| 2025-08-01 | 123,569 (+5,230) | 146,680 (+3,336) | 270,249 (+8,566) | +| 2025-08-02 | 127,870 (+4,301) | 149,236 (+2,556) | 277,106 (+6,857) | +| 2025-08-03 | 131,398 (+3,528) | 150,451 (+1,215) | 281,849 (+4,743) | +| 2025-08-04 | 136,293 (+4,895) | 153,260 (+2,809) | 289,553 (+7,704) | +| 2025-08-05 | 141,624 (+5,331) | 155,752 (+2,492) | 297,376 (+7,823) | +| 2025-08-06 | 147,090 (+5,466) | 158,309 (+2,557) | 305,399 (+8,023) | +| 2025-08-07 | 152,622 (+5,532) | 160,889 (+2,580) | 313,511 (+8,112) | +| 2025-08-08 | 158,229 (+5,607) | 163,448 (+2,559) | 321,677 (+8,166) | +| 2025-08-09 | 162,770 (+4,541) | 165,721 (+2,273) | 328,491 (+6,814) | +| 2025-08-10 | 165,704 (+2,934) | 167,109 (+1,388) | 332,813 (+4,322) | +| 2025-08-11 | 169,310 (+3,606) | 167,953 (+844) | 337,263 (+4,450) | +| 2025-08-12 | 176,348 (+7,038) | 171,876 (+3,923) | 348,224 (+10,961) | +| 2025-08-13 | 183,027 (+6,679) | 177,182 (+5,306) | 360,209 (+11,985) | +| 2025-08-14 | 189,093 (+6,066) | 179,741 (+2,559) | 368,834 (+8,625) | +| 2025-08-15 | 193,608 (+4,515) | 181,792 (+2,051) | 375,400 (+6,566) | +| 2025-08-16 | 198,123 (+4,515) | 184,558 (+2,766) | 382,681 (+7,281) | +| 2025-08-17 | 201,299 (+3,176) | 186,269 (+1,711) | 387,568 (+4,887) | +| 2025-08-18 | 204,587 (+3,288) | 187,399 (+1,130) | 391,986 (+4,418) | +| 2025-08-19 | 209,832 (+5,245) | 189,668 (+2,269) | 399,500 (+7,514) | +| 2025-08-20 | 214,549 (+4,717) | 191,481 (+1,813) | 406,030 (+6,530) | +| 2025-08-21 | 220,487 (+5,938) | 194,784 (+3,303) | 415,271 (+9,241) | +| 2025-08-22 | 225,915 (+5,428) | 197,204 (+2,420) | 423,119 (+7,848) | +| 2025-08-23 | 229,005 (+3,090) | 199,238 (+2,034) | 428,243 (+5,124) | +| 2025-08-24 | 232,099 (+3,094) | 201,157 (+1,919) | 433,256 (+5,013) | +| 2025-08-25 | 236,649 (+4,550) | 202,650 (+1,493) | 439,299 (+6,043) | +| 2025-08-26 | 242,827 (+6,178) | 205,242 (+2,592) | 448,069 (+8,770) | +| 2025-08-27 | 248,425 (+5,598) | 205,242 (+0) | 453,667 (+5,598) | +| 2025-08-28 | 252,808 (+4,383) | 205,242 (+0) | 458,050 (+4,383) | +| 2025-08-29 | 256,048 (+3,240) | 211,075 (+5,833) | 467,123 (+9,073) | +| 2025-08-30 | 258,864 (+2,816) | 212,397 (+1,322) | 471,261 (+4,138) | +| 2025-08-31 | 262,004 (+3,140) | 213,944 (+1,547) | 475,948 (+4,687) | +| 2025-09-01 | 265,386 (+3,382) | 215,115 (+1,171) | 480,501 (+4,553) | +| 2025-09-02 | 270,516 (+5,130) | 217,075 (+1,960) | 487,591 (+7,090) | +| 2025-09-03 | 274,794 (+4,278) | 219,755 (+2,680) | 494,549 (+6,958) | +| 2025-09-05 | 283,771 (+8,977) | 223,793 (+4,038) | 507,564 (+13,015) | +| 2025-09-06 | 286,248 (+2,477) | 225,036 (+1,243) | 511,284 (+3,720) | +| 2025-09-07 | 288,623 (+2,375) | 225,866 (+830) | 514,489 (+3,205) | +| 2025-09-08 | 293,363 (+4,740) | 227,073 (+1,207) | 520,436 (+5,947) | +| 2025-09-09 | 300,090 (+6,727) | 229,788 (+2,715) | 529,878 (+9,442) | +| 2025-09-10 | 307,311 (+7,221) | 233,435 (+3,647) | 540,746 (+10,868) | +| 2025-09-11 | 314,085 (+6,774) | 237,356 (+3,921) | 551,441 (+10,695) | +| 2025-09-12 | 321,050 (+6,965) | 240,728 (+3,372) | 561,778 (+10,337) | +| 2025-09-13 | 324,894 (+3,844) | 245,539 (+4,811) | 570,433 (+8,655) | +| 2025-09-14 | 328,879 (+3,985) | 248,245 (+2,706) | 577,124 (+6,691) | +| 2025-09-15 | 334,248 (+5,369) | 250,983 (+2,738) | 585,231 (+8,107) | +| 2025-09-16 | 342,673 (+8,425) | 255,264 (+4,281) | 597,937 (+12,706) | +| 2025-09-17 | 351,146 (+8,473) | 260,970 (+5,706) | 612,116 (+14,179) | +| 2025-09-18 | 358,719 (+7,573) | 266,922 (+5,952) | 625,641 (+13,525) | +| 2025-09-19 | 365,423 (+6,704) | 271,859 (+4,937) | 637,282 (+11,641) | +| 2025-09-20 | 372,092 (+6,669) | 276,917 (+5,058) | 649,009 (+11,727) | +| 2025-09-21 | 377,084 (+4,992) | 280,261 (+3,344) | 657,345 (+8,336) | +| 2025-09-22 | 382,515 (+5,431) | 284,009 (+3,748) | 666,524 (+9,179) | +| 2025-09-23 | 387,011 (+4,496) | 289,129 (+5,120) | 676,140 (+9,616) | +| 2025-09-24 | 393,352 (+6,341) | 294,927 (+5,798) | 688,279 (+12,139) | +| 2025-09-25 | 398,914 (+5,562) | 301,663 (+6,736) | 700,577 (+12,298) | +| 2025-09-26 | 404,402 (+5,488) | 306,713 (+5,050) | 711,115 (+10,538) | +| 2025-09-27 | 411,620 (+7,218) | 317,763 (+11,050) | 729,383 (+18,268) | +| 2025-09-28 | 414,910 (+3,290) | 322,522 (+4,759) | 737,432 (+8,049) | +| 2025-09-29 | 419,987 (+5,077) | 328,033 (+5,511) | 748,020 (+10,588) | +| 2025-09-30 | 428,007 (+8,020) | 336,472 (+8,439) | 764,479 (+16,459) | +| 2025-10-02 | 440,880 (+12,873) | 348,099 (+11,627) | 788,979 (+24,500) | +| 2025-10-03 | 446,905 (+6,025) | 359,937 (+11,838) | 806,842 (+17,863) | +| 2025-10-04 | 452,563 (+5,658) | 370,386 (+10,449) | 822,949 (+16,107) | +| 2025-10-05 | 455,560 (+2,997) | 374,745 (+4,359) | 830,305 (+7,356) | +| 2025-10-06 | 460,947 (+5,387) | 379,489 (+4,744) | 840,436 (+10,131) | +| 2025-10-07 | 467,382 (+6,435) | 385,438 (+5,949) | 852,820 (+12,384) | +| 2025-10-08 | 474,677 (+7,295) | 394,139 (+8,701) | 868,816 (+15,996) | +| 2025-10-09 | 479,215 (+4,538) | 400,526 (+6,387) | 879,741 (+10,925) | +| 2025-10-10 | 484,414 (+5,199) | 406,015 (+5,489) | 890,429 (+10,688) | +| 2025-10-11 | 488,430 (+4,016) | 414,699 (+8,684) | 903,129 (+12,700) | +| 2025-10-12 | 492,126 (+3,696) | 418,745 (+4,046) | 910,871 (+7,742) | +| 2025-10-13 | 497,573 (+5,447) | 423,531 (+4,786) | 921,104 (+10,233) | +| 2025-10-14 | 505,190 (+7,617) | 429,286 (+5,755) | 934,476 (+13,372) | +| 2025-10-15 | 512,767 (+7,577) | 439,290 (+10,004) | 952,057 (+17,581) | +| 2025-10-16 | 517,739 (+4,972) | 447,137 (+7,847) | 964,876 (+12,819) | +| 2025-10-17 | 526,294 (+8,555) | 457,467 (+10,330) | 983,761 (+18,885) | +| 2025-10-18 | 531,565 (+5,271) | 465,272 (+7,805) | 996,837 (+13,076) | +| 2025-10-19 | 536,210 (+4,645) | 469,078 (+3,806) | 1,005,288 (+8,451) | +| 2025-10-20 | 541,314 (+5,104) | 472,952 (+3,874) | 1,014,266 (+8,978) | +| 2025-10-21 | 548,786 (+7,472) | 479,703 (+6,751) | 1,028,489 (+14,223) | +| 2025-10-22 | 557,999 (+9,213) | 491,395 (+11,692) | 1,049,394 (+20,905) | +| 2025-10-23 | 564,777 (+6,778) | 498,736 (+7,341) | 1,063,513 (+14,119) | +| 2025-10-24 | 572,758 (+7,981) | 506,905 (+8,169) | 1,079,663 (+16,150) | +| 2025-10-25 | 578,929 (+6,171) | 516,129 (+9,224) | 1,095,058 (+15,395) | +| 2025-10-26 | 584,411 (+5,482) | 521,179 (+5,050) | 1,105,590 (+10,532) | +| 2025-10-27 | 590,045 (+5,634) | 526,001 (+4,822) | 1,116,046 (+10,456) | +| 2025-10-28 | 595,855 (+5,810) | 532,438 (+6,437) | 1,128,293 (+12,247) | +| 2025-10-29 | 606,314 (+10,459) | 542,064 (+9,626) | 1,148,378 (+20,085) | +| 2025-10-30 | 617,912 (+11,598) | 555,026 (+12,962) | 1,172,938 (+24,560) | +| 2025-10-31 | 626,688 (+8,776) | 564,579 (+9,553) | 1,191,267 (+18,329) | +| 2025-11-01 | 636,101 (+9,413) | 581,806 (+17,227) | 1,217,907 (+26,640) | +| 2025-11-02 | 644,071 (+7,970) | 590,004 (+8,198) | 1,234,075 (+16,168) | +| 2025-11-03 | 653,187 (+9,116) | 597,139 (+7,135) | 1,250,326 (+16,251) | +| 2025-11-04 | 663,971 (+10,784) | 608,056 (+10,917) | 1,272,027 (+21,701) | +| 2025-11-05 | 675,129 (+11,158) | 619,690 (+11,634) | 1,294,819 (+22,792) | +| 2025-11-06 | 686,313 (+11,184) | 630,885 (+11,195) | 1,317,198 (+22,379) | +| 2025-11-07 | 696,670 (+10,357) | 642,146 (+11,261) | 1,338,816 (+21,618) | +| 2025-11-08 | 706,040 (+9,370) | 653,489 (+11,343) | 1,359,529 (+20,713) | +| 2025-11-09 | 713,470 (+7,430) | 660,459 (+6,970) | 1,373,929 (+14,400) | +| 2025-11-10 | 722,360 (+8,890) | 668,225 (+7,766) | 1,390,585 (+16,656) | +| 2025-11-11 | 729,800 (+7,440) | 677,501 (+9,276) | 1,407,301 (+16,716) | +| 2025-11-12 | 740,238 (+10,438) | 686,454 (+8,953) | 1,426,692 (+19,391) | +| 2025-11-13 | 749,948 (+9,710) | 696,157 (+9,703) | 1,446,105 (+19,413) | +| 2025-11-14 | 759,966 (+10,018) | 705,237 (+9,080) | 1,465,203 (+19,098) | +| 2025-11-15 | 765,959 (+5,993) | 712,870 (+7,633) | 1,478,829 (+13,626) | +| 2025-11-16 | 771,074 (+5,115) | 716,596 (+3,726) | 1,487,670 (+8,841) | +| 2025-11-17 | 780,235 (+9,161) | 723,339 (+6,743) | 1,503,574 (+15,904) | +| 2025-11-18 | 791,644 (+11,409) | 732,544 (+9,205) | 1,524,188 (+20,614) | +| 2025-11-19 | 804,486 (+12,842) | 747,624 (+15,080) | 1,552,110 (+27,922) | +| 2025-11-20 | 814,675 (+10,189) | 757,907 (+10,283) | 1,572,582 (+20,472) | +| 2025-11-21 | 826,361 (+11,686) | 769,307 (+11,400) | 1,595,668 (+23,086) | +| 2025-11-22 | 837,273 (+10,912) | 780,996 (+11,689) | 1,618,269 (+22,601) | +| 2025-11-23 | 846,614 (+9,341) | 795,069 (+14,073) | 1,641,683 (+23,414) | +| 2025-11-24 | 856,796 (+10,182) | 804,033 (+8,964) | 1,660,829 (+19,146) | +| 2025-11-25 | 869,492 (+12,696) | 817,339 (+13,306) | 1,686,831 (+26,002) | +| 2025-11-26 | 881,475 (+11,983) | 832,518 (+15,179) | 1,713,993 (+27,162) | +| 2025-11-27 | 894,027 (+12,552) | 846,180 (+13,662) | 1,740,207 (+26,214) | +| 2025-11-28 | 901,768 (+7,741) | 856,482 (+10,302) | 1,758,250 (+18,043) | +| 2025-11-29 | 908,695 (+6,927) | 863,361 (+6,879) | 1,772,056 (+13,806) | +| 2025-11-30 | 916,402 (+7,707) | 870,194 (+6,833) | 1,786,596 (+14,540) | +| 2025-12-01 | 925,963 (+9,561) | 876,500 (+6,306) | 1,802,463 (+15,867) | +| 2025-12-02 | 939,308 (+13,345) | 890,919 (+14,419) | 1,830,227 (+27,764) | +| 2025-12-03 | 952,371 (+13,063) | 903,713 (+12,794) | 1,856,084 (+25,857) | +| 2025-12-04 | 965,688 (+13,317) | 916,471 (+12,758) | 1,882,159 (+26,075) | +| 2025-12-05 | 978,063 (+12,375) | 930,616 (+14,145) | 1,908,679 (+26,520) | +| 2025-12-06 | 987,906 (+9,843) | 943,773 (+13,157) | 1,931,679 (+23,000) | +| 2025-12-07 | 994,050 (+6,144) | 951,425 (+7,652) | 1,945,475 (+13,796) | +| 2025-12-08 | 1,000,947 (+6,897) | 957,149 (+5,724) | 1,958,096 (+12,621) | +| 2025-12-09 | 1,011,581 (+10,634) | 973,922 (+16,773) | 1,985,503 (+27,407) | +| 2025-12-10 | 1,025,962 (+14,381) | 991,708 (+17,786) | 2,017,670 (+32,167) | +| 2025-12-11 | 1,045,225 (+19,263) | 1,010,559 (+18,851) | 2,055,784 (+38,114) | +| 2025-12-12 | 1,061,439 (+16,214) | 1,030,838 (+20,279) | 2,092,277 (+36,493) | +| 2025-12-13 | 1,073,614 (+12,175) | 1,044,608 (+13,770) | 2,118,222 (+25,945) | +| 2025-12-14 | 1,082,058 (+8,444) | 1,052,425 (+7,817) | 2,134,483 (+16,261) | +| 2025-12-15 | 1,093,737 (+11,679) | 1,059,078 (+6,653) | 2,152,815 (+18,332) | +| 2025-12-16 | 1,120,648 (+26,911) | 1,078,022 (+18,944) | 2,198,670 (+45,855) | +| 2025-12-17 | 1,151,257 (+30,609) | 1,097,661 (+19,639) | 2,248,918 (+50,248) | +| 2025-12-18 | 1,178,630 (+27,373) | 1,113,418 (+15,757) | 2,292,048 (+43,130) | +| 2025-12-19 | 1,203,614 (+24,984) | 1,129,698 (+16,280) | 2,333,312 (+41,264) | +| 2025-12-20 | 1,223,101 (+19,487) | 1,146,258 (+16,560) | 2,369,359 (+36,047) | +| 2025-12-21 | 1,242,831 (+19,730) | 1,158,909 (+12,651) | 2,401,740 (+32,381) | +| 2025-12-22 | 1,262,644 (+19,813) | 1,169,121 (+10,212) | 2,431,765 (+30,025) | +| 2025-12-23 | 1,286,744 (+24,100) | 1,186,439 (+17,318) | 2,473,183 (+41,418) | +| 2025-12-24 | 1,309,437 (+22,693) | 1,203,767 (+17,328) | 2,513,204 (+40,021) | +| 2025-12-25 | 1,333,207 (+23,770) | 1,217,283 (+13,516) | 2,550,490 (+37,286) | +| 2025-12-26 | 1,352,481 (+19,274) | 1,227,615 (+10,332) | 2,580,096 (+29,606) | +| 2025-12-27 | 1,371,873 (+19,392) | 1,238,236 (+10,621) | 2,610,109 (+30,013) | +| 2025-12-28 | 1,390,522 (+18,649) | 1,245,690 (+7,454) | 2,636,212 (+26,103) | +| 2025-12-29 | 1,415,770 (+25,248) | 1,257,101 (+11,411) | 2,672,871 (+36,659) | diff --git a/packages/tui/internal/commands/command.go b/packages/tui/internal/commands/command.go index dfa7abdd0db..1e6e9c15778 100644 --- a/packages/tui/internal/commands/command.go +++ b/packages/tui/internal/commands/command.go @@ -106,6 +106,8 @@ const ( InputPasteCommand CommandName = "input_paste" InputSubmitCommand CommandName = "input_submit" InputNewlineCommand CommandName = "input_newline" + HistoryPreviousCommand CommandName = "history_previous" + HistoryNextCommand CommandName = "history_next" MessagesPageUpCommand CommandName = "messages_page_up" MessagesPageDownCommand CommandName = "messages_page_down" MessagesHalfPageUpCommand CommandName = "messages_half_page_up" @@ -264,6 +266,16 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry { Description: "insert newline", Keybindings: parseBindings("shift+enter", "ctrl+j"), }, + { + Name: HistoryPreviousCommand, + Description: "previous input", + Keybindings: parseBindings("up"), + }, + { + Name: HistoryNextCommand, + Description: "next input", + Keybindings: parseBindings("down"), + }, { Name: MessagesPageUpCommand, Description: "page up", diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go index 67f1f75eae1..0b61244a83d 100644 --- a/packages/tui/internal/components/chat/editor.go +++ b/packages/tui/internal/components/chat/editor.go @@ -39,6 +39,8 @@ type EditorComponent interface { Clear() (tea.Model, tea.Cmd) Paste() (tea.Model, tea.Cmd) Newline() (tea.Model, tea.Cmd) + HistoryPrevious() (tea.Model, tea.Cmd) + HistoryNext() (tea.Model, tea.Cmd) SetValue(value string) SetInterruptKeyInDebounce(inDebounce bool) SetExitKeyInDebounce(inDebounce bool) @@ -50,6 +52,8 @@ type editorComponent struct { spinner spinner.Model interruptKeyInDebounce bool exitKeyInDebounce bool + history []string + historyIndex int } func (m *editorComponent) Init() tea.Cmd { @@ -357,6 +361,9 @@ func (m *editorComponent) Submit() (tea.Model, tea.Cmd) { }) } + m.history = append(m.history, value) + m.historyIndex = len(m.history) + updated, cmd := m.Clear() m = updated.(*editorComponent) cmds = append(cmds, cmd) @@ -403,6 +410,34 @@ func (m *editorComponent) Newline() (tea.Model, tea.Cmd) { return m, nil } +func (m *editorComponent) HistoryPrevious() (tea.Model, tea.Cmd) { + if len(m.history) == 0 { + return m, nil + } + if m.historyIndex > 0 { + m.historyIndex-- + } + m.SetValue(m.history[m.historyIndex]) + m.textarea.CursorEnd() + return m, nil +} + +func (m *editorComponent) HistoryNext() (tea.Model, tea.Cmd) { + if len(m.history) == 0 { + m.SetValue("") + return m, nil + } + if m.historyIndex < len(m.history)-1 { + m.historyIndex++ + m.SetValue(m.history[m.historyIndex]) + } else { + m.historyIndex = len(m.history) + m.SetValue("") + } + m.textarea.CursorEnd() + return m, nil +} + func (m *editorComponent) SetInterruptKeyInDebounce(inDebounce bool) { m.interruptKeyInDebounce = inDebounce } @@ -487,6 +522,8 @@ func NewEditorComponent(app *app.App) EditorComponent { textarea: ta, spinner: s, interruptKeyInDebounce: false, + history: []string{}, + historyIndex: 0, } return m diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.go index 1e34d4cbcc4..0a454a4a474 100644 --- a/packages/tui/internal/tui/tui.go +++ b/packages/tui/internal/tui/tui.go @@ -950,6 +950,14 @@ func (a appModel) executeCommand(command commands.Command) (tea.Model, tea.Cmd) updated, cmd := a.editor.Newline() a.editor = updated.(chat.EditorComponent) cmds = append(cmds, cmd) + case commands.HistoryPreviousCommand: + updated, cmd := a.editor.HistoryPrevious() + a.editor = updated.(chat.EditorComponent) + cmds = append(cmds, cmd) + case commands.HistoryNextCommand: + updated, cmd := a.editor.HistoryNext() + a.editor = updated.(chat.EditorComponent) + cmds = append(cmds, cmd) case commands.MessagesFirstCommand: updated, cmd := a.messages.First() a.messages = updated.(chat.MessagesComponent) diff --git a/packages/tui/sdk/config.go b/packages/tui/sdk/config.go index 7c04cd14b83..e45116cbf4e 100644 --- a/packages/tui/sdk/config.go +++ b/packages/tui/sdk/config.go @@ -518,6 +518,10 @@ type Keybinds struct { InputPaste string `json:"input_paste,required"` // Submit input InputSubmit string `json:"input_submit,required"` + // Previous input history + HistoryPrevious string `json:"history_previous,required"` + // Next input history + HistoryNext string `json:"history_next,required"` // Leader key for keybind combinations Leader string `json:"leader,required"` // Copy message @@ -580,6 +584,8 @@ type keybindsJSON struct { InputNewline apijson.Field InputPaste apijson.Field InputSubmit apijson.Field + HistoryPrevious apijson.Field + HistoryNext apijson.Field Leader apijson.Field MessagesCopy apijson.Field MessagesFirst apijson.Field