Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(phone): implement phone search functionality with commands and scope bar

Dev jacobae00380fd5d1
diff --git a/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
index 0fe97ed36..273d6693b 100644
Binary files a/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
index ba3053989..f25bf437d 100644
Binary files a/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index f48b7e38e..9ddd0e39b 100644
Binary files a/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index e5bc654c4..3e0a888c3 100644
Binary files a/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index f44ecc50c..2bd73ee6d 100644
Binary files a/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/mobile/assets/app_icon.png b/mobile/assets/app_icon.png
index 1f96c25ba..b23906df7 100644
Binary files a/mobile/assets/app_icon.png and b/mobile/assets/app_icon.png differ
diff --git a/mobile/assets/app_icon.svg b/mobile/assets/app_icon.svg
new file mode 100644
index 000000000..62e212e94
--- /dev/null
+++ b/mobile/assets/app_icon.svg
@@ -0,0 +1,17 @@
+<svg width="400" height="400" viewBox="0 0 400 400" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_6337_1342)">
+<rect width="400" height="400" rx="60" fill="url(#paint0_linear_6337_1342)"/>
+<circle cx="200" cy="192" r="192" stroke="#030303" stroke-width="2.2"/>
+<rect x="43" y="69" width="314" height="315" stroke="#030303" stroke-width="2.2"/>
+<path d="M190.011 70.7326C191.753 69.9926 194.472 69.2152 196.292 70.0215C196.266 70.4473 195.87 70.4399 195.239 70.6894C192.582 71.7405 191.348 72.3783 189.426 74.4942C190.511 73.9004 193.192 72.7203 194.351 73.3766C193.587 73.7129 193.336 73.7619 192.761 74.3428C193.015 75.1091 194.127 74.6032 195.048 75.696L194.855 75.8587C190.062 76.527 189.631 78.6743 189.221 82.9106C188.73 83.3344 188.463 83.5222 188.085 84.0678L188.249 84.1955C191.167 82.5805 189.884 77.1543 194.867 77.4467C196.08 77.5181 197.997 78.1914 198.837 79.0558C198.525 80.3012 195.339 79.7716 194.391 81.3425C194.285 82.5718 195.213 83.5724 195.932 84.5936C194.706 85.6136 193.666 86.8485 192.291 87.9858C195.58 88.0369 195.344 88.1759 198.29 89.1013C198.73 88.9312 198.996 88.7713 199.458 88.8525C199.7 90.2986 199.367 94.2358 199.528 96.003C199.596 96.739 199.187 97.5215 199.424 98.5864C200.535 99.8081 201.477 98.5924 202.878 99.1605C203.15 99.632 203.064 99.3737 203.003 99.99C202.134 101.275 201.265 99.5882 200.885 102.129L200.801 102.416L201.409 102.513C202.722 103.148 203.909 103.246 204.921 103.854C205.139 104.523 205.158 104.218 205.006 104.8C202.939 104.546 200.425 104.192 198.378 104.446L198.294 104.688C199.275 105.157 202.112 104.923 202.493 105.631L202.227 106.571C201.374 107.258 199.475 106.982 198.067 107.748C197.405 108.637 198.048 109.239 198.846 109.755C199.436 109.695 199.383 109.55 199.93 109.006C201.901 108.477 200.874 112.154 204.923 109.906C210.556 106.779 210.736 106.398 211.035 99.6845C209.854 100.364 209.518 100.638 208.475 101.527C209.557 96.4152 212.555 98.4476 211.323 91.8934C207.45 93.7156 209.025 92.0083 207.595 91.7705C207.175 92.6529 207.248 92.603 206.48 93.1332L206.186 93.3326C206.546 93.7581 206.586 93.7909 206.841 94.2817C205.647 95.3558 203.709 93.9669 202.735 93.2019C202.418 93.2874 202.411 93.3536 202.165 93.5742C201.628 92.4933 200.705 89.4821 200.986 88.3168L201.219 88.2376C204.356 89.7339 205.512 86.4073 210.364 89.4541C209.59 87.2491 209.319 86.587 209.768 84.2449C208.935 82.2411 208.6 81.7502 207.318 79.9956C207.567 79.5 207.787 79.4582 208.279 79.2216C209.371 78.6961 210.16 81.4641 211.368 82.0851L211.6 81.8452C212.104 78.9688 209.223 77.7428 209.188 76.2518L209.513 76.0155C212.282 75.8462 212.638 77.0974 213.813 79.3487C213.672 78.6791 213.615 78.1968 213.536 77.5138L213.712 77.4514C214.213 77.9089 214.435 78.5869 214.748 79.2462C215.161 79.2396 214.954 79.2904 215.346 78.8997C215.788 76.9943 214.866 75.8751 213.424 74.9226C212.28 74.8363 210.993 74.8143 209.836 74.7685C211.007 74.0059 211.84 73.44 213.279 73.4483C215.898 73.4635 217.501 75.7038 217.387 78.2722L217.147 78.4827L216.441 78.1595L216.265 78.2572C216.382 79.24 217.207 79.7839 217.484 80.6332C218.075 82.4561 217.409 84.288 220.264 83.8441C220.877 83.749 221.102 83.4328 221.412 82.8843C221.449 82.2546 221.454 82.2008 221.155 81.6588L220.989 81.3458L220.855 81.1021C221.148 80.9987 221.361 80.9552 221.638 81.2007C225.248 84.4125 221.772 85.7247 220.767 87.3599C221.781 89.2035 221.046 88.5934 220.946 90.0554C220.807 92.1187 225.434 91.2992 226.503 93.656C227.214 95.2279 227.544 95.8794 227.199 97.745C227.02 98.959 225.424 101.068 224.093 100.78L223.961 100.552C225.703 98.6074 226.011 96.7223 223.066 95.8306L222.914 95.9823C223.71 98.5806 223.173 99.1146 221.473 101.061C222.089 102.046 222.672 103.175 223.73 103.64L223.939 103.511C224.04 102.963 224.155 102.418 224.284 101.877L224.537 101.866C227.579 105.651 223.754 111.325 221.28 110.127C221.071 109.553 222.133 109.331 222.608 108.14C222.496 107.353 222.65 107.686 222.144 107.099C219.307 106.004 220.38 109.67 219.221 110.917C218.951 111.206 218.812 111.558 218.794 111.948C219.571 112.813 220.515 112.088 221.187 111.529C221.48 112.598 221.894 114.351 221.599 115.403C220.972 117.633 218.838 119.17 216.613 118.586L216.516 118.338C217.359 117.772 218.425 117.443 218.528 116.37C218.068 115.637 217.066 115.53 216.29 115.445C215.078 115.312 215.762 116.962 215.515 117.711C215.363 118.175 214.913 120.646 214.592 120.998C217.644 122.466 221.038 123.889 224.181 125.372C234.265 119.538 238.14 119.656 249.346 120.861C253.73 118.364 256.723 115.689 262.006 113.831C266.448 112.269 274.272 109.79 278.771 111.899L278.807 112.113C277.769 112.406 275.299 112.317 273.955 112.52C268.045 112.934 264.014 118.408 259.448 120.532C252.885 123.583 252.014 122.375 247.426 128.936C249.48 128.287 251.559 127.428 253.565 126.833C257.501 125.664 260.787 124.729 264.572 123.012C271.294 119.962 273.39 115.851 280.778 114.594L279.154 116.709C279.867 116.632 280.577 116.522 281.279 116.38C285.856 115.422 288.752 112.118 291.196 108.27C286.492 108.894 280.799 110.071 276.214 110.434C278.385 108.158 280.747 105.722 283.252 103.861C290.631 98.2778 299.976 97.4869 308.287 94.0762C310.352 93.2291 312.308 92.2491 314.276 91.1966C316.432 90.0442 318.521 88.7702 320.799 87.8945C315.398 94.8445 309.161 94.7491 302.784 99.6016C300.715 101.177 298.172 105.225 296.666 107.474C300.587 106.268 302.708 105.05 306.18 102.949C311.276 99.8652 319.695 91.2807 325.678 91.8144C332.036 88.1719 330.393 85.7751 334.005 80.7974C334.561 79.3842 339.085 78.7851 339.552 78.097C340.904 76.1017 349.073 71.871 351.274 72.4838C351.69 72.6022 352.024 72.9238 352.163 73.3429C353.104 76.1254 342.111 78.1153 340.523 80.735C341.81 81.137 350.901 74.9435 352.519 77.7316C352.473 80.8339 341.793 82.4572 340.766 84.6909C341.773 85.1437 347.234 81.7211 349.497 81.9015C350.047 82.2599 349.831 82.0255 350.132 82.6689C349.858 84.9093 342.27 87.5563 340.326 87.9317C337.741 91.4035 334.029 94.8523 329.685 95.5241C327.875 95.804 326.239 95.8792 324.662 96.9064C316.145 102.454 309.662 110.695 300.695 115.633C298.592 116.791 296.697 117.746 294.414 118.517C292.964 119.007 291.189 119.418 289.797 119.939C288.414 120.457 287.296 121.547 285.638 121.91C283.461 122.387 280.945 122.27 278.908 123.155C275.169 124.779 272.055 127.612 268.536 129.794C274.652 131.117 278.248 132.365 284.248 130.105C286.283 129.338 290.072 129.02 292.271 129.039C297.31 129.081 302.309 130.511 307.252 131.377C312.798 132.333 318.319 131.908 323.876 131.343C327.05 131.02 329.153 129.355 332.074 128.276C333.499 127.509 335.832 128.239 337.148 127.905C339.321 127.263 340.77 127.246 343.013 127.651C344.408 127.903 345.47 127.111 346.677 128.225C346.746 128.615 346.851 128.941 346.546 129.266C344.582 131.352 341.683 130.65 339.848 129.181C337.873 129.357 335.436 129.099 333.644 129.504C331.343 130.024 327.246 132.606 325.053 132.975C320.087 133.808 314.577 134.141 309.587 134.714C313.581 135.938 317.318 136.837 321.475 137.199C322.781 137.313 326.329 138.431 327.38 137.871C326.929 137.451 326.978 137.652 326.852 137.18C328.414 136.636 329.843 136.369 331.279 135.431C333.066 134.261 334.609 132.24 336.677 131.621C340.535 130.465 342.571 132.507 346.449 130.648C348.197 131.022 354.708 132.625 355.433 134.041C355.42 134.821 355.534 134.483 355.097 135.098C353.018 136.132 348.991 134.129 346.682 133.889C345.373 133.753 343.935 133.842 342.622 133.899C345.019 134.675 356.384 135.863 355.647 139.367C353.86 141.475 345.578 136.665 343.055 137.19C342.804 137.242 342.76 137.438 342.629 137.64L342.78 137.909C344.826 138.132 352.869 140.41 353.592 142.395C353.496 142.814 353.436 143.013 353.053 143.27C351.443 144.35 343.583 140.557 341.194 140.37L340.873 140.799C341.927 141.797 348.235 142.684 349.084 144.824C348.967 145.258 349.06 145.169 348.776 145.477C347.788 146.545 342.048 144.177 340.776 143.683C337.128 142.267 335.404 143.805 331.539 143.632C328.924 143.688 326.001 141.37 323.518 141.518C313.418 142.122 303.816 147.139 293.683 147.444C291.082 147.54 288.48 147.336 285.924 146.837C283.403 146.335 280.417 145.455 277.942 145.419C271.931 145.333 267.056 147.717 260.895 147.963C257.77 148.111 254.638 147.914 251.554 147.375C249.307 146.981 245.515 146.126 243.373 146.063L243.102 146.056C240.476 150.817 237.049 153.692 234.307 157.255C233.185 158.715 231.415 167.454 230.332 170.155C228.25 175.336 224.719 184.156 225.973 189.751C226.257 191.656 227.966 194.996 227.988 196.801C228.036 201.001 228.212 203.281 229.658 207.271C230.63 209.948 231.142 212.363 232.635 214.989C234.373 218.105 236.754 221.145 238.972 223.909C245.578 232.135 250.644 240.534 252.593 251.192C253.483 256.047 253.985 261.793 256.178 266.176C257.257 268.334 259.632 270.063 260.849 272.162C262.004 273.837 262.736 277.463 264.155 278.805C268.369 282.793 272.739 285.573 275.926 290.71C282.471 301.26 282.491 315.127 288.561 325.666C289.791 327.8 291.917 327.232 292.566 331.235C296.417 332.771 306.537 339.626 308.289 343.731C309.939 345.87 308.087 347.36 308.109 347.802C308.221 349.954 310.005 350.336 306.356 352.129C305.604 353.127 306.614 353.941 305.365 354.873C304.397 355.599 304.095 355.238 303.022 355.086C302.175 356.099 302.387 358.208 300.534 358.367C297.576 358.621 295.526 356.913 293.736 354.743C292.674 353.458 291.803 352.484 291.059 350.977C289.769 348.364 288.799 345.58 287.121 343.195C285.638 341.088 281.994 340.38 281.91 337.31C281.87 336.262 281.813 335.749 280.942 335.068C279.871 334.243 279.975 332.98 279.737 331.76C279.258 328.465 277.245 325.574 275.297 322.996C272.972 319.917 270.165 316.609 267.225 314.109C263.97 311.342 260.257 310.242 257.746 306.605C254.755 302.559 253.617 298.025 252.21 293.212C251.739 291.599 250.998 288.986 250.182 287.601C248.821 285.291 246.108 284.556 244.263 282.287C243.003 280.75 242.211 278.801 240.969 277.254C240.151 276.341 239.137 275.495 238.193 274.709C233.794 271.052 231.562 265.884 227.695 261.693C226.185 268.104 223.398 275.601 222.177 281.966C221.728 284.3 222.342 286.911 222.157 289.294C221.946 292.003 221.176 294.869 221.586 297.623C223.202 305.227 225.661 312.086 224.896 320.191C223.834 331.412 218.717 344.627 217.204 355.744C216.775 358.896 217.825 360.472 218.012 363.428C218.009 363.498 218.005 363.567 218.001 363.637C223.075 366.285 224.408 369.652 228.973 372.337C230.091 372.995 231.931 372.973 233.167 373.431C234.769 374.027 236.28 374.073 237.074 375.578C237.307 376.02 237.351 376.77 237.094 377.179C235.657 379.473 232.306 380.513 230.302 381.092C229.803 381.237 228.41 381.921 227.902 381.82C225.489 381.337 220.965 380.98 218.858 379.952C217.235 379.16 216.156 377.792 214.214 377.455C211.699 377.019 209.342 377.64 206.915 377.063C205.873 376.817 204.813 376.078 204.336 375.098C202.999 372.358 205.361 368.939 205.568 366.114C205.656 364.915 204.881 362.864 205.121 361.804C205.37 360.708 206.188 359.314 206.507 357.976C207.846 352.384 207.16 338.992 205.844 333.425C204.969 329.722 202.931 327.211 202.818 322.191C202.7 317.072 203.45 314.059 204.663 309.18C205.178 307.107 205.82 303.57 205.856 301.483C205.926 297.504 203.243 293.963 203.076 289.8C202.862 284.454 204.461 276.889 204.254 271.514C204.002 264.98 201.774 258.947 201.131 252.318C200.986 250.835 200.487 240.665 200.408 240.518C199.776 240.394 199.957 240.305 199.491 240.493C199.227 241.756 199.303 243.615 199.227 244.987C199.077 247.59 198.822 250.186 198.468 252.771C198.118 255.148 197.683 257.513 197.164 259.857C196.438 262.997 195.346 266.552 195.305 269.755C195.228 275.85 196.475 282.78 195.89 289.035C195.855 292.903 192.522 297.681 192.897 301.376C193.541 307.727 197.008 313.881 196.796 320.649C196.645 325.442 195.54 328.374 194.418 332.938C193.759 335.622 194.24 340.154 194.231 342.994C194.394 346.159 194.905 353.724 196.48 356.536C197.329 358.051 198.111 359.205 198.699 360.927C199.156 362.257 198.387 364.174 198.521 364.971C199.044 368.097 199.462 368.217 199.134 371.473C200.456 373.572 201.162 374.869 201.063 377.446C200.966 379.982 200.504 381.042 198.156 381.767C195.815 382.491 195.216 380.92 193.801 380.824C191.705 382.425 191.9 381.532 189.806 380.94C188.578 381.373 188.528 381.378 187.265 381.028C185.709 380.596 184.75 380.632 183.278 379.826C183.025 379.316 182.564 378.44 182.369 377.914C181.189 374.734 183.977 372.726 185.422 370.33C186.04 369.305 186.466 368.057 186.877 366.965C186.571 366.454 185.814 365.135 185.76 364.631C185.405 360.891 186.678 358.06 185.314 354.307C180.036 339.77 171.188 323.048 174.967 306.772C175.666 303.763 176.326 299.278 176.817 296.196C177.257 294.142 176.196 291.17 176.382 289.217C176.766 284.96 177.451 278.107 176.069 273.912C174.664 269.649 173.457 265.862 172.394 261.449C169.4 264.988 167.226 268.548 164.341 272.136C163.2 273.916 159.507 275.995 158.524 277.536C156.47 280.758 155.275 283.226 151.687 285.069C150.725 285.703 149.258 286.443 148.674 287.479C145.447 293.202 144.952 299.627 140.616 304.918C138.048 308.457 134.476 310.47 131.318 313.274C127.021 317.09 122.631 322.546 120.62 328.067C119.534 331.046 120.319 333.352 117.963 335.683C117.167 340.887 115.065 339.906 112.23 343.4C110.642 345.357 109.648 349.611 108.098 351.772C106.469 354.043 103.992 357.595 101.172 358.23C98.6494 358.634 97.1471 357.651 96.9354 355.048L96.662 354.954C94.3623 355.7 93.6463 354.813 93.5809 352.422C93.5653 351.849 91.7932 351.473 91.2054 350.484C91.4913 348.637 92.2308 348.855 90.8676 347.028C90.275 344.325 93.7837 340.113 95.8159 338.635C99.3244 336.083 102.967 333.296 106.686 331.087C106.76 330.625 106.981 329.211 107.174 328.886C109.146 325.546 111.486 325.212 112.82 320.971C116.136 310.432 117.25 298.161 123.088 288.718C125.135 285.406 128.348 282.332 131.452 280.083C132.76 279.135 134.603 277.803 135.729 276.668C137.196 275.19 138.104 272.533 139.508 270.931C140.921 269.318 142.813 267.886 143.826 265.956C145.961 261.734 146.587 256.451 147.434 251.818C149.418 240.95 154.502 232.093 161.353 223.739C163.188 221.502 165.233 218.821 166.806 216.322C169.565 211.933 170.287 206.689 172.663 202.078C172.045 196.926 173.056 195.237 174.285 190.382C176.046 183.421 171.067 174.877 169.007 168.424C168.563 167.032 166.108 158.016 165.848 157.703C162.409 153.559 159.655 150.761 156.768 145.997C154.506 146.086 151.68 146.785 149.397 147.203C145.924 147.857 142.391 148.11 138.863 147.957C133.028 147.712 128.004 145.357 122.208 145.429C119.231 145.466 116.665 146.303 113.789 146.867C111.142 147.374 108.447 147.558 105.758 147.414C95.9863 146.931 86.8396 142.455 77.1489 141.508C74.0405 141.204 71.8386 143.292 68.7695 143.603C66.0009 143.883 63.6485 142.837 60.9644 143.094C58.7504 143.382 52.9393 146.778 51.0419 145.441C50.7564 144.841 50.8004 145.153 50.9518 144.466C52.1266 143.052 55.2615 142.44 56.9983 141.51C57.2124 141.396 58.6745 141.194 59.1833 141.005L59.2011 140.529C55.9502 140.079 48.8596 144.714 46.4473 143.025C45.768 140.684 53.2302 139.018 54.9112 138.256C55.1946 138.127 56.9575 138.282 57.5935 138.187L57.4066 137.677C55.0883 135.728 45.8089 142.081 44.0338 139.288C44.0148 139.062 43.9471 138.438 44.0824 138.293C46.6412 135.554 54.6963 134.654 57.3677 133.957C54.1601 133.648 51.86 134.186 48.7615 135.001C47.5481 135.321 45.2505 135.828 44.3833 134.634C44.3613 134.334 44.3221 133.838 44.5796 133.657C46.2295 132.498 51.5448 131.138 53.3094 130.697C57.009 132.373 59.6482 130.449 63.489 131.727C65.5116 132.4 66.6887 134.143 68.4676 135.305C70.0399 136.332 71.3595 136.55 73.0869 137.037L73.124 137.237C72.6733 137.575 72.5752 137.553 72.3583 138.027C73.8072 138.387 76.3171 137.253 77.8351 137.146C82.1326 136.842 85.8279 135.929 89.9709 134.741C85.8123 133.961 79.7897 133.994 75.3304 133.051C71.6932 132.282 68.9341 130.172 65.5099 129.371C64.9055 129.23 60.6847 129.331 59.7258 129.331C58.5612 130.11 57.3972 130.681 55.9764 130.561C54.7755 130.459 52.9023 129.737 53.1368 128.226C54.014 127.316 58.4749 127.714 59.9142 127.412C60.3458 127.321 62.7744 127.97 63.4305 127.982C64.696 128.003 65.9226 127.591 67.1284 128.064C71.6446 129.564 72.139 131.073 77.1051 131.482C82.7409 131.947 86.9677 132.394 92.7368 131.377C97.8334 130.478 102.394 129.167 107.619 129.071C110.009 129.026 112.396 129.293 114.72 129.867C116.803 130.393 120.086 131.475 122.129 131.51C126.182 131.58 126.673 129.523 130.929 131.143C127.988 131.87 124.046 133.034 121.12 133.152C119.252 133.227 116.46 132.305 114.633 131.818C109.43 130.432 105.188 131.34 100.193 132.794C103.177 133.514 107.063 134.239 109.331 136.477C111.698 138.813 113.269 141.6 117.147 141.128C117.925 141.033 120.213 140.259 120.686 139.641L120.238 139.178L120.336 139.011C127.789 136.011 131.314 135.878 139.159 137.9C142.007 138.633 143.976 138.94 146.855 138.354C145.177 136.463 144.324 135.962 142.17 134.553C148.794 133.376 152.355 134.361 158.763 136.272C157.736 134.915 156.683 133.558 155.297 132.561C149.346 128.278 139.598 129.848 132.941 130.876C128.944 128.468 124.944 124.871 120.905 123.071C118.205 121.867 114.367 122.805 111.331 120.688C110.151 119.865 106.871 119.066 105.33 118.495C101.943 117.238 99.0139 115.72 95.9867 113.693C88.5625 108.722 82.5984 101.743 75.1341 96.8323C73.6274 95.8411 72.1892 95.9079 70.4795 95.6158C65.5929 94.7809 62.4962 91.7261 59.4728 88.0064C57.4403 87.4553 50.0199 84.8742 49.7624 82.5475C50.9846 80.5102 57.412 84.9473 58.7332 84.4486C55.9547 82.1113 50.7291 81.2137 47.8002 78.9925C47.3394 78.643 47.253 78.2558 47.2214 77.7412C47.5188 77.1622 47.4962 77.2036 48.0614 76.8901C50.4787 76.6099 57.6025 80.2984 60.1511 81.3694C56.5565 78.3083 52.7326 77.422 48.7267 75.1949C48.0672 74.8284 47.8472 74.4312 47.7113 73.7155C48.1056 72.1553 49.3643 72.1074 50.5991 72.6055C54.3927 74.136 57.4115 75.0426 60.3002 78.0473C60.9664 78.7403 65.0517 79.1334 66.0943 80.8678C68.2728 84.4932 68.7067 88.342 72.4677 90.7787C74.5369 92.1251 76.6293 91.8033 78.8236 92.7452C81.1788 93.7562 83.5042 95.5314 85.6024 97.0434C91.4833 101.407 96.1429 105.381 103.282 107.459C99.286 101.23 96.5355 97.9744 89.684 95.5894C85.6848 94.1974 81.6202 90.8316 78.6917 87.7081C82.4498 88.9842 87.2037 92.3413 91.2075 93.9026C106.023 99.6806 111.777 97.5962 123.323 110.25C119.544 109.146 112.826 105.562 108.957 106.37C107.639 107.512 109.979 110.188 110.789 111.232C113.361 114.544 116.405 116.292 120.525 116.694C119.991 116.028 119.489 115.307 118.989 114.612C126.651 115.953 128.687 120.129 135.585 123.18C139.402 124.868 142.856 125.802 146.791 126.992C148.475 127.501 150.634 128.399 152.336 129.028C152.106 129.104 151.87 129.183 151.624 129.264C154.063 128.989 157.196 128.469 159.357 129.91C161.315 131.215 161.936 134.545 163.544 136.72C166.043 140.101 169.393 141.641 172.034 144.543C174.334 147.07 175.051 150.793 178.189 153.035C180.361 154.693 182.343 155.854 185.03 156.421C186.738 156.782 190.72 156.191 191.317 158.465C191.401 158.787 191.226 159.431 190.944 159.647C188.577 161.466 185.564 161.434 182.744 161.393C182.038 161.383 181.293 162.471 181.509 163.242C182.279 165.989 184.666 168.086 186.825 169.732C193.539 168.087 189.664 171.281 191.781 174.738C194.878 179.793 197.289 184.448 195.082 190.644C194.479 192.338 193.222 195.409 193.445 197.26C193.825 200.409 196.462 203.281 196.442 206.655C196.466 211.247 195.335 217.31 190.024 211.942C187.103 208.995 185.213 204.616 185.189 200.393C185.165 196.263 185.652 194.644 182.885 191.346L182.708 191.137C177.479 199.806 179.63 199.308 183.817 206.753C184.191 207.417 185.944 214.014 186.368 215.337C184.976 213.905 182.553 210.499 181.041 209.576C178.249 207.87 177.331 207.974 174.534 205.692C174.327 206.285 174.155 206.89 174.018 207.504C173.343 210.645 174.774 214.773 174.645 218.188C174.516 221.592 173.887 224.631 173.566 227.988C172.555 238.561 173.629 248.91 179.267 258.047C179.964 251.613 182.933 245.714 186.827 240.702C184.816 248.242 182.367 257.535 186.791 264.552C191.273 271.656 193.652 279.428 189.174 287.492C188.146 285.915 187.136 283.443 185.829 281.398C185.425 284.826 184.32 285.663 183.231 288.71C182.966 289.452 183.765 291.343 183.801 292.198C183.854 293.491 183.611 294.822 183.621 296.119C183.586 297.371 183.825 299.935 183.658 301.01C182.958 305.515 181.109 309.407 181.337 314.304C181.621 320.441 185.24 324.427 186.551 330.333C187.496 334.588 187.335 338.725 188.065 342.99C189.044 348.704 190.607 357.103 191.385 362.892C187.809 367.266 190.067 369.48 186.898 373.595C186.01 374.749 183.791 374.681 183.563 376.636L183.839 376.982C184.585 376.775 184.804 375.17 185.943 375.034C186.087 375.972 184.663 377.574 185.541 379.025L186.022 379.113C187.014 378.521 186.692 374.918 188.549 375.106C188.917 376.375 186.736 378.181 188.392 379.767L188.717 379.703C189.703 378.548 189.856 375.341 191.062 374.839C192.024 375.425 190.54 378.999 191.175 379.501C193.998 381.731 192.421 373.959 195.42 375.02C195.747 375.969 194.981 377.298 195.197 378.345C195.485 379.743 197.679 379.617 198.673 379.237C199.761 378.111 199.086 377.253 198.457 376.063L198.699 374.074C196.977 370.74 196.941 369.443 196.517 365.842C196.427 365.073 194.96 363.285 195.445 362.515L196.656 362.708C197.595 361.633 194.847 357.566 194.198 356.244C193.695 355.22 193.297 354.147 193.01 353.04C191.761 348.378 191.256 340.866 191.432 336.043C191.541 333.036 191.78 330.568 191.621 327.557L192.502 329.232C197.239 318.197 191.933 311.804 190.878 301.686C190.064 303.613 189.513 306.09 188.881 308.094C188.391 305.808 188.65 302.075 188.628 299.609L189.13 299.636C189.812 299.16 190.525 297.677 190.954 296.944C192.899 293.621 193.621 290.589 193.501 286.736C192.934 287.337 191.989 288.477 191.255 288.634C191.119 287.91 193.538 282.193 193.531 280.624C193.508 274.942 191.886 267.307 191.979 261.657C192.676 262.823 192.861 263.17 193.34 264.45C194.429 260.736 195.435 256.095 194.937 252.229C193.742 242.952 190.985 241.367 193.838 231.928C192.959 228.342 191.237 227.107 189.386 224.03C188.536 222.617 188.132 221.662 187.52 220.12C190.809 222.968 193.973 225.101 198.233 225.654C198.479 225.614 199.488 226.33 199.477 226.567C199.366 228.633 196.81 235.399 200.467 235.809C203.186 236.114 201.138 228.345 203.542 227.092C204.705 226.484 209.206 223.521 210.464 223.509C210.754 227.058 212.298 228.578 213.971 231.586C217.662 238.223 219.554 247.079 218.111 254.624C216.641 250.504 216.125 248.827 213.74 245.16C211.42 253.752 215.76 256.436 215.012 264.49C214.602 268.912 211.752 274.032 210.547 278.077C209.465 281.706 210.947 284.005 212.614 287.009L212.038 289.206C212.335 290.037 213.043 291.516 213.228 292.253C214.427 297.019 215.231 302.265 213.578 307.015C212.841 309.135 212.045 311.855 211.779 313.997C211.336 317.555 212.097 320.847 212.509 324.361C212.799 322.202 213.566 318.473 214.394 316.501C215.016 322.747 215.615 329.179 214.73 335.453C213.567 343.71 211.647 354.938 211.132 363.306C211.094 363.917 210.019 366.137 209.801 366.93C208.937 370.056 210.316 368.785 212.375 369.052C213.301 369.23 214.266 369.667 215.071 370.101C217.673 371.507 218.414 374.454 220.481 376.339C221.806 377.548 224.214 377.369 225.657 378.444C226.662 379.194 227.94 379.309 229.14 379.11C229.688 379.008 229.829 378.895 230.084 378.504C229.429 376.946 226.556 377.164 225.703 375.627C227.346 373.266 231.718 378.79 232.653 379.228C233.359 379.177 233.075 377.277 233.566 376.837C233.365 375.168 230.216 376.166 229.515 375.298L230.049 375.1C232.05 375.343 233.528 375.602 234.986 376.681L235.541 376.548L235.582 376.2C233.477 372.856 228.802 374.106 226.081 372.17C222.527 369.644 219.809 366.377 216.045 363.753C212.326 349.769 222.45 331.528 222.639 317.82C222.663 316.187 222.567 314.554 222.355 312.933C222.135 311.251 220.458 301.934 219.43 300.859L219.001 301.677L218.834 301.44C218.594 299.395 219.104 294.734 219.017 292.418C219.001 292.016 219.565 290.272 219.532 289.623C219.344 285.826 219.41 281.902 219.973 278.129C220.249 276.288 221.781 272.324 222.472 270.63C227.04 259.445 228.498 246.325 228.005 234.294C227.818 229.706 226.809 224.78 226.681 220.639C226.466 213.777 228.417 212.115 226.169 205.123C225.304 205.852 224.372 206.429 223.429 207.047C229.292 194.296 223.108 196.548 223.198 185.422C223.231 181.472 226.294 176.926 226.382 170.762C225.252 171.808 224.722 172.105 223.422 172.817C224.641 170.56 225.837 168.499 226.486 165.992C226.693 165.192 227.036 164.075 227.645 163.515L227.922 163.654C228.419 165.157 227.973 168.262 227.856 169.953C231.357 162.858 231.63 156.004 231.624 148.348C230.447 150.194 228.478 154.316 228.349 156.461C228.017 161.992 227.585 163.712 222.879 166.703C225.307 162.643 226.308 161.198 226 156.434C224.407 157.871 222.863 159.245 220.625 159.347C219.347 159.405 218.359 159.584 217.563 158.41C217.56 158.222 217.554 158.033 217.55 157.844C218.553 156.46 221.41 155.283 222.765 154.228C226.092 151.642 226.444 148.021 228.912 144.761C230.889 142.184 233.462 140.18 235.644 137.787C239.224 133.857 238.496 130.125 244.23 128.639C245.809 126.506 246.415 125.725 248.423 124.07C241.409 122.1 238.085 122.303 231.733 125.793C231.203 126.084 229.314 126.483 228.608 126.687C225.371 127.621 222.953 128.267 220.805 131.065C221.847 132.554 222.817 133.349 224.168 134.526C221.926 134.001 219.525 133.504 217.418 132.584L216.591 131.035C212.432 131.015 209.854 130.885 205.787 130.074C211.007 128.37 215.577 129.309 220.668 128.586L222.533 126.657C218.962 124.907 215.746 123.933 212.056 121.878L212.777 125.597C210.369 122.817 210.29 118.437 210.274 114.868C210.263 112.5 210.29 110.119 210.307 107.75C208.926 109.491 206.782 111.685 204.89 112.847C203.451 113.731 200.285 114.14 199.233 115.487C198.96 116.666 199.832 119.998 200.393 121.104C197.504 125.758 195.647 118.088 194.149 117.33L193.878 117.638C193.841 121.401 195.897 127.08 196.794 130.956L196.869 131.292C192.316 129.337 187.654 130.329 182.087 128.605C181.914 128.243 181.994 128.447 181.852 127.984C180.436 126.97 178.311 125.945 176.731 125.12C179.595 123.612 182.704 122.29 185.676 121.015C185.152 120.581 185.021 118.455 184.596 117.89C184.511 116.775 184.502 115.177 183.099 115.202C182.242 115.684 181.908 116.28 181.566 117.186C181.745 118.02 182.584 119.923 183.21 120.932L182.921 121.168C181.257 121.399 179.592 118.651 178.661 117.149C177.315 114.977 179.23 114.203 179.636 112.55C179.008 111.707 178.556 111.587 177.525 111.705C176.009 111.877 173.985 111.077 173.278 109.575C172.041 106.946 175.057 104.948 175.509 103.642C175.107 103.393 174.841 103.273 174.552 102.889C175.289 101.623 173.619 101.584 174.209 99.865C174.349 99.4577 174.403 99.1882 174.454 98.7564L174.208 98.5846C172.018 99.0143 172.781 100.82 172.929 102.19L172.707 102.281C172.483 102.162 172.3 102.037 172.124 101.851C171.325 101.008 170.99 99.9218 171.038 98.7576C171.271 93.0903 176.313 94.8241 177.523 93.4069C177.795 93.087 177.958 92.5122 177.866 92.0957C177.803 91.8136 176.218 91.4572 175.853 91.215C175.763 91.1552 175.677 91.0896 175.587 91.0294C175.495 90.968 175.401 90.9102 175.308 90.8498L175.111 90.7185L174.888 90.926C174.765 91.6308 175.056 92.3481 175.258 93.0544L175.127 93.2432C173.193 92.2145 172.645 89.4426 172.934 87.3791C173.194 85.5192 175.416 83.9732 177.274 84.6122L177.346 84.8193C176.647 85.1783 176.159 85.3552 175.645 85.9455C175.475 86.5978 175.445 86.2995 175.669 86.8757C176.798 87.8779 179.075 87.7007 179.412 85.9557C179.521 85.3915 178.886 84.6543 178.557 84.197C179.228 83.4207 180.556 81.38 180.982 80.4477C179.026 80.0438 178.848 81.9155 178.43 83.0605C177.396 81.8395 177.426 80.643 178.619 79.4788C180.249 77.8877 181.183 77.8512 183.286 77.8969L183.357 77.7257C184.979 73.8151 185.996 72.4393 190.011 70.7326ZM169.847 232.38C167.549 235.326 165.638 238.88 164.991 242.588C163.858 249.075 164.648 253.733 160.35 259.356C157.064 263.655 153.532 264.177 149.805 268.038C155.166 269.497 151.513 276.415 149.573 276.857C142.09 278.558 141.348 283.573 135.838 289.016C135.919 283.862 136.958 281.246 139.198 276.654C137.369 278.53 135.272 280.101 133.677 282.148C129.995 286.877 130.392 292.381 129.791 297.989C129.045 304.949 124.514 310.534 120.861 316.125C118.567 319.646 116.608 323.655 114.238 327.144C113.61 328.1 111.865 329.066 111.203 330.023C111.276 330.448 111.422 330.92 111.086 331.265C109.959 332.427 108.371 333.107 107.051 334.248C105.118 335.919 103.094 339.026 101.186 340.394C97.4514 343.073 96.1424 341.842 93.0062 346.011C94.2691 345.409 95.7636 344.533 96.9799 344.073L97.2109 344.199C96.6167 346.148 92.8026 348.146 92.8757 349.992C93.9974 350.071 94.4297 349.328 95.145 348.543C96.2054 347.672 97.5609 346.36 98.8882 346.138L99.0672 346.326C98.6827 347.898 96.746 349.424 95.7659 350.862L96.9223 352.2C98.9238 350.268 100.229 348.755 102.874 347.781C102.703 348.542 102.495 349.574 102.155 350.206C101.041 352.275 96.1444 354.234 100.554 356.19C101.967 356.818 106.646 349.83 107.161 348.787C108.728 345.612 110.22 342.229 111.981 339.126C112.702 337.855 113.609 334.417 114.672 333.801C115.434 333.963 115.967 334.387 116.679 334.203C118.341 333.019 117.942 330.066 118.424 328.286C120.611 320.219 126.252 315.052 131.848 309.455C133.951 307.352 136.334 302.506 138.295 300.083C141.224 296.036 143.566 292.92 145.745 288.324C144.637 288.787 143.462 289.3 142.34 289.702C144.178 286.576 146.163 284.74 148.562 282.133C149.225 281.411 150.957 278.626 151.566 278.27C153.443 277.175 155.867 276.111 157.787 275.03C162.473 272.252 167.772 264.833 168.664 259.431C169.185 256.279 168.333 250.353 168.33 246.861C168.327 243.338 170.582 235.119 169.847 232.38ZM230.007 216.927C229.886 218.661 229.301 222.559 229.45 224.099C230.033 230.208 230.622 235.598 230.459 241.773C232.199 244.927 233.351 247.18 234.227 250.795C235.793 257.262 235.439 262.409 239.075 268.267C242.327 273.5 247.762 273.177 247.955 279.846L247.967 280.203C249.455 282.827 250.964 283.186 253.456 284.547C251.244 281.742 250.601 280.436 250.67 276.769C256.661 280.996 261.512 284.018 263.921 291.461C264.778 294.102 265.518 296.903 266.965 299.258C269.336 303.113 273.092 305.624 275.294 309.695C276.649 312.203 277.735 314.744 278.861 317.36L283.363 327.681C284.523 330.404 284.831 331.491 286.495 333.992C287.432 335.402 287.901 339.332 289.46 340.954C291.571 344.279 292.722 348.208 295.178 351.328C295.741 352.043 296.399 354.576 297.263 354.484C297.66 353.945 297.772 353.796 298.339 353.458L298.631 353.501C298.702 354.488 298.709 354.961 299.23 355.815C299.8 356.175 299.502 356.117 300.155 356.01C300.822 355.493 300.839 355.429 301.29 354.685C301.282 354.08 301.227 353.732 300.705 353.29C297.802 350.838 297.928 351.713 296.92 347.781C301.436 349.894 301.786 352.108 304.288 353.572C306.46 350.905 299.652 348.409 300.567 346.278C302.148 345.624 305.089 350.257 306.727 350.168C307.973 348.8 302.617 346.024 302.452 344.372C303.576 343.242 305.619 346.105 307.508 346.011L307.704 345.785C307.482 343.731 303.466 340.618 301.805 339.596C298.737 337.707 296.102 335.316 293.177 333.237C291.987 332.453 289.559 331.936 288.816 330.699C284.474 323.467 281.12 314.922 279.029 306.727C276.882 298.309 275.125 291.441 268.163 285.659C266.848 284.567 266.028 283.212 264.225 283.047C261.7 280.83 261.24 276.851 259.038 274.4C257.895 273.13 255.917 272.66 255.117 270.961C253.868 268.307 253.696 265.23 252.746 262.493C252.728 263.997 252.849 266.002 252.214 267.309L251.974 267.376C250.008 263.516 249.717 262.311 245.895 259.935C242.499 257.824 239.492 254.458 238.155 250.622C235.626 244.301 236.952 238.153 236.407 231.612C236.116 228.125 232.65 218.891 230.007 216.927ZM207.074 287.444C206.918 290.53 206.688 292.902 208.918 295.399C209.171 295.677 209.434 295.949 209.701 296.212L209.916 296.113C209.27 293.564 209.348 292.615 209.769 290.025C208.242 289.279 208.014 288.318 207.074 287.444ZM214.985 206.233C215.042 206.407 215.135 206.682 215.133 206.868C215.084 213.968 211.202 222.12 204.102 224.172C202.928 224.51 202.011 224.55 200.781 224.608C201.026 224.127 202.326 223.51 202.86 223.168C209.227 219.063 211.966 213.045 214.985 206.233ZM178.162 169.733C178.87 171.692 181.346 177.035 182.472 178.72L182.616 178.611L182.647 177.071C183.08 174.944 183.316 174.338 184.373 172.451C181.318 171.952 180.662 171.561 178.162 169.733ZM168.595 147.142C171.145 153.299 170.586 154.521 171.905 160.719C171.999 159.204 172.043 156.551 172.674 155.274L172.906 155.185C173.849 156.132 174.171 156.481 175.285 157.222L175.452 157.147C174.931 156.102 173.866 154.858 173.161 153.847C171.964 152.13 170.209 148.263 168.595 147.142ZM270.801 131.769C266.112 130.817 257.895 129.123 253.141 129.805C247.923 130.283 245.034 131.236 241.653 135.39C241.341 135.775 241.033 136.163 240.727 136.554C246.43 134.834 251.434 133.101 257.449 134.525C255.595 135.826 254.376 136.715 252.703 138.287C257.486 139.686 259.305 138.324 264.038 137.181C268.433 136.119 272.147 136.449 276.362 138.024C279.001 139.01 279.302 139.668 281.288 140.722C286.144 142.637 287.083 140.156 290.095 136.973C292.654 134.27 296.279 133.713 299.651 132.795C294.889 131.306 289.421 130.275 284.647 131.959C278.928 133.978 276.403 132.908 270.801 131.769ZM152.385 129.046C152.368 129.04 152.352 129.034 152.336 129.028C152.346 129.025 152.355 129.021 152.365 129.018C152.372 129.028 152.378 129.037 152.385 129.046ZM120.746 111.973C122.231 110.712 126.546 111.147 128.367 111.362C136.852 112.368 143.5 116.254 150.492 120.918C159.806 119.831 167.275 119.332 175.511 125.459C170.76 126.37 168.721 126.586 164.365 124.195C160.204 121.91 155.87 122.931 151.506 124.064C153.063 125.379 153.831 126.319 154.961 128.021C154.047 128.443 153.252 128.723 152.365 129.018C151.018 127.057 149.135 124.735 147.186 123.379C145.025 121.953 142.343 121.7 140.093 120.324C135.219 117.345 131.491 113.156 125.536 112.45C124.649 112.345 121.275 112.344 120.746 111.973ZM189.502 112.039C189.435 113.075 188.994 120.173 189.309 120.85C189.7 119.094 189.832 113.757 189.502 112.039ZM193.894 117.508L194.038 117.284C194.029 117.281 194.021 117.277 194.011 117.274L193.894 117.508ZM176.011 107.3C174.148 109.083 175.124 110.112 177.047 110.989C177.958 109.495 177.51 108.143 176.011 107.3ZM190.87 107.516C191.909 108.762 194.03 110.431 195.543 110.811C194.538 109.966 192.066 107.951 190.87 107.516ZM184.814 97.0717C185.385 98.5167 186.537 101.262 188.186 101.569L188.419 101.348C188.612 100.304 188.198 99.2113 187.849 98.2327L187.511 99.1794C186.136 99.0976 185.623 98.0943 184.814 97.0717ZM214.366 97.429C214.054 98.0593 213.926 98.4521 213.392 98.9036C212.908 98.987 212.798 98.9958 212.307 98.9971C211.661 99.6436 211.687 100.129 211.41 101.117C211.914 101.196 212.388 101.375 212.842 101.028C213.667 100.4 214.404 98.4272 214.366 97.429ZM190.595 93.7813C190.446 94.7809 190.322 95.3241 190.977 96.1663C191.904 97.3557 192.904 98.472 193.956 99.5418C194.45 99.2437 194.68 98.7833 195.01 98.2884C195.551 96.2048 194.519 96.4358 196.008 94.2382C193.528 94.7408 192.936 94.8713 190.595 93.7813ZM187.164 96.122C187.073 97.373 187.284 97.9551 187.511 99.1794L187.849 98.2327C187.693 97.5953 187.538 96.5496 187.164 96.122ZM215.867 84.9632C214.932 85.2966 214.178 85.2988 213.205 85.3541C214.169 86.0796 215.33 86.3168 216.021 87.0901L215.831 87.3761C215.073 87.4578 214.446 86.9268 213.571 86.6557C213.025 88.353 215.814 88.7873 216.901 88.9283L216.111 91.3202C216.716 91.9127 217.721 93.0922 218.425 93.2001C218.589 92.6314 218.53 92.7034 218.477 92.0783C221.101 92.8929 221.899 93.075 224.578 93.4165C222.139 91.8758 220.903 92.5583 218.589 90.6862C218.856 88.7879 218.631 88.7609 219.927 87.5227C219.443 86.9435 218.666 87.2018 218.152 86.9873C217.687 86.7925 216.329 85.0362 215.867 84.9632ZM345.832 70.3161C346.84 70.2723 346.877 70.2524 347.473 71.0967C347.693 73.3101 342.7 74.7519 340.978 75.4176C339.558 78.111 337.451 77.8604 334.864 77.4843C333.626 78.1241 331.6 79.129 330.632 80.0968C328.409 82.3168 327.641 83.6802 324.982 85.5176L323.46 86.3177C326.029 82.1595 328.748 77.0818 334.094 77.0412C338.17 72.8067 340.563 72.8242 345.832 70.3161ZM52.9505 70.2753C54.4011 70.2821 61.9258 73.6597 63.1652 74.6212C65.8808 76.7276 63.7782 76.7577 67.6906 77.04C70.3526 77.2324 74.8185 83.1683 76.0337 85.7527L75.808 85.9322C72.7662 84.4731 71.6194 82.3571 69.2637 80.1388C68.0527 78.9983 66.2165 78.0411 64.7451 77.225C62.241 78.2677 59.9368 77.8022 58.5586 75.3163C56.5584 74.3581 50.9642 73.2061 52.9505 70.2753Z" fill="#030303"/>
+</g>
+<defs>
+<linearGradient id="paint0_linear_6337_1342" x1="200" y1="0" x2="200" y2="400" gradientUnits="userSpaceOnUse">
+<stop stop-color="#56FF40"/>
+<stop offset="1" stop-color="#39DE24"/>
+</linearGradient>
+<clipPath id="clip0_6337_1342">
+<rect width="400" height="400" rx="60" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 84962a982..69cb55118 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 9d703680b..a64ba7019 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 7164ecc54..ff7b43ce9 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index e383d2741..da93f88f9 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 719ab0cdb..6f788824d 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 594edd472..5d203601c 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index d64b7d6e2..509c9f1b0 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 7164ecc54..ff7b43ce9 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index e128ab7a1..7972e8dc9 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 62cdf6344..18d9ecd11 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 62cdf6344..18d9ecd11 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index af54389a5..caf147b0b 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 1a9cbfae4..da87eb3e7 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 55123a33a..bc871da11 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
index 5137af6e4..1253a2770 100644
Binary files a/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] and b/mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected] differ
diff --git a/mobile/lib/core/models.dart b/mobile/lib/core/models.dart
index e8b94943b..dd811e2b9 100644
--- a/mobile/lib/core/models.dart
+++ b/mobile/lib/core/models.dart
@@ -267,6 +267,15 @@ class Agent {
terminalUnavailableReason: terminalUnavailableReason,
);
+ /// Saved work the daemon is no longer running, as the desktop's [Agent] reads
+ /// it. Its conversation is on disk; `agent_restart` brings it back.
+ ///
+ /// ⚠️ **Only ever set on a machine the app asked `includeStopped: true` of.**
+ /// The daemon's plain `agents_list` answers with `registry.advertised()` —
+ /// live agents only — so a client that does not ask sees a fleet with its
+ /// stopped work silently missing, which is exactly what this app did.
+ bool get isStopped => status == 'stopped';
+
static String? _safeEngine(Object? raw) {
if (raw is! String || raw.isEmpty || raw.length > 64) return null;
return RegExp(r'^[a-zA-Z0-9._-]+$').hasMatch(raw) ? raw : null;
diff --git a/mobile/lib/core/phone_search_history.dart b/mobile/lib/core/phone_search_history.dart
new file mode 100644
index 000000000..7a0fc1a91
--- /dev/null
+++ b/mobile/lib/core/phone_search_history.dart
@@ -0,0 +1,106 @@
+import 'dart:async';
+import 'dart:convert';
+
+import 'local_key_value_store.dart';
+
+/// The agents and commands reached from the search, most recent first.
+///
+/// The phone's half of the desktop's `SwarmNavigationHistory`: the part that
+/// ranks. A search earns its keep in the first three rows, before a word is
+/// typed, and without this the box opens on whichever agent a daemon happened to
+/// stamp last — the one from an hour ago no nearer than one from last month.
+///
+/// ⚠️ **Only ids are kept**, never a name, a path or a line of terminal. They
+/// outlive a restart and mean nothing to anything that cannot already read the
+/// account's agent list.
+class PhoneSearchHistory {
+ PhoneSearchHistory(this._storage);
+
+ final LocalKeyValueStore? _storage;
+ static const _agentsKey = 'phone_recent_agents_v1';
+ static const _commandsKey = 'phone_recent_commands_v1';
+
+ /// Long enough to cover the agents anyone switches between, short enough that
+ /// the whole list stays one small write.
+ static const _kept = 32;
+
+ final _agents = <String>[];
+ final _commands = <String>[];
+ Timer? _saving;
+ bool _disposed = false;
+ Future<void>? _loading;
+
+ /// Agent ids ([phoneAgentId]) most recent first.
+ List<String> get recent => List.unmodifiable(_agents);
+
+ /// Command ids most recent first: with nothing typed, `>` opens on these.
+ List<String> get recentCommands => List.unmodifiable(_commands);
+
+ /// Folds what the last run remembered in BEHIND what this one has already
+ /// visited, so a read that lands late cannot reorder the present.
+ ///
+ /// Idempotent and shared: every opening of the box asks, and they all wait on
+ /// the one read rather than racing each other for the state file's lock.
+ Future<void> load() => _loading ??= _load();
+
+ Future<void> _load() async {
+ await _read(_agentsKey, _agents, prefix: 'agent:');
+ await _read(_commandsKey, _commands);
+ }
+
+ Future<void> _read(
+ String key,
+ List<String> into, {
+ String? prefix,
+ }) async {
+ try {
+ final raw = await _storage?.read(key);
+ if (raw == null || _disposed) return;
+ final ids = jsonDecode(raw);
+ if (ids is! List) return;
+ for (final id in ids.take(_kept)) {
+ if (id is! String || into.contains(id)) continue;
+ if (prefix != null && !id.startsWith(prefix)) continue;
+ into.add(id);
+ }
+ } catch (_) {
+ // A damaged list is an empty one; the next visit writes a good one.
+ }
+ }
+
+ void remember(String id) => _touch(_agents, id);
+
+ void rememberCommand(String id) => _touch(_commands, id);
+
+ void _touch(List<String> list, String id) {
+ if (list.firstOrNull == id) return;
+ list
+ ..remove(id)
+ ..insert(0, id);
+ if (list.length > _kept) list.removeLast();
+ _save();
+ }
+
+ void _save() {
+ if (_storage == null || _disposed) return;
+ // Agents are opened in bursts; one write after it settles is enough.
+ _saving?.cancel();
+ _saving = Timer(const Duration(milliseconds: 600), () {
+ unawaited(_write(_agentsKey, _agents));
+ unawaited(_write(_commandsKey, _commands));
+ });
+ }
+
+ Future<void> _write(String key, List<String> ids) async {
+ try {
+ await _storage?.write(key, jsonEncode(ids));
+ } catch (_) {
+ // Losing the order only costs the next search its head start.
+ }
+ }
+
+ void dispose() {
+ _disposed = true;
+ _saving?.cancel();
+ }
+}
diff --git a/mobile/lib/phone/agent_index.dart b/mobile/lib/phone/agent_index.dart
index 7c1c3d50f..4345a4c9a 100644
--- a/mobile/lib/phone/agent_index.dart
+++ b/mobile/lib/phone/agent_index.dart
@@ -28,6 +28,15 @@ class AgentEntry {
bool get isWorking => machine.processingAgentIds.contains(agent.id);
+ /// Whether a tap can land on this agent — it has a terminal, or it is saved
+ /// work a resume can bring back ([AppNotifier.resumeAgent]).
+ ///
+ /// ⚠️ **Not `terminalAvailable` alone.** A stopped agent has no terminal and
+ /// never will until something restarts it, so the bare flag sorted every one
+ /// of them to the bottom of every list and made them untappable — which,
+ /// before the app asked for them at all, was invisible. It is visible now.
+ bool get isOpenable => agent.terminalAvailable || agent.isStopped;
+
/// When its conversation last moved: the machine's own [Agent.updatedAt], or
/// a turn this app saw since ([MachineState.agentActivityAt]) — whichever is
/// later. Null when neither is known.
@@ -82,8 +91,8 @@ List<AgentEntry> otherAgents(List<AgentEntry> entries) =>
entries.where((entry) => !entry.isWaiting),
(a, b) =>
_firstWhere(a.isWorking, b.isWorking) ??
- // Then agents that can actually be opened, so a row with no terminal never heads the list.
- _firstWhere(a.agent.terminalAvailable, b.agent.terminalAvailable) ??
+ // Then agents that can actually be opened, so a row a tap cannot land on never heads the list.
+ _firstWhere(a.isOpenable, b.isOpenable) ??
0,
);
@@ -99,7 +108,7 @@ List<AgentEntry> recentAgents(List<AgentEntry> entries) => _stableSorted(
(a, b) =>
_firstWhere(a.isWaiting, b.isWaiting) ??
_firstWhere(a.isWorking, b.isWorking) ??
- _firstWhere(a.agent.terminalAvailable, b.agent.terminalAvailable) ??
+ _firstWhere(a.isOpenable, b.isOpenable) ??
_newestFirst(a.lastActiveAt, b.lastActiveAt),
);
diff --git a/mobile/lib/phone/agent_swipe.dart b/mobile/lib/phone/agent_swipe.dart
index 781163a71..89f832923 100644
--- a/mobile/lib/phone/agent_swipe.dart
+++ b/mobile/lib/phone/agent_swipe.dart
@@ -10,6 +10,7 @@ import 'package:harness_mobile/terminal/terminal_session.dart'
show TerminalSessionStatus;
import 'agent_pane_prune.dart';
+import 'phone_search_catalog.dart' show phoneAgentId;
import 'agent_swipe_list.dart';
import 'terminal_page.dart';
import 'voice_input_controller.dart';
@@ -167,6 +168,19 @@ class _AgentSwipeHostState extends State<AgentSwipeHost> {
widget.notifier.api.transcribeVoice(wav, lang: lang),
);
+ /// Tell the search this agent was reached.
+ ///
+ /// ⚠️ **Landing on an agent is the event, not searching for one.** The desktop
+ /// records every pane it focuses, however you got there, and ranks its box off
+ /// that — so within a day its list is "the agents you actually work in". The
+ /// phone's first port only recorded agents opened THROUGH the search, which
+ /// meant the history stayed nearly empty no matter how much the app was used,
+ /// and the box kept falling through to its last-resort ordering. A swipe
+ /// between agents is this app's focus change; this is where it belongs.
+ void _rememberVisit(AgentRef agent) => widget.notifier.searchHistory.remember(
+ phoneAgentId(agent.machineId, agent.agentId),
+ );
+
@override
void initState() {
super.initState();
@@ -178,6 +192,7 @@ class _AgentSwipeHostState extends State<AgentSwipeHost> {
_attached.add(_current);
// What a relaunch reopens — kept up to date on every swipe, and cleared only by leaving.
widget.notifier.lastOpenedAgent.remember(_current);
+ _rememberVisit(_current);
final neighbours = widget.neighbours;
if (neighbours == null || neighbours.isEmpty) return;
// The snapshot is fixed for as long as this pager lives, so the opening page is the only index
@@ -359,6 +374,7 @@ class _AgentSwipeHostState extends State<AgentSwipeHost> {
// and finds none.
_attached.add(arrived);
widget.notifier.lastOpenedAgent.remember(arrived);
+ _rememberVisit(arrived);
// ⚠️ A second dismissal, and not a redundant one. The [ScrollStartNotification] above catches
// the finger, which is the usual way here and the one that matters for how it looks — but a page
// reached any other way never raised that notification, and the incoming terminal would claim
diff --git a/mobile/lib/phone/agents_list_page.dart b/mobile/lib/phone/agents_list_page.dart
index a0fd5d962..5791300d7 100644
--- a/mobile/lib/phone/agents_list_page.dart
+++ b/mobile/lib/phone/agents_list_page.dart
@@ -8,11 +8,14 @@ import 'package:harness_mobile/state/app_state.dart';
import 'agent_index.dart';
import 'phone_header.dart';
import 'phone_navigation.dart';
+import 'phone_destination.dart';
+import 'phone_search_catalog.dart';
import 'phone_search_field.dart';
import 'phone_search_groups.dart';
-import 'phone_search_index.dart';
import 'phone_search_rank.dart';
+import 'phone_search_results.dart';
import 'phone_search_row.dart';
+import 'resume_agent.dart';
import 'phone_status.dart';
import 'status_pill.dart';
@@ -51,6 +54,11 @@ class _AgentsListPageState extends State<AgentsListPage> {
final _focus = FocusNode(debugLabel: 'Agents list search');
String _query = '';
+ /// This screen rebuilds on every turn event — it watches the notifier AND the
+ /// preview store — so the catalog behind it must not be re-derived each time.
+ /// See [PhoneSearchCatalogCache].
+ final _catalog = PhoneSearchCatalogCache();
+
@override
void initState() {
super.initState();
@@ -77,7 +85,13 @@ class _AgentsListPageState extends State<AgentsListPage> {
listenable: _changes,
builder: (context, _) {
AppTheme.watch(context);
- final all = phoneSearchIndex(widget.notifier);
+ // Agents only: this screen groups by machine and has a Machines tab of
+ // its own, so the catalog's machine and project rows would be two ways to
+ // the same place stacked on one screen.
+ final all = [
+ for (final row in _catalog.read(widget.notifier))
+ if (row.isAgent) row,
+ ];
return Scaffold(
backgroundColor: AppPalette.windowBg,
// The keyboard only comes up if the field is tapped, but when it does the list must shrink
@@ -102,6 +116,9 @@ class _AgentsListPageState extends State<AgentsListPage> {
controller: _controller,
focus: _focus,
autofocus: false,
+ // This field filters the list below it; it is not the door to
+ // the modes, which [PhoneSearchPage] carries.
+ hintText: 'Search agents',
onChanged: (value) => setState(() => _query = value),
onClear: () {
_controller.clear();
@@ -126,7 +143,7 @@ class _AgentsListPageState extends State<AgentsListPage> {
);
}
-class _Body extends StatelessWidget {
+class _Body extends StatefulWidget {
const _Body({
required this.notifier,
required this.all,
@@ -138,18 +155,38 @@ class _Body extends StatelessWidget {
/// Every agent, most recently active first — see [recentAgents] for why recency and not the
/// tabs' fixed order: this screen is opened to REACH one agent, and the one reached for is
/// overwhelmingly the one that just finished.
- final List<PhoneSearchResult> all;
+ final List<PhoneDestination> all;
/// Trimmed; empty means the whole list.
final String query;
+ @override
+ State<_Body> createState() => _BodyState();
+}
+
+class _BodyState extends State<_Body> {
+ /// The row whose agent is being brought back — see [_open]. One at a time, so
+ /// a second tap cannot start a second restart.
+ String? _resuming;
+
+ AppNotifier get notifier => widget.notifier;
+
@override
Widget build(BuildContext context) {
+ final all = widget.all;
+ final query = widget.query;
if (all.isEmpty) return _empty();
// The same ranking [PhoneSearchPage] applies, so an agent found by a word here is the agent
// that word finds there. Grouping happens after: ranking decides the order the rows arrive in,
// and [phoneMachineGroups] preserves it — so the best match still heads the first group.
- final rows = query.isEmpty ? all : rankPhoneSearch(all, query);
+ final rows = query.isEmpty
+ ? all
+ : rankPhoneDestinations(
+ all,
+ query,
+ recent: notifier.searchHistory.recent,
+ previews: notifier.sessionPreviews,
+ );
if (rows.isEmpty) {
return EmptyState.noMatches(
compact: false,
@@ -180,10 +217,10 @@ class _Body extends StatelessWidget {
row: row,
terms: terms,
now: now,
- // The header above named the machine and nothing else, so the row still owes the
- // folder — and must not repeat the machine.
- place: PhoneRowContext.machined,
- onTap: () => _open(context, drawn, row),
+ openable: (row.entry?.isOpenable ?? false) && _resuming == null,
+ resuming: _resuming == row.id,
+ quote: phoneContentSnippet(row, terms, notifier.sessionPreviews),
+ onTap: () => _open(drawn, row),
),
],
],
@@ -204,18 +241,34 @@ class _Body extends StatelessWidget {
'Start one from a machine, or from Harness on it.',
);
- /// Opens the agent as a pager over the other rows on screen.
- void _open(
- BuildContext context,
- List<PhoneSearchResult> drawn,
- PhoneSearchResult row,
- ) {
+ /// Opens the agent as a pager over the other rows on screen, resuming stopped
+ /// work first — the same [resumeAgentForOpen] the search uses, so tapping the
+ /// same agent on either screen does the same thing.
+ Future<void> _open(
+ List<PhoneDestination> drawn,
+ PhoneDestination row,
+ ) async {
// The keyboard goes away with the screen rather than a frame after it, so the push does not
// animate over a collapsing inset. [PhoneSearchRow] does this for its own tap; a row opened
// by any other path still has to.
FocusManager.instance.primaryFocus?.unfocus();
final entry = row.entry;
- if (entry == null || !entry.agent.terminalAvailable) return;
+ if (entry == null) return;
+ if (entry.agent.isStopped) {
+ setState(() => _resuming = row.id);
+ final error = await resumeAgentForOpen(notifier, entry);
+ if (!mounted) return;
+ setState(() => _resuming = null);
+ if (error != null) {
+ ScaffoldMessenger.maybeOf(
+ context,
+ )?.showSnackBar(SnackBar(content: Text(error)));
+ return;
+ }
+ } else if (!entry.agent.terminalAvailable) {
+ return;
+ }
+ if (!mounted) return;
openAgentPager(context, notifier, phoneSearchAgentEntries(drawn), entry);
}
}
@@ -248,7 +301,7 @@ class _MachineHeader extends StatelessWidget {
// ⚠️ [Flexible] and no [Spacer]. Both take what is left over, so the two together split
// it — a long machine name would give up half its width to blank space instead of
// running on and ellipsing. The count is pushed right by this being the only flexible
- // child, the way [PhoneSearchFolderHeader] does it.
+ // child.
Flexible(
child: Text(
group.machineName.toUpperCase(),
diff --git a/mobile/lib/phone/phone_destination.dart b/mobile/lib/phone/phone_destination.dart
new file mode 100644
index 000000000..32ed84e1a
--- /dev/null
+++ b/mobile/lib/phone/phone_destination.dart
@@ -0,0 +1,148 @@
+import 'package:harness_mobile/state/app_state.dart';
+import 'package:harness_mobile/state/session_preview.dart';
+
+import 'agent_index.dart';
+import 'phone_prompt_context.dart';
+
+/// What one row is, and so what a tap on it does.
+///
+/// The desktop distinguishes the same five kinds inside one `SwarmDestination`,
+/// through `isProject` / `isMachine` / `isCommand` / `pickerQuery` getters
+/// rather than a field. Named here because the phone draws each kind with a
+/// different mark and opens each one differently, and a chain of getters at
+/// every one of those call sites is how the two drifted apart the first time.
+enum PhoneDestinationKind {
+ /// A harness. The only kind that opens a terminal.
+ agent,
+
+ /// A machine, as `@` lists them. Tapping it scopes the search to its agents.
+ machine,
+
+ /// A repository or folder, as `#` lists them. Tapping it scopes the search
+ /// to its agents.
+ project,
+
+ /// Something the app does, as `>` lists them.
+ command,
+
+ /// A `?` row: it rewrites the query in place instead of opening anything.
+ mode,
+}
+
+/// One row the search can offer, whichever of the catalogs it came from.
+///
+/// This is the phone's `SwarmDestination`, ported field for field from
+/// `desktop/lib/state/swarm_navigation.dart` so both apps rank the same rows on
+/// the same strings. [fields] and [titleFieldCount] in particular are the whole
+/// ranking contract: see `rankPhoneDestinations`.
+///
+/// ⚠️ **[fields] keeps empty strings.** Only nulls are dropped. [titleFieldCount]
+/// counts positions from the front, so filtering a blank title out would shift
+/// every metadata field into a title slot and rank a folder like a name.
+class PhoneDestination {
+ PhoneDestination({
+ required this.id,
+ required this.kind,
+ required this.title,
+ required this.detail,
+ this.detailBranchOffset,
+ this.promptContext,
+ this.machineId,
+ this.machineLabel = '',
+ this.agentId,
+ this.engine,
+ this.commandId,
+ this.pickerQuery,
+ this.shortcut,
+ this.projectId,
+ this.previewKey,
+ this.members = const {},
+ this.entry,
+ this.machine,
+ Iterable<String?> searchFields = const [],
+ int titleFields = 1,
+ }) : fields = [
+ title.toLowerCase(),
+ ...searchFields.whereType<String>().map((s) => s.toLowerCase()),
+ ],
+ titleFieldCount = titleFields;
+
+ final String id;
+ final PhoneDestinationKind kind;
+
+ /// The name, as the row draws it and as the query matches it first.
+ final String title;
+
+ /// The metadata line: harness · project · branch · machine, or a kind and a
+ /// count for a group.
+ final String detail;
+
+ /// Where the branch starts inside [detail], so a plain-text rendering can set
+ /// its glyph there without the searchable text or the match offsets moving.
+ final int? detailBranchOffset;
+
+ /// The same facts as [detail], but as the identity the row actually DRAWS:
+ /// engine, machine, project, branch, each its own segment with its own glyph
+ /// and colour. See [PhonePromptContextView].
+ ///
+ /// ⚠️ **Supplied by the catalog, never parsed back out of [detail].** That is
+ /// the desktop's rule ("identity supplied by the catalog, never inferred by
+ /// parsing display text"), and it is what keeps a machine called `work · 2`
+ /// from being split down its separator into two segments.
+ ///
+ /// Null on every kind but an agent — a project row's "Project · 3 harnesses"
+ /// is a count, not a place, and falls back to [detail] as plain text.
+ final PhonePromptContext? promptContext;
+
+ final String? machineId, agentId, engine;
+ final String machineLabel;
+
+ /// Set on [PhoneDestinationKind.command] — what running it asks the app for.
+ final String? commandId;
+
+ /// Set on [PhoneDestinationKind.mode] — the text a tap puts in the field, so
+ /// `?` teaches the other modes by taking you into one.
+ final String? pickerQuery;
+
+ /// The key that reaches this row directly on the desktop. Drawn faint on the
+ /// `?` rows, because somebody searching on the phone is usually somebody who
+ /// will be back at the keyboard later.
+ final String? shortcut;
+
+ final String? projectId;
+
+ /// What was last asked of this agent and what it answered, for the content
+ /// fallback. Null for every kind but [PhoneDestinationKind.agent].
+ final SessionPreviewKey? previewKey;
+
+ /// The agent rows this group holds, by [id]. Empty for an agent.
+ final Set<String> members;
+
+ /// Set on [PhoneDestinationKind.agent] — what a tap opens.
+ final AgentEntry? entry;
+
+ /// Set on [PhoneDestinationKind.machine].
+ final MachineState? machine;
+
+ /// Every searchable string, lowercased, names first.
+ ///
+ /// Not all of it is drawn — an engine id, a project path — which is why
+ /// `SearchResultText` re-checks that a matched field is present in the text it
+ /// is about to embolden rather than trusting the match alone.
+ final List<String> fields;
+
+ /// How many leading [fields] are "the name of the thing" rather than
+ /// metadata: the row's title, plus the agent's own title when it has one. A
+ /// match there outranks any match in a folder, a machine or a recap.
+ final int titleFieldCount;
+
+ bool get isAgent => kind == PhoneDestinationKind.agent;
+ bool get isProject => kind == PhoneDestinationKind.project;
+ bool get isMachine => kind == PhoneDestinationKind.machine;
+ bool get isCommand => kind == PhoneDestinationKind.command;
+ bool get isMode => kind == PhoneDestinationKind.mode;
+
+ /// Whether tapping it narrows the search to the agents inside it rather than
+ /// opening anything — a project or a machine.
+ bool get isGroup => isProject || isMachine;
+}
diff --git a/mobile/lib/phone/phone_prompt_context.dart b/mobile/lib/phone/phone_prompt_context.dart
new file mode 100644
index 000000000..46ca50a27
--- /dev/null
+++ b/mobile/lib/phone/phone_prompt_context.dart
@@ -0,0 +1,194 @@
+import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/terminal/terminal_font_store.dart';
+
+import 'search_result_text.dart';
+
+/// What goes in front of the harness on the identity line. The desktop's
+/// `kHarnessPromptMarker`.
+const kHarnessPromptMarker = '>_';
+
+/// The terminal's own typeface, for the text that names a terminal.
+///
+/// The desktop's `boxMonoStyle`. The picker's rows are set in it there, and that
+/// is not decoration: an agent's name is as often an id as a sentence
+/// (`codex-2026-09-21-16-49`), and a proportional face makes two of those hard
+/// to tell apart at a glance. Reads off [terminalFontStore], so changing the
+/// terminal font changes these rows with it.
+TextStyle phoneBoxMonoStyle({
+ double size = 13,
+ Color? color,
+ FontWeight? weight,
+}) => TextStyle(
+ fontFamily: terminalFontStore.value.fontFamily,
+ fontFamilyFallback: terminalFontStore.value.fontFamilyFallback,
+ fontSize: size,
+ height: 1.35,
+ color: color ?? AppPalette.textPrimary,
+ fontWeight: weight ?? FontWeight.w400,
+);
+
+/// Identity supplied by the catalog, never inferred by parsing display text.
+@immutable
+class PhonePromptContext {
+ const PhonePromptContext({
+ this.harness,
+ this.machine,
+ this.project,
+ this.branch,
+ this.leading,
+ });
+
+ final String? harness, machine, project, branch, leading;
+}
+
+/// The compact identity line under a result's name: what engine, on what
+/// machine, in what folder, on what branch.
+///
+/// A port of the desktop's `PromptContextView`, which is what its picker
+/// actually draws — and the reason the two lists did not look alike even once
+/// they held the same words. The desktop does not write
+/// `Codex · work · harness-remote-box`; it draws four segments, each with its
+/// own glyph and its own colour, so the eye can find "which machine" without
+/// reading the line.
+///
+/// ⚠️ **The symbols are icons, not glyphs from a patched font.** The desktop's
+/// comment on this is worth keeping: drawing them means changing the terminal
+/// font never requires a Nerd Font.
+///
+/// What is dropped in the port: the desktop's `PromptPrefs`, which let somebody
+/// turn the machine, project or branch off and pick plain/powerline. The phone
+/// has no screen to set that on, so all three are always drawn, always with
+/// their glyph.
+class PhonePromptContextView extends StatelessWidget {
+ const PhonePromptContextView({
+ super.key,
+ required this.contextData,
+ this.size = 12,
+ this.matches = const [],
+ });
+
+ final PhonePromptContext contextData;
+ final double size;
+ final Iterable<PhoneFieldMatch> matches;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return ListenableBuilder(
+ listenable: terminalFontStore,
+ builder: (context, _) => _line(context),
+ );
+ }
+
+ Widget _line(BuildContext context) {
+ final data = contextData;
+ final faint = AppPalette.textSecondary;
+ final segments =
+ <({String label, String value, String ascii, IconData? icon, Color color})>[
+ if (data.harness?.isNotEmpty == true)
+ (
+ label: 'Harness',
+ value: data.harness!,
+ ascii: kHarnessPromptMarker,
+ icon: null,
+ color: faint,
+ ),
+ if (data.leading?.isNotEmpty == true)
+ (
+ label: '',
+ value: data.leading!,
+ ascii: '',
+ icon: null,
+ color: faint,
+ ),
+ if (data.machine?.isNotEmpty == true)
+ (
+ label: 'Machine',
+ value: data.machine!,
+ ascii: '@',
+ icon: LucideIcons.monitor300,
+ color: AppPalette.swarmAccent,
+ ),
+ if (data.project?.isNotEmpty == true)
+ (
+ label: 'Project',
+ value: data.project!,
+ ascii: '/',
+ icon: LucideIcons.folder300,
+ color: AppPalette.teal,
+ ),
+ if (data.branch?.isNotEmpty == true)
+ (
+ label: 'Branch',
+ value: data.branch!,
+ ascii: 'git:',
+ icon: LucideIcons.gitBranch300,
+ color: AppPalette.online,
+ ),
+ ];
+ if (segments.isEmpty) return const SizedBox.shrink();
+ return Semantics(
+ label: segments
+ .map(
+ (part) =>
+ '${part.label.isEmpty ? '' : '${part.label}: '}${part.value}',
+ )
+ .join(', '),
+ child: ExcludeSemantics(
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ for (var index = 0; index < segments.length; index++) ...[
+ if (index > 0) const SizedBox(width: 10),
+ // Each segment truncates inside its own share rather than the
+ // line ellipsing from the right — otherwise the machine, which is
+ // last and is the whole reason the line exists on a list that
+ // mixes machines, is the one part that always disappears.
+ Flexible(child: _Segment(part: segments[index], size: size, matches: matches)),
+ ],
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class _Segment extends StatelessWidget {
+ const _Segment({
+ required this.part,
+ required this.size,
+ required this.matches,
+ });
+
+ final ({String label, String value, String ascii, IconData? icon, Color color})
+ part;
+ final double size;
+ final Iterable<PhoneFieldMatch> matches;
+
+ @override
+ Widget build(BuildContext context) => Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (part.ascii.isNotEmpty) ...[
+ if (part.icon == null)
+ Text(
+ part.ascii,
+ style: phoneBoxMonoStyle(size: size, color: part.color),
+ )
+ else
+ Icon(part.icon, size: size, color: part.color),
+ const SizedBox(width: 4),
+ ],
+ Flexible(
+ child: SearchResultText(
+ part.value,
+ matches: matches,
+ style: phoneBoxMonoStyle(size: size, color: part.color),
+ ),
+ ),
+ ],
+ );
+}
diff --git a/mobile/lib/phone/phone_search_actions.dart b/mobile/lib/phone/phone_search_actions.dart
new file mode 100644
index 000000000..4a4f091ab
--- /dev/null
+++ b/mobile/lib/phone/phone_search_actions.dart
@@ -0,0 +1,59 @@
+import 'package:flutter/widgets.dart';
+
+import 'package:harness_mobile/state/app_state.dart';
+
+import 'agent_index.dart';
+import 'agents_list_page.dart';
+import 'agents_page.dart' show openNewAgent;
+import 'phone_navigation.dart';
+import 'phone_search_commands.dart';
+import 'phone_status.dart';
+import 'settings_page.dart';
+
+/// What `>` offers on the phone, and so what `?` lists under its three modes.
+///
+/// The desktop's `_searchModes` builds its half of this off a keymap and drops
+/// any command the workspace cannot currently run. Same rule here, without the
+/// keymap: a command is offered only while it would do something — there is no
+/// "New agent" while no machine is ready to take one.
+///
+/// ⚠️ **Re-read on every filter, never cached.** Which commands are available
+/// follows the fleet, and a list built once at open would keep offering a
+/// machine that has since dropped.
+List<PhoneCommand> phoneSearchCommands(
+ BuildContext context,
+ AppNotifier notifier,
+) {
+ final ready = [
+ for (final machine in filterableMachines(notifier))
+ if (phoneMachineStatusOf(machine) == PhoneMachineStatus.ready) machine,
+ ];
+ return [
+ if (ready.isNotEmpty)
+ PhoneCommand(
+ id: 'agent.new',
+ title: 'New agent',
+ detail: ready.length == 1
+ ? 'On ${ready.first.machine.displayName}'
+ : 'Choose a machine, then an engine',
+ run: () =>
+ openNewAgent(context, notifier, ready.first.machine.machineId),
+ ),
+ PhoneCommand(
+ id: 'navigation.agents',
+ title: 'All agents',
+ detail: 'Every agent on the account, by machine',
+ run: () => Navigator.of(
+ context,
+ ).push(phoneRoute((_) => AgentsListPage(notifier: notifier))),
+ ),
+ PhoneCommand(
+ id: 'app.settings',
+ title: 'Settings',
+ detail: 'Appearance · terminal · account',
+ run: () => Navigator.of(context).push(
+ phoneRoute((_) => SettingsPage(notifier: notifier, large: false)),
+ ),
+ ),
+ ];
+}
diff --git a/mobile/lib/phone/phone_search_catalog.dart b/mobile/lib/phone/phone_search_catalog.dart
new file mode 100644
index 000000000..87bd4e08c
--- /dev/null
+++ b/mobile/lib/phone/phone_search_catalog.dart
@@ -0,0 +1,276 @@
+import 'package:collection/collection.dart' show compareNatural;
+import 'package:flutter/foundation.dart' show listEquals;
+
+import 'package:harness_mobile/core/models.dart';
+import 'package:harness_mobile/state/app_state.dart';
+import 'package:harness_mobile/widgets/engine_identity.dart';
+
+import 'agent_index.dart';
+import 'phone_destination.dart';
+import 'phone_prompt_context.dart';
+import 'phone_status.dart';
+
+String phoneAgentId(String machineId, String agentId) =>
+ 'agent:$machineId\u0000$agentId';
+
+/// One catalog, rebuilt only when the fleet actually changes shape.
+///
+/// The desktop's `SwarmSearchCatalog`, and it exists for the reason its comment
+/// gives: terminal output leaves these normalized snapshots intact, and only
+/// discovery, membership or metadata rebuilds them.
+///
+/// ⚠️ **A turn event must not re-normalize the account.** Building the catalog
+/// lowercases eleven strings per agent, and on a busy fleet the notifier ticks
+/// several times a second — so the uncached version spent a phone's battery
+/// re-deriving a list that had not changed a character.
+///
+/// What it deliberately does NOT key on: `agentActivityAt`, `processingAgentIds`
+/// and `blockedAgents`, all of which move constantly. Rows read those live off
+/// the [MachineState] they hold, so `working` and `4m` stay current without the
+/// catalog being rebuilt — and the ranking no longer depends on them at all.
+class PhoneSearchCatalogCache {
+ List<Object?>? _presentation;
+ List<PhoneDestination> _entries = const [];
+
+ List<PhoneDestination> read(AppNotifier notifier) {
+ final presentation = _presentationOf(notifier);
+ if (listEquals(_presentation, presentation)) return _entries;
+ _presentation = presentation;
+ return _entries = List.unmodifiable(phoneSearchCatalog(notifier));
+ }
+
+ static List<Object?> _presentationOf(AppNotifier notifier) => [
+ for (final machine in notifier.machines) machine,
+ for (final machine in notifier.machineStates.values) ...[
+ machine.machine,
+ machine.nodeOnline,
+ machine.needsLink,
+ machine.connectionStatus,
+ machine.agentLoadStatus,
+ // The list's identity, not its contents: `_replaceAgents` hands over a
+ // new list whenever anything about the agents changed, and nothing else
+ // reassigns it.
+ machine.agents,
+ machine.agents.length,
+ ],
+ ];
+}
+
+/// Everything one query can reach: every agent, every machine, every project.
+///
+/// The phone's `SwarmSearchCatalog.read`, ported from the desktop so the same
+/// words reach the same rows on both. Agents come first and in [recentAgents]
+/// order, which is what an empty query offers before ranking has anything to
+/// go on.
+///
+/// ⚠️ **Machines and projects are rows here, but only `@` and `#` list them.**
+/// The desktop keeps them in its catalog the same way and shows them under the
+/// same two prefixes — its plain query is agents only (see
+/// `PhoneSearchController._filter`). They still earn their place here twice
+/// over: the two prefixes read them, and building the project groups is what
+/// makes a project's name searchable on the agents inside it.
+List<PhoneDestination> phoneSearchCatalog(AppNotifier notifier) {
+ final entries = recentAgents(agentIndex(notifier));
+ final agents = [
+ for (final entry in entries)
+ _agent(
+ notifier,
+ entry,
+ engineIdentity(
+ entry.agent.engine,
+ displayName: entry.agent.engineDisplayName,
+ ).label,
+ ),
+ ];
+ final byId = {for (final row in agents) row.id: row};
+ return [
+ ...agents,
+ ..._machines(notifier, byId),
+ ..._projects(entries, byId),
+ ];
+}
+
+PhoneDestination _agent(
+ AppNotifier notifier,
+ AgentEntry entry,
+ String label,
+) {
+ final agent = entry.agent;
+ final project = entry.project;
+ final offline = entry.machine.nodeOnline == false;
+ final detail = _harnessDetail(
+ label,
+ project,
+ entry.machineName,
+ offline,
+ agentLabel: label,
+ );
+ return PhoneDestination(
+ id: phoneAgentId(entry.machineId, agent.id),
+ kind: PhoneDestinationKind.agent,
+ title: agent.name,
+ detail: detail.text,
+ detailBranchOffset: detail.branchOffset,
+ promptContext: PhonePromptContext(
+ harness: label,
+ machine: entry.machineName,
+ // The FOLDER, not the project's reported name — the desktop's picker
+ // shows `Desktop` and `autonomous-harness`, which is the tail of the path
+ // somebody actually recognises, and a phone has no width for the rest.
+ project: project?.folder,
+ branch: project?.branchLabel,
+ leading: offline ? 'Offline' : null,
+ ),
+ machineId: entry.machineId,
+ machineLabel: entry.machineName,
+ agentId: agent.id,
+ engine: agent.engine,
+ previewKey: notifier.previewKey(entry.machineId, agent),
+ entry: entry,
+ // The agent's own title is ranked like its name (see [titleFields]):
+ // "board fab check" finds the agent whose work that is, never the one
+ // whose folder or recap happens to mention fab.
+ searchFields: [
+ agent.title,
+ label,
+ entry.machineName,
+ project?.name,
+ project?.branchLabel,
+ project?.cwd,
+ agent.engine,
+ // Neither is drawn, but "the llama one" or "the model manager" is how
+ // somebody away from their desk remembers an agent called `harness-3`.
+ agent.gridModel,
+ agent.selectedModel,
+ agent.dshName,
+ ],
+ titleFields: agent.title == null ? 1 : 2,
+ );
+}
+
+/// One row per machine on the account, whether or not it is answering.
+///
+/// Every machine, unlike [agentIndex], which lists only the ones that can hand
+/// over an agent: a machine that is off or locked is exactly the thing somebody
+/// searches for when its agents are missing, and the row says which it is.
+List<PhoneDestination> _machines(
+ AppNotifier notifier,
+ Map<String, PhoneDestination> agents,
+) {
+ final members = <String, Set<String>>{};
+ for (final row in agents.values) {
+ (members[row.machineId!] ??= {}).add(row.id);
+ }
+ return [
+ for (final machine in notifier.machines)
+ if (notifier.stateOf(machine.machineId) case final state?)
+ PhoneDestination(
+ id: 'machine:${machine.machineId}',
+ kind: PhoneDestinationKind.machine,
+ title: state.machine.displayName,
+ detail: [
+ 'Machine',
+ _countLabel(members[machine.machineId]?.length ?? 0, 'harness'),
+ switch (phoneMachineStatusOf(state)) {
+ PhoneMachineStatus.needsPassword => 'Link required',
+ PhoneMachineStatus.offline => 'Offline',
+ PhoneMachineStatus.connecting => 'Connecting',
+ PhoneMachineStatus.ready => null,
+ },
+ ].whereType<String>().join(' · '),
+ machineId: machine.machineId,
+ machineLabel: state.machine.displayName,
+ machine: state,
+ members: Set.unmodifiable(
+ members[machine.machineId] ?? const <String>{},
+ ),
+ ),
+ ];
+}
+
+/// One row per repository or folder, agents grouped by [AgentProject.identity].
+///
+/// The same identity rule the desktop uses: checkouts group across machines
+/// only when the daemon reports the same canonical remote. Two same-named
+/// folders never become one project on a name alone.
+///
+/// Also makes each project's name searchable on its agents, so `#harness` and a
+/// plain `harness` reach the same rows.
+List<PhoneDestination> _projects(
+ List<AgentEntry> entries,
+ Map<String, PhoneDestination> agents,
+) {
+ final groups = <String, List<AgentEntry>>{};
+ for (final entry in entries) {
+ final project = entry.project;
+ if (project == null) continue;
+ (groups[project.identity(entry.machineId)] ??= []).add(entry);
+ }
+ final rows = <PhoneDestination>[];
+ for (final MapEntry(key: id, value: members) in groups.entries) {
+ final name = members.first.project!.name;
+ final ids = {
+ for (final entry in members)
+ if (agents.containsKey(phoneAgentId(entry.machineId, entry.agent.id)))
+ phoneAgentId(entry.machineId, entry.agent.id),
+ };
+ rows.add(
+ PhoneDestination(
+ id: 'project:$id',
+ kind: PhoneDestinationKind.project,
+ projectId: id,
+ title: name,
+ detail: 'Project · ${_countLabel(ids.length, 'harness')}',
+ machineId: members.first.machineId,
+ machineLabel: members.first.machineName,
+ members: Set.unmodifiable(ids),
+ searchFields: {
+ for (final entry in members) ...[
+ entry.machineName,
+ entry.project?.cwd,
+ entry.project?.branchLabel,
+ ],
+ },
+ ),
+ );
+ }
+ rows.sort(
+ (a, b) => compareNatural(a.title.toLowerCase(), b.title.toLowerCase()),
+ );
+ return rows;
+}
+
+/// The metadata line, in the desktop's own order and with its branch offset.
+///
+/// The engine's label stands in for the desktop's harness *category*, which the
+/// phone's [engineIdentity] does not carry — "Claude" where the desktop says
+/// "Coding agent". Same slot, same ranking, one word the person recognises.
+({String text, int? branchOffset}) _harnessDetail(
+ String? type,
+ AgentProject? project,
+ String machine,
+ bool offline, {
+ required String agentLabel,
+}) {
+ final prefix = [
+ type,
+ project?.name,
+ ].whereType<String>().where((part) => part.isNotEmpty).join(' · ');
+ final branch = project?.branchLabel;
+ return (
+ text: [
+ prefix,
+ branch,
+ machine,
+ if (offline) 'Offline',
+ ].whereType<String>().where((part) => part.isNotEmpty).join(' · '),
+ branchOffset: branch != null && branch.isNotEmpty
+ ? (prefix.isNotEmpty ? prefix.length + 3 : 0)
+ : null,
+ );
+}
+
+String _countLabel(int count, String noun) {
+ final plural = noun == 'harness' ? 'harnesses' : '${noun}s';
+ return '$count ${count == 1 ? noun : plural}';
+}
diff --git a/mobile/lib/phone/phone_search_commands.dart b/mobile/lib/phone/phone_search_commands.dart
new file mode 100644
index 000000000..73e54b580
--- /dev/null
+++ b/mobile/lib/phone/phone_search_commands.dart
@@ -0,0 +1,62 @@
+import 'dart:async';
+
+import 'phone_destination.dart';
+
+/// Something the app does, offered by name under `>`.
+///
+/// The action travels WITH the row, unlike the desktop, where the screen owns a
+/// keymap and resolves a command id back to a handler. The phone has no keymap
+/// to resolve against, and an id matched back to a handler by hand at the call
+/// site is how a renamed command becomes a row that quietly does nothing.
+class PhoneCommand {
+ const PhoneCommand({
+ required this.id,
+ required this.title,
+ required this.detail,
+ required this.run,
+ });
+
+ /// Stable across releases: it is what [PhoneSearchHistory] remembers, so a
+ /// renamed title keeps its place in the list and a renamed id loses it.
+ final String id;
+
+ final String title, detail;
+ final FutureOr<void> Function() run;
+
+ PhoneDestination get destination => PhoneDestination(
+ id: 'command:$id',
+ kind: PhoneDestinationKind.command,
+ title: title,
+ detail: detail,
+ commandId: id,
+ searchFields: [id, detail],
+ );
+}
+
+/// The `?` rows: what this one box can do, each with the character that goes
+/// there directly.
+///
+/// The desktop's `_searchModes`, minus the keyboard. Its point survives the
+/// translation intact: five shortcuts that open five things read as five
+/// features until something lists them in one place, and then they read as one.
+/// A phone has no key to discover them by, so `?` is the only teacher there is.
+List<PhoneDestination> phoneSearchModes(List<PhoneCommand> commands) => [
+ _mode('commands', '> Commands', 'Run anything by name', '> '),
+ _mode('projects', '# Projects', 'Choose a project, then one of its agents', '# '),
+ _mode('machines', '@ Machines', 'Choose a machine, then one of its agents', '@ '),
+ for (final command in commands) command.destination,
+];
+
+PhoneDestination _mode(
+ String id,
+ String title,
+ String detail,
+ String query,
+) => PhoneDestination(
+ id: 'picker:$id',
+ kind: PhoneDestinationKind.mode,
+ title: title,
+ detail: detail,
+ pickerQuery: query,
+ searchFields: [detail],
+);
diff --git a/mobile/lib/phone/phone_search_controller.dart b/mobile/lib/phone/phone_search_controller.dart
new file mode 100644
index 000000000..16ce7d472
--- /dev/null
+++ b/mobile/lib/phone/phone_search_controller.dart
@@ -0,0 +1,335 @@
+import 'dart:async';
+
+import 'package:flutter/foundation.dart';
+
+import 'package:harness_mobile/core/phone_search_history.dart';
+import 'package:harness_mobile/state/app_state.dart';
+
+import 'phone_destination.dart';
+import 'phone_search_catalog.dart';
+import 'phone_search_commands.dart';
+import 'phone_search_rank.dart';
+
+/// What the box finds, said in the box.
+///
+/// The desktop's `kSwarmSearchHint`, word for word. It searches four kinds of
+/// thing, and a hint that named only one of them ("Search agents") was most of
+/// why nobody on the phone knew the other three existed.
+const kPhoneSearchHint =
+ 'Search agents > commands # projects @ machines ? help';
+
+/// One search session, shared by the field and its results.
+///
+/// The phone's `SwarmSearchController`. Ported mode for mode: `>` commands,
+/// `#` projects, `@` machines, `?` help, and the group scope that choosing a
+/// project or a machine drops you into.
+///
+/// ⚠️ **Keystrokes never ask a machine anything.** They filter the catalog the
+/// app already holds — agents, machines, projects, and the session content
+/// [AppNotifier.sessionPreviews] has cached — so typing on two bars of signal
+/// stays instant and costs no data.
+///
+/// What the desktop has and this does not: panes, tabs, placement, splits, the
+/// preview panel, and the "New Harness" row. All four are about WHERE a result
+/// opens, and a phone has one place.
+class PhoneSearchController extends ChangeNotifier {
+ PhoneSearchController({
+ required this.notifier,
+ this.history,
+ this.commands,
+ }) {
+ _catalog = _cache.read(notifier);
+ _filter();
+ notifier.addListener(_rebuild);
+ notifier.sessionPreviews.addListener(_previewChanged);
+ }
+
+ final AppNotifier notifier;
+
+ /// Where visits are remembered, so the box opens on the agents actually being
+ /// switched between. Null keeps this search's ranking to one session.
+ final PhoneSearchHistory? history;
+
+ /// What `>` lists. Read on every filter rather than held, because which
+ /// commands are available follows the app: there is no "Change model" while
+ /// no agent is open.
+ final List<PhoneCommand> Function()? commands;
+
+ final _cache = PhoneSearchCatalogCache();
+ List<PhoneDestination> _catalog = const [];
+ Set<String> _commandIds = const {};
+
+ /// What the list draws, best first.
+ List<PhoneDestination> rows = const [];
+
+ String query = '';
+
+ /// How many things could match, and how many do — fzf's `4/7`. The quickest
+ /// answer to "did that narrow it, or is it just not here?".
+ int total = 0;
+ int matchCount = 0;
+
+ static final _quickAccessPrefix = RegExp(r'^[>@#?]');
+ static final _commandPrefix = RegExp(r'^>\s*');
+ static final _helpPrefix = RegExp(r'^\?\s*');
+
+ bool get isCommandMode => query.trimLeft().startsWith('>');
+ bool get isHelpMode => query.trimLeft().startsWith('?');
+ bool get isProjectMode => query.trimLeft().startsWith('#');
+ bool get isMachineMode => query.trimLeft().startsWith('@');
+ bool get isGroupMode => isProjectMode || isMachineMode;
+
+ String get commandQuery => query.trimLeft().replaceFirst(_commandPrefix, '');
+ String get helpQuery => query.trimLeft().replaceFirst(_helpPrefix, '');
+
+ /// The project or machine the search has been narrowed to, once one was
+ /// chosen. Its [query] is what the field goes back to on [back].
+ ({String id, String name, String query})? _groupScope;
+ bool get canGoBack => _groupScope != null;
+ String? get scopeName => _groupScope?.name;
+
+ /// What the rows are actually matched against: the query minus its mode
+ /// character.
+ String get matchQuery => isCommandMode
+ ? commandQuery
+ : isHelpMode
+ ? helpQuery
+ : isGroupMode
+ ? query.trimLeft().substring(1).trimLeft()
+ : query;
+
+ String get title => isCommandMode
+ ? 'Commands'
+ : isHelpMode
+ ? 'Quick access'
+ : isProjectMode
+ ? 'Projects'
+ : isMachineMode
+ ? 'Machines'
+ : _groupScope != null
+ ? 'Agents · ${_groupScope!.name}'
+ : 'Search';
+
+ String get hint => isCommandMode
+ ? 'Search commands…'
+ : isHelpMode
+ ? 'Choose a mode or search help…'
+ : _groupScope != null
+ ? 'Search agents in ${_groupScope!.name}…'
+ : isProjectMode
+ ? 'Search projects…'
+ : isMachineMode
+ ? 'Search machines…'
+ : kPhoneSearchHint;
+
+ void setQuery(String value) {
+ if (query == value) return;
+ // Typing a mode character leaves whatever group was chosen: `@` means "pick
+ // a machine", which is not a thing to do inside one.
+ if (_quickAccessPrefix.hasMatch(value.trimLeft())) _groupScope = null;
+ query = value;
+ _filter();
+ notifyListeners();
+ }
+
+ /// Leaves the chosen project or machine, putting the query that chose it back
+ /// in the field. False when there was no group to leave, so the caller can let
+ /// the gesture close the search instead.
+ bool back() {
+ final scope = _groupScope;
+ if (scope == null) return false;
+ _groupScope = null;
+ setQuery(scope.query);
+ return true;
+ }
+
+ /// What a tap does: scope to a group, take a `?` row's mode, or hand the row
+ /// back for the caller to open. Null when the tap was absorbed here.
+ PhoneDestination? submit(PhoneDestination row) {
+ if (!canSubmit(row)) return null;
+ if (row.isGroup) {
+ final group = _catalog
+ .where((entry) => entry.id == row.id && entry.isGroup)
+ .firstOrNull;
+ if (group == null) return null;
+ _groupScope = (id: group.id, name: group.title, query: query);
+ setQuery('');
+ return null;
+ }
+ if (row.pickerQuery case final next?) {
+ setQuery(next);
+ return null;
+ }
+ if (row.isCommand) {
+ final id = row.commandId;
+ if (id != null) history?.rememberCommand(id);
+ return row;
+ }
+ final id = row.agentId == null ? null : row.id;
+ if (id != null) history?.remember(id);
+ return row;
+ }
+
+ /// Whether a tap on [row] can do anything at all. A row that cannot is drawn
+ /// dimmed with the reason on its trailing edge rather than hidden: an agent
+ /// whose terminal has gone is still the answer to "where did it go".
+ bool canSubmit(PhoneDestination row) => switch (row.kind) {
+ // Stopped work counts: the tap resumes it first — see [AgentEntry.isOpenable].
+ PhoneDestinationKind.agent => row.entry?.isOpenable ?? false,
+ // A locked machine opens its password form, which is the thing to do about
+ // it; a switched-off one has nothing to take a password.
+ PhoneDestinationKind.machine =>
+ _catalog.any((entry) => entry.id == row.id && entry.isMachine),
+ PhoneDestinationKind.project =>
+ _catalog.any((entry) => entry.id == row.id && entry.isProject),
+ PhoneDestinationKind.command => _commandIds.contains(row.id),
+ PhoneDestinationKind.mode => true,
+ };
+
+ void _rebuild() {
+ final next = _cache.read(notifier);
+ // Nothing about the fleet changed shape, so the rows cannot have either —
+ // and re-ranking would hand the list a new set of objects to rebuild from
+ // for no reason. What the rows SAY still updates: they read their machine
+ // live, and the preview store has its own path in.
+ if (identical(next, _catalog)) return;
+ _catalog = next;
+ _filter();
+ _scheduleNotify();
+ }
+
+ /// Content landing can add or remove a match, but must never shuffle the rows
+ /// under a thumb or repaint a list whose result set has not changed.
+ void _previewChanged() {
+ if (matchQuery.trim().isEmpty || isCommandMode || isHelpMode) return;
+ final previous = rows;
+ _filter();
+ if (!listEquals(previous, rows)) _scheduleNotify();
+ }
+
+ /// Announce a change the APP made, one microtask late.
+ ///
+ /// ⚠️ **Never synchronously, because these two arrive mid-build.**
+ /// [PhoneSearchResults] warms the preview store from its `initState`, and the
+ /// store publishes to its listeners as it goes — so the controller was told to
+ /// re-rank while the very list watching it was still being built, and
+ /// `markNeedsBuild` threw. A microtask drains after the build phase, which is
+ /// the earliest moment a rebuild can legally be asked for.
+ ///
+ /// [rows] is still updated synchronously above: what the box HOLDS is current
+ /// immediately, and only the repaint waits. Coalesced, so a machine answering
+ /// with forty agents costs one rebuild rather than forty.
+ ///
+ /// Typing does not come through here — [setQuery] notifies directly, because a
+ /// keystroke is never inside a build and the field must not lag a frame.
+ void _scheduleNotify() {
+ if (_notifyScheduled || _disposed) return;
+ _notifyScheduled = true;
+ scheduleMicrotask(() {
+ _notifyScheduled = false;
+ if (!_disposed) notifyListeners();
+ });
+ }
+
+ bool _notifyScheduled = false;
+ bool _disposed = false;
+
+ void _filter() {
+ if (isHelpMode) {
+ // The modes keep the order they are taught in; what follows `?` only
+ // narrows them, the way a quick-open's own `?` does.
+ final all = phoneSearchModes(commands?.call() ?? const <PhoneCommand>[]);
+ final needle = helpQuery.trim().toLowerCase();
+ _commandIds = {for (final mode in all) mode.id};
+ total = all.length;
+ rows = [
+ for (final mode in all)
+ if (needle.isEmpty ||
+ mode.fields.any((field) => field.contains(needle)))
+ mode,
+ ];
+ matchCount = rows.length;
+ return;
+ }
+ final available = isCommandMode
+ ? [
+ for (final command
+ in commands?.call() ?? const <PhoneCommand>[])
+ command.destination,
+ ]
+ : const <PhoneDestination>[];
+ _commandIds = {for (final row in available) row.id};
+ final scoped = _groupScope == null
+ ? null
+ : _catalog
+ .where((row) => row.id == _groupScope!.id)
+ .firstOrNull
+ ?.members ??
+ const <String>{};
+ final candidates = isCommandMode
+ ? available
+ : isProjectMode
+ ? [for (final row in _catalog) if (row.isProject) row]
+ : isMachineMode
+ ? [for (final row in _catalog) if (row.isMachine) row]
+ : scoped != null
+ ? [
+ for (final row in _catalog)
+ if (row.isAgent && scoped.contains(row.id)) row,
+ ]
+ // ⚠️ **Agents only, and this is the desktop's behaviour, not a cut.**
+ // Every one of `swarm_screen.dart`'s six `_openSearch` calls passes
+ // `adding: true`, which makes `placement` (or `split`) non-null, which
+ // takes `_filter` down its `row.agentId != null` branch. So the desktop
+ // box has never listed a machine or a project in a plain query — its
+ // `16/16` counts agents. They are reached through `@` and `#`, and they
+ // stay searchable as fields on the agents inside them.
+ : [
+ for (final row in _catalog)
+ if (row.isAgent) row,
+ ];
+ total = candidates.length;
+ rows = isCommandMode
+ ? _recentFirst(rankPhoneDestinations(candidates, commandQuery))
+ : rankPhoneDestinations(
+ candidates,
+ matchQuery,
+ recent: history?.recent ?? const <String>[],
+ previews: notifier.sessionPreviews,
+ );
+ // Keep the match order, but put rows a tap can open first. An agent whose
+ // terminal has gone must not bury the ones that answer.
+ final open = <PhoneDestination>[];
+ final shut = <PhoneDestination>[];
+ for (final row in rows) {
+ (canSubmit(row) ? open : shut).add(row);
+ }
+ rows = [...open, ...shut];
+ matchCount = rows.length;
+ }
+
+ /// With nothing typed, the commands run lately lead, newest first; the rest
+ /// keep their order. Once something is typed, the match decides.
+ List<PhoneDestination> _recentFirst(List<PhoneDestination> ranked) {
+ final recent = history?.recentCommands ?? const <String>[];
+ if (commandQuery.trim().isNotEmpty || recent.isEmpty) return ranked;
+ final byId = {
+ for (final row in ranked)
+ if (row.commandId != null) row.commandId!: row,
+ };
+ final first = [for (final id in recent) ?byId[id]];
+ return [
+ ...first,
+ for (final row in ranked)
+ if (!first.contains(row)) row,
+ ];
+ }
+
+ @override
+ void dispose() {
+ _disposed = true;
+ notifier.removeListener(_rebuild);
+ notifier.sessionPreviews.removeListener(_previewChanged);
+ super.dispose();
+ }
+}
diff --git a/mobile/lib/phone/phone_search_field.dart b/mobile/lib/phone/phone_search_field.dart
index ef92b222a..3fe6a90c1 100644
--- a/mobile/lib/phone/phone_search_field.dart
+++ b/mobile/lib/phone/phone_search_field.dart
@@ -4,6 +4,7 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'composing_keyboard.dart';
+import 'phone_search_controller.dart';
/// The search page's whole header: one bar, with the way out inside it.
///
@@ -25,6 +26,7 @@ class PhoneSearchField extends StatelessWidget {
required this.onClear,
this.onBack,
this.autofocus = true,
+ this.hintText = kPhoneSearchHint,
});
final TextEditingController controller;
@@ -45,6 +47,15 @@ class PhoneSearchField extends StatelessWidget {
/// would bury half of what the person opened the screen to look at.
final bool autofocus;
+ /// What the empty field says it can do.
+ ///
+ /// ⚠️ **It names all four kinds, and that is the point.** It used to read
+ /// "Search agents", which was true and was also the whole reason nobody on the
+ /// phone knew that `>`, `#`, `@` and `?` existed — the desktop teaches its
+ /// modes here and only here. The controller narrows it once a mode is open
+ /// ("Search projects…"), so the long form is only ever read on an empty box.
+ final String hintText;
+
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
@@ -88,6 +99,7 @@ class PhoneSearchField extends StatelessWidget {
focus: focus,
onChanged: onChanged,
autofocus: autofocus,
+ hintText: hintText,
),
),
_ClearButton(controller: controller, onTap: onClear),
@@ -134,12 +146,14 @@ class _QueryInput extends StatelessWidget {
required this.focus,
required this.onChanged,
required this.autofocus,
+ required this.hintText,
});
final TextEditingController controller;
final FocusNode focus;
final ValueChanged<String> onChanged;
final bool autofocus;
+ final String hintText;
@override
Widget build(BuildContext context) {
@@ -192,8 +206,10 @@ class _QueryInput extends StatelessWidget {
filled: false,
contentPadding: EdgeInsets.zero,
constraints: const BoxConstraints(),
- hintText: 'Search agents',
- hintStyle: TextStyle(color: AppPalette.textFaint, fontSize: 16),
+ hintText: hintText,
+ // A size down from the query's own 16pt: the hint spells out four modes
+ // and has to survive a 390pt screen without ellipsing the last of them.
+ hintStyle: TextStyle(color: AppPalette.textFaint, fontSize: 13),
),
);
}
diff --git a/mobile/lib/phone/phone_search_folder_header.dart b/mobile/lib/phone/phone_search_folder_header.dart
deleted file mode 100644
index b7bebf032..000000000
--- a/mobile/lib/phone/phone_search_folder_header.dart
+++ /dev/null
@@ -1,60 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:lucide_icons_flutter/lucide_icons.dart';
-
-import 'package:harness_mobile/shared/theme/app_theme.dart';
-
-import 'phone_search_groups.dart';
-
-/// The line over one folder's agents: the folder, the machine it is on, and how
-/// many matched.
-///
-/// Carries the two things every row under it used to repeat, so each row's
-/// second line is left for what actually tells its agents apart. A folder glyph
-/// rather than an uppercase label, so it cannot be read as the same kind of
-/// heading as the Machines section below it.
-class PhoneSearchFolderHeader extends StatelessWidget {
- const PhoneSearchFolderHeader({super.key, required this.group});
-
- final PhoneSearchGroup group;
-
- @override
- Widget build(BuildContext context) {
- AppTheme.watch(context);
- final faint = TextStyle(color: AppPalette.textFaint, fontSize: 12);
- return Padding(
- padding: const EdgeInsets.fromLTRB(10, 14, 10, 4),
- child: Row(
- children: [
- Icon(LucideIcons.folder300, size: 14, color: AppPalette.textFaint),
- const SizedBox(width: 6),
- Flexible(
- child: Text.rich(
- TextSpan(
- children: [
- TextSpan(
- text: group.folder.isEmpty ? 'No folder' : group.folder,
- style: TextStyle(
- color: AppPalette.textSecondary,
- fontWeight: FontWeight.w600,
- ),
- ),
- // The machine ellipses off first: it is the longest part and
- // the one that is the same for most people's every group.
- TextSpan(text: ' · ${group.machineName}'),
- ],
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: faint,
- ),
- ),
- const SizedBox(width: 7),
- Text(
- '${group.rows.length}',
- style: faint.copyWith(fontFeatures: AppFont.tabularFigures),
- ),
- ],
- ),
- );
- }
-}
diff --git a/mobile/lib/phone/phone_search_groups.dart b/mobile/lib/phone/phone_search_groups.dart
index f4d008822..f16b08626 100644
Binary files a/mobile/lib/phone/phone_search_groups.dart and b/mobile/lib/phone/phone_search_groups.dart differ
diff --git a/mobile/lib/phone/phone_search_index.dart b/mobile/lib/phone/phone_search_index.dart
deleted file mode 100644
index 161deed57..000000000
--- a/mobile/lib/phone/phone_search_index.dart
+++ /dev/null
@@ -1,186 +0,0 @@
-import 'package:harness_mobile/state/app_state.dart';
-import 'package:harness_mobile/state/session_preview.dart';
-
-import 'agent_index.dart';
-import 'phone_status.dart';
-
-/// What a search result opens.
-enum PhoneSearchKind { agent, machine }
-
-/// One row the search offers, whichever of the two lists it came from.
-///
-/// The phone's two tabs answer two different questions — every agent on the
-/// account, every machine on the account — and until now there was nowhere to
-/// ask both at once. Somebody who remembers only "that review thing" should not
-/// have to know first whether it is the name of an agent or of the machine it
-/// runs on. This is the flattening that lets one query reach both, built the way
-/// [AgentEntry] flattens machine-keyed state for the Agents tab.
-///
-/// [fields] is what the query is matched against, title fields first. The order
-/// is the ranking: a hit on the name outranks a hit on the machine under it, the
-/// same rule the desktop's `swarmFieldMatchScore` applies with its `title` flag.
-class PhoneSearchResult {
- const PhoneSearchResult({
- required this.kind,
- required this.id,
- required this.title,
- required this.subtitle,
- required this.placedSubtitle,
- required this.machinedSubtitle,
- required this.fields,
- required this.summary,
- required this.machineId,
- this.titleFields = 1,
- this.preview,
- this.entry,
- this.machine,
- });
-
- final PhoneSearchKind kind;
-
- /// Unique across both kinds — an agent and a machine can share a name, and
- /// two machines can each hold an agent with the same id.
- final String id;
-
- /// The name, as the row draws it and as the query matches it first.
- final String title;
-
- /// The line under it, when a folder header over the row already says where
- /// it is: an agent's work and branch, a machine's status.
- final String subtitle;
-
- /// The line under it when nothing above the row says where it is — the
- /// Recent list, which is one run rather than folders: the work, then the
- /// folder and the machine.
- final String placedSubtitle;
-
- /// The line under it when a MACHINE header above the row already names the
- /// machine but nothing names the folder — the agents list, which groups by
- /// machine and no deeper. [placedSubtitle] minus the machine: repeating it
- /// down every row of a group whose header just said it is the noise the
- /// header was added to remove, and the folder is what tells the group's own
- /// rows apart.
- final String machinedSubtitle;
-
- /// Every searchable string, lowercased, title first. Not everything in here is
- /// drawn — an agent's engine id is matched but never shown as itself — which is
- /// why [SearchResultText] re-checks that a matched field is actually present in
- /// the text it is emphasising.
- final List<String> fields;
-
- /// How many of [fields], from the front, rank as a name rather than as
- /// metadata: two for an agent that has a title, which is how people describe
- /// it, and is ranked that way on the desktop too (its `titleFields`).
- final int titleFields;
-
- /// What was last asked of this agent and what it answered — cached from its
- /// machine and kept live by its turn events. The fallback a word that matches
- /// no field is looked for in, as on the desktop.
- final SessionPreview? preview;
-
- final PhoneSummary summary;
-
- /// The machine this row belongs to, for either kind. An agent needs it to
- /// open; a machine IS it.
- final String machineId;
-
- /// Set for [PhoneSearchKind.agent] — what a tap opens.
- final AgentEntry? entry;
-
- /// Set for [PhoneSearchKind.machine].
- final MachineState? machine;
-}
-
-/// Everything one query can reach, unfiltered: agents most recent first (see
-/// [recentAgents]).
-///
-/// Recomputed on every rebuild, so the recency in it is live — which is why the
-/// screen drawing it pins the order down rather than following it. See
-/// `PhoneSearchOrder`.
-///
-/// Agents come from [agentIndex], so only machines that are LINKED and answering
-/// contribute — a row offered here has to be openable, and an offline machine's
-/// last-seen agent list is not. Machines are not listed: they are reached from
-/// the terminal's `⋯` sheet (`machine_actions.dart`), so search answers the one
-/// question it is opened for.
-List<PhoneSearchResult> phoneSearchIndex(AppNotifier notifier) => [
- for (final entry in recentAgents(agentIndex(notifier)))
- _agentResult(
- entry,
- notifier.sessionPreviews.read(
- notifier.previewKey(entry.machineId, entry.agent),
- ),
- ),
-];
-
-PhoneSearchResult _agentResult(AgentEntry entry, SessionPreview? preview) {
- final agent = entry.agent;
- final engine = agent.engineDisplayName ?? agent.engine ?? '';
- final title = agent.title ?? '';
- final branch = entry.project?.branchLabel ?? '';
- final folder = entry.project?.folder ?? '';
- return PhoneSearchResult(
- kind: PhoneSearchKind.agent,
- id: 'agent:${entry.machineId}:${agent.id}',
- title: agent.name,
- // What tells `work · 3188` from `work · 48e9`: the work itself, then its
- // branch. The folder and the machine are said once, by the group header
- // over the row, rather than repeated down every line of it; the engine is
- // the mark's to show and is only spelled out when nothing else is known.
- subtitle: _joined([title, branch]).ifEmpty(engine),
- placedSubtitle: _joined([title, folder, entry.machineName]).ifEmpty(engine),
- machinedSubtitle: _joined([title, folder]).ifEmpty(engine),
- fields: [
- agent.name,
- title,
- entry.machineName,
- engine,
- // The raw engine id as well as its display name: somebody types "codex",
- // and the display name may well be "Codex CLI".
- agent.engine ?? '',
- // What it runs on and what it was made as. None of these is drawn, but
- // "the llama one" or "the model manager" is how somebody away from the
- // desk remembers an agent whose name is `harness-3`.
- agent.gridModel ?? '',
- agent.selectedModel ?? '',
- agent.dshName ?? '',
- folder,
- // The project's own name is not drawn on a result row, but it is how
- // people describe the agent they are hunting for, so it stays searchable.
- // [SearchResultText] checks that a matched field is present in the text
- // it is about to emphasise, so matching here never bolds something
- // unrelated.
- entry.project?.name ?? '',
- branch,
- ].map((field) => field.toLowerCase()).where((field) => field.isNotEmpty).toList(),
- titleFields: title.isEmpty ? 1 : 2,
- preview: preview,
- summary: entry.summary,
- machineId: entry.machineId,
- entry: entry,
- );
-}
-
-String _joined(List<String> parts) =>
- parts.where((part) => part.isNotEmpty).join(' · ');
-
-extension on String {
- String ifEmpty(String fallback) => isEmpty ? fallback : this;
-}
-
-/// The agent rows' entries, in rank order — what a pager opened from a result
-/// swipes along.
-///
-/// ⚠️ **One entry out, one agent row in.** [PhoneSearchResult.entry] is nullable
-/// because a machine row has none, so unwrapping it at the call site invites a
-/// null-collapse that quietly drops a row. The pager walks this list BY INDEX
-/// against the rows drawn on screen: a list one shorter than the list somebody
-/// tapped sends the next swipe to a different agent than the one beside it.
-///
-/// Building it here keeps that invariant next to the code that establishes it —
-/// [phoneSearchIndex] sets `entry` on every agent row it makes — rather than
-/// leaving each caller to rediscover it.
-List<AgentEntry> phoneSearchAgentEntries(List<PhoneSearchResult> rows) => [
- for (final row in rows)
- if (row.kind == PhoneSearchKind.agent && row.entry != null) row.entry!,
-];
diff --git a/mobile/lib/phone/phone_search_order.dart b/mobile/lib/phone/phone_search_order.dart
deleted file mode 100644
index 3fe3ada54..000000000
--- a/mobile/lib/phone/phone_search_order.dart
+++ /dev/null
@@ -1,49 +0,0 @@
-import 'phone_search_index.dart';
-
-/// The place each row keeps for as long as one search is open.
-///
-/// ⚠️ **A list somebody is reading must not reorder itself.** [phoneSearchIndex]
-/// hands its rows in `recentAgents` order, and recency MOVES: every turn event
-/// stamps its agent's `lastActiveAt`, and that row jumps to the top — from under
-/// a finger already on its way to the row that was there. On a fleet with
-/// several agents working it never settles, and a turn left open by a restarted
-/// daemon heartbeats every second for ever, so the list reshuffles roughly as
-/// fast as it can be read. What the person gets for it is a tap on the wrong
-/// agent.
-///
-/// So the order is taken ONCE — from the first index this search is built with,
-/// which is the ranked one worth offering — and every rebuild after that is
-/// arranged back into it. The rows still say what is true right now: `working`
-/// replaces an age, a quote appears under a name as its preview lands. Only
-/// WHERE they are is held still.
-///
-/// One search, one order: both ways in mount [PhoneSearchResults] when the
-/// search opens and drop it when it closes, so the next one opens freshly
-/// ranked rather than on an order frozen minutes ago.
-class PhoneSearchOrder {
- /// Row id → its place. Ids are [PhoneSearchResult.id], stable across rebuilds.
- final Map<String, int> _slots = {};
-
- int _next = 0;
-
- /// [rows] in the frozen order, rows this search has not seen before last.
- ///
- /// An agent that appears mid-search — one just created, or a machine that has
- /// only now answered — goes to the END rather than into the middle. Dropping
- /// it into recency order would be exactly the shove this class exists to
- /// stop, and a row nobody has looked for yet has not earned the top of a list
- /// somebody is already reading.
- ///
- /// ⚠️ **A slot is never released.** A machine redialling takes its agents out
- /// of `agentIndex` for the length of the redial (`phoneMachineListsAgents`),
- /// which backgrounding the app does every time. Forgetting them there would
- /// send every one of that machine's rows to the bottom of the list and back
- /// on each reconnect — the same jump, arriving by the other door. Kept, they
- /// come back exactly where they were.
- List<PhoneSearchResult> arrange(List<PhoneSearchResult> rows) {
- for (final row in rows) {
- _slots.putIfAbsent(row.id, () => _next++);
- }
- return [...rows]..sort((a, b) => _slots[a.id]!.compareTo(_slots[b.id]!));
- }
-}
diff --git a/mobile/lib/phone/phone_search_page.dart b/mobile/lib/phone/phone_search_page.dart
index e17bd0d28..d7975edfc 100644
--- a/mobile/lib/phone/phone_search_page.dart
+++ b/mobile/lib/phone/phone_search_page.dart
@@ -4,36 +4,49 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/state/app_state.dart';
import 'phone_navigation.dart';
+import 'phone_search_actions.dart';
+import 'phone_search_commands.dart';
+import 'phone_search_controller.dart';
import 'phone_search_field.dart';
-import 'phone_search_rank.dart';
import 'phone_search_results.dart';
+import 'phone_search_scope_bar.dart';
-/// One query over every agent the account can reach. Machines are not searched
-/// here — they are on the terminal's `⋯` sheet.
+/// One query over every agent, machine and project the account can reach.
///
/// A screen of its own rather than a field above either list, and that is the
/// whole point: the two tabs each answer half the question, and somebody who
-/// remembers "that review thing" does not know which half holds it. This is the
-/// phone's version of the desktop's Open Agent picker, down to the ranking — the
-/// two share [phoneFieldMatchScore] so a query that finds an agent on the laptop
-/// finds the same agent here.
+/// remembers "that review thing" does not know which half holds it.
+///
+/// This is the phone's version of the desktop's box, mode for mode —
+/// [PhoneSearchController] carries `>` commands, `#` projects, `@` machines and
+/// `?` help, and ranks with the desktop's own scorer, so a query that finds an
+/// agent on the laptop finds the same agent here.
///
/// ⚠️ Keystrokes never ask a machine anything. They filter what the app already
-/// holds — the agent list, and the session content [PhoneSearchResults] reads —
-/// so typing on two bars of signal stays instant.
+/// holds, so typing on two bars of signal stays instant.
///
/// Returns when the search closes, so a caller whose own chrome depends on
/// being the top route can rebuild — see `terminal_page.dart`, where the header
/// buttons hide behind a keyboard this page did not raise.
Future<void> openPhoneSearch(BuildContext context, AppNotifier notifier) =>
- Navigator.of(context)
- .push(phoneRoute((_) => PhoneSearchPage(notifier: notifier)));
+ Navigator.of(
+ context,
+ ).push(phoneRoute((_) => PhoneSearchPage(notifier: notifier)));
class PhoneSearchPage extends StatefulWidget {
- const PhoneSearchPage({super.key, required this.notifier});
+ const PhoneSearchPage({
+ super.key,
+ required this.notifier,
+ this.commands,
+ });
final AppNotifier notifier;
+ /// What `>` offers. Defaults to [phoneSearchCommands], the app's real set;
+ /// overridden by tests, which must not push the real Settings screen to find
+ /// out whether a command ran.
+ final List<PhoneCommand> Function()? commands;
+
@override
State<PhoneSearchPage> createState() => _PhoneSearchPageState();
}
@@ -41,15 +54,43 @@ class PhoneSearchPage extends StatefulWidget {
class _PhoneSearchPageState extends State<PhoneSearchPage> {
final _controller = TextEditingController();
final _focus = FocusNode(debugLabel: 'Phone search');
- String _query = '';
+ late final PhoneSearchController _search = PhoneSearchController(
+ notifier: widget.notifier,
+ history: widget.notifier.searchHistory,
+ commands:
+ widget.commands ??
+ () => phoneSearchCommands(context, widget.notifier),
+ );
+
+ @override
+ void initState() {
+ super.initState();
+ // The order the box opens in comes off disk. Not awaited: what is known
+ // draws now, and the visits fold in a frame later, before anything has been
+ // read let alone tapped.
+ widget.notifier.searchHistory.load().then((_) {
+ if (mounted) _search.setQuery(_search.query);
+ });
+ }
@override
void dispose() {
_controller.dispose();
_focus.dispose();
+ _search.dispose();
super.dispose();
}
+ /// Back leaves the chosen project or machine first, and only then the screen —
+ /// the same step `#`/`@` took to get in.
+ void _back() {
+ if (_search.back()) {
+ _controller.text = _search.query;
+ return;
+ }
+ Navigator.of(context).maybePop();
+ }
+
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
@@ -60,28 +101,39 @@ class _PhoneSearchPageState extends State<PhoneSearchPage> {
resizeToAvoidBottomInset: true,
body: SafeArea(
bottom: false,
- child: Column(
- children: [
- PhoneSearchField(
- controller: _controller,
- focus: _focus,
- onChanged: (value) => setState(() => _query = value),
- onClear: () {
- _controller.clear();
- setState(() => _query = '');
- // Clearing is a step back into browsing, not out of the
- // screen — the caret stays where the next query will go.
- _focus.requestFocus();
- },
- onBack: () => Navigator.of(context).maybePop(),
- ),
- Expanded(
- child: PhoneSearchResults(
- notifier: widget.notifier,
- query: _query,
+ child: PopScope(
+ canPop: !_search.canGoBack,
+ onPopInvokedWithResult: (didPop, _) {
+ if (!didPop) _back();
+ },
+ child: Column(
+ children: [
+ ListenableBuilder(
+ listenable: _search,
+ builder: (context, _) => PhoneSearchField(
+ controller: _controller,
+ focus: _focus,
+ hintText: _search.hint,
+ onChanged: _search.setQuery,
+ onClear: () {
+ _controller.clear();
+ _search.setQuery('');
+ // Clearing is a step back into browsing, not out of the
+ // screen — the caret stays where the next query will go.
+ _focus.requestFocus();
+ },
+ onBack: _back,
+ ),
+ ),
+ PhoneSearchScopeBar(search: _search),
+ Expanded(
+ child: PhoneSearchResults(
+ notifier: widget.notifier,
+ controller: _search,
+ ),
),
- ),
- ],
+ ],
+ ),
),
),
);
diff --git a/mobile/lib/phone/phone_search_rank.dart b/mobile/lib/phone/phone_search_rank.dart
index bd34ae931..c9403c8eb 100644
--- a/mobile/lib/phone/phone_search_rank.dart
+++ b/mobile/lib/phone/phone_search_rank.dart
@@ -1,26 +1,28 @@
import 'package:harness_mobile/core/fuzzy_match.dart';
+import 'package:harness_mobile/state/session_preview.dart';
-import 'phone_search_index.dart';
+import 'phone_destination.dart';
+
+final _words = RegExp(r'\s+');
/// The query, split into the words that each have to match something.
///
/// Every word must hit — possibly a DIFFERENT field each — so "review mac" finds
-/// the review agent on the MacBook without either word having to match the whole
-/// row. The desktop splits the same way, and the freedom to match different
-/// fields is what makes word order not matter.
-List<String> phoneSearchTerms(String query) => query
- .toLowerCase()
- .split(RegExp(r'\s+'))
- .where((term) => term.isNotEmpty)
- .toList();
+/// the review agent on the MacBook without either word matching the whole row.
+/// The desktop's `swarmQueryTerms`, and the freedom to match different fields is
+/// what makes word order not matter.
+List<String> phoneSearchTerms(String query) {
+ final needle = query.trim().toLowerCase();
+ return needle.isEmpty ? const [] : needle.split(_words);
+}
/// How well [term] matches [field]: LOWER is better, null does not match.
///
-/// Ported from the desktop's `swarmFieldMatchScore` so both apps rank alike.
-/// The bands, cheapest first: an exact field, a prefix, a substring anywhere,
-/// and last a scattered-letter subsequence whose cost grows with how far apart
-/// the letters landed. A non-title field takes a flat 64 penalty, which is what
-/// keeps a name match ahead of every piece of metadata under it.
+/// The desktop's `swarmFieldMatchScore`, unchanged. The bands, cheapest first:
+/// an exact field, a prefix, a substring anywhere, and last a scattered-letter
+/// subsequence whose cost grows with how far apart the letters landed. A
+/// non-title field takes a flat 64, which is what keeps a name match ahead of
+/// every piece of metadata under it.
int? phoneFieldMatchScore(String field, String term, {required bool title}) {
final offset = field.indexOf(term);
final spread = offset >= 0 ? 0 : subsequenceSpread(field, term);
@@ -36,137 +38,174 @@ int? phoneFieldMatchScore(String field, String term, {required bool title}) {
}
/// The field [term] reaches best on [row] — its score and its index in
-/// [PhoneSearchResult.fields] — or null when it reaches none.
+/// [PhoneDestination.fields] — or null when it reaches none.
///
/// Shared by the ranking and by the emphasis, so the field a row is ranked on is
-/// the field that is bolded.
+/// the field that is emboldened. The desktop means the same ("the same field
+/// preference drives ranking and the visible match emphasis") but its two copies
+/// of this loop disagree: `search_result_text.dart` passes `title: i == 0`,
+/// which scores an agent's own title as metadata and can move the emphasis onto
+/// a different field than the one that earned the row its place. One helper here
+/// is what keeps that from being possible.
///
-/// Bounded: a pathologically long field is skipped rather than scanned, so one
-/// agent named with a pasted log cannot make a keystroke cost more than a frame.
+/// ⚠️ **Stops at the first field scoring 64 or better**, exactly as the desktop
+/// does. Every field past the titles is metadata, whose best possible score IS
+/// 64, so an exact, prefix or substring title match already beats anything left
+/// to find. Scanning on would let a later field win ties the desktop gives to
+/// the earlier one, and rank the two apps' lists differently.
({int score, int index})? phoneBestFieldMatch(
- PhoneSearchResult row,
+ PhoneDestination row,
String term,
) {
({int score, int index})? best;
- for (final (index, field) in row.fields.indexed) {
+ for (var i = 0; i < row.fields.length; i++) {
+ final field = row.fields[i];
+ // Bounded: one agent named with a pasted log must not make a keystroke
+ // cost more than a frame.
if (field.length > 4096) continue;
final score = phoneFieldMatchScore(
field,
term,
- title: index < row.titleFields,
+ title: i < row.titleFieldCount,
);
- if (score != null && (best == null || score < best.score)) {
- best = (score: score, index: index);
- }
- // Every field past the title fields is metadata, whose best possible score
- // is 64. An exact, prefix or substring title match already beats that, so
- // once the title fields are behind us there is nothing left to find.
- if (best != null && index >= row.titleFields - 1 && best.score <= 64) {
- break;
- }
+ if (score == null) continue;
+ if (best == null || score < best.score) best = (score: score, index: i);
+ if (best.score <= 64) break;
}
return best;
}
-/// Whether [term] appears, as written, in what was last asked of [row]'s agent
-/// or what it answered — the desktop's content fallback.
-///
-/// Literal only — never the scattered-letter match the fields get. A few turns
-/// of prose contain almost every short run of letters somewhere, so a fuzzy hit
-/// in them would return every agent on the account.
-bool phoneContentHas(PhoneSearchResult row, String term) =>
- row.preview?.searchText.contains(term) ?? false;
-
/// What a word found only in the conversation costs: more than any metadata
/// match can, so an agent that IS "llama" stays ahead of one that talked about
/// it. The desktop's figure.
const _contentScore = 256;
-/// The rows [query] reaches, best first.
-///
-/// An empty query keeps index order untouched: [phoneSearchIndex] already put
-/// the agents in the order worth offering before a word is typed.
+/// The rows [query] reaches, best first — the desktop's `rankSwarmDestinations`.
///
/// A word that matches no field is looked for in the agent's session content —
/// its recent requests, its latest answer, what it is writing right now — which
/// is how "llama" finds the agent somebody asked about llama.cpp. Rows that
-/// needed the content to match rank after every row that matched on the agent
-/// itself, as on the desktop.
+/// needed the content rank after every row that matched on the agent itself.
///
-/// ⚠️ Ties break on the row's position in [all], never on anything that moves
-/// by itself — and [all] is held still for the length of one search by
-/// `PhoneSearchOrder`, so a tie settled on this keystroke is settled the same
-/// way on the next one. A second, unstable tiebreak on top of it would let two
-/// idle rows swap places on an unrelated rebuild.
-List<PhoneSearchResult> rankPhoneSearch(
- List<PhoneSearchResult> all,
- String query,
-) {
+/// ⚠️ **The tie-breaks are the desktop's, in the desktop's order**, with one
+/// deliberate substitution: content, then score, then — only with nothing typed
+/// — the tier below, then how recently the row was OPENED, then [all]'s own
+/// order, and finally the id so two rows can never swap places on a rebuild.
+/// [recent] is the phone's visit history (see [PhoneSearchHistory]).
+///
+/// ⚠️ **The substitution is the last-but-one step: [all]'s order where the
+/// desktop compares names.** The desktop can afford alphabetical there because
+/// by the time it is reached its visit history has already placed almost
+/// everything — it records every pane you focus, over weeks. A phone opened for
+/// the first time has no history at all, so EVERY row fell through to that step
+/// and the box opened on an alphabetical list: `Codex harness 8:16` above the
+/// agent that finished a minute ago. That is not what the desktop looks like,
+/// it is what the desktop's last resort looks like.
+///
+/// [phoneSearchCatalog] hands its agents in [recentAgents] order — waiting on
+/// you, then working, then whose conversation moved last — so deferring to it
+/// puts the phone's best guess where the desktop puts its worst one, and the two
+/// converge on the same list as the history fills.
+///
+/// It is also what keeps the list still. That order is decided when the CATALOG
+/// is built, and the catalog is cached against the shape of the fleet
+/// ([PhoneSearchCatalogCache]) — so a turn event, which moves `lastActiveAt`
+/// every second on a busy machine, does not rebuild it and cannot move a row out
+/// from under a thumb.
+List<PhoneDestination> rankPhoneDestinations(
+ List<PhoneDestination> all,
+ String query, {
+ List<String> recent = const [],
+ SessionPreviewStore? previews,
+}) {
final needle = query.trim().toLowerCase();
- if (needle.isEmpty) return all;
- final terms = phoneSearchTerms(needle);
- if (terms.isEmpty) return all;
-
+ final terms = phoneSearchTerms(query);
+ final recency = {for (var i = 0; i < recent.length; i++) recent[i]: i};
final ranked =
- <({PhoneSearchResult row, int score, bool content, int index})>[];
- for (final (index, row) in all.indexed) {
- // An exact hit on the name — or the title — wins outright, ahead of every
- // scored row. Typing one in full is the least ambiguous thing somebody can do.
- if (row.fields.take(row.titleFields).contains(needle)) {
- ranked.add((row: row, score: -1, content: false, index: index));
+ <({PhoneDestination entry, int score, bool content, int index})>[];
+ for (final (index, entry) in all.indexed) {
+ // An exact hit on the name — or on the agent's own title — wins outright,
+ // ahead of every scored row. Typing one in full is the least ambiguous
+ // thing somebody can do.
+ if (entry.fields.take(entry.titleFieldCount).contains(needle)) {
+ ranked.add((entry: entry, score: -1, content: false, index: index));
continue;
}
- final match = _scoreRow(row, terms);
- if (match == null) continue;
- ranked.add((
- row: row,
- score: match.score,
- content: match.content,
- index: index,
- ));
+ var total = 0;
+ var content = false;
+ String? excerpt;
+ for (final term in terms) {
+ final best = phoneBestFieldMatch(entry, term);
+ if (best == null) {
+ excerpt ??= entry.previewKey == null
+ ? ''
+ : previews?.read(entry.previewKey!)?.searchText ?? '';
+ // Literal only, never the scattered-letter match the fields get: a few
+ // turns of prose contain almost every short run of letters somewhere,
+ // and a fuzzy hit in them would return every agent on the account.
+ if (!excerpt.contains(term)) {
+ total = -1;
+ break;
+ }
+ content = true;
+ total += _contentScore;
+ continue;
+ }
+ total += best.score;
+ }
+ if (total >= 0) {
+ ranked.add((entry: entry, score: total, content: content, index: index));
+ }
}
-
- int byContent(bool content) => content ? 1 : 0;
+ // A group or a command is not something the phone can open, so with nothing
+ // typed it sits under every agent — the desktop's `!hasView` tier.
+ //
+ // ⚠️ **The desktop's third tier, `current`, is deliberately absent.** It
+ // demotes the pane you are looking at, and porting that rule literally
+ // inverted its effect. The desktop's box is always opened with `adding: true`
+ // and so always targets a NEW tab or pane (`swarm_screen.dart`), where nothing
+ // is focused — so `current` almost never fires there, and the agent you came
+ // from ranks near the top: in a live window it sat at rows[2] of 16. A phone's
+ // search is ALWAYS opened from a terminal showing an agent, so the same rule
+ // fired every single time and buried that agent at the bottom.
+ //
+ // Matching the desktop means matching what it does, not what it says. And the
+ // agent you came from is the most recently active one anyway, so the order it
+ // falls into is the one the catalog already wanted.
+ int tier(PhoneDestination e) => !e.isAgent
+ ? 3
+ : recency.containsKey(e.id)
+ ? 0
+ : 1;
ranked.sort((a, b) {
- var order = byContent(a.content).compareTo(byContent(b.content));
+ var order = (a.content ? 1 : 0).compareTo(b.content ? 1 : 0);
if (order == 0) order = a.score.compareTo(b.score);
- return order != 0 ? order : a.index.compareTo(b.index);
- });
- return [for (final row in ranked) row.row];
-}
-
-/// Every term's best score on [row] summed, and whether any needed the session
-/// content — or null when one term matches nothing at all.
-///
-/// One word matching nothing drops the row: the words narrow, they do not
-/// accumulate. Without this, "review mac" would return everything either word
-/// touches.
-({int score, bool content})? _scoreRow(
- PhoneSearchResult row,
- List<String> terms,
-) {
- var total = 0;
- var content = false;
- for (final term in terms) {
- final best = phoneBestFieldMatch(row, term);
- if (best != null) {
- total += best.score;
- continue;
+ if (order == 0 && needle.isEmpty) {
+ order = tier(a.entry).compareTo(tier(b.entry));
}
- if (!phoneContentHas(row, term)) return null;
- content = true;
- total += _contentScore;
- }
- return (score: total, content: content);
+ if (order == 0) {
+ order = (recency[a.entry.id] ?? 999).compareTo(
+ recency[b.entry.id] ?? 999,
+ );
+ }
+ if (order == 0) order = a.index.compareTo(b.index);
+ return order == 0 ? a.entry.id.compareTo(b.entry.id) : order;
+ });
+ return [for (final row in ranked) row.entry];
}
/// The line of [row]'s session content worth quoting under its name: the one
/// holding the first word no field matched, from a little before that word.
///
-/// Null when every word matched the agent itself — the row's own subtitle then
+/// Null when every word matched the agent itself — the row's own detail then
/// says why it is there, and a quote would only be noise.
-String? phoneContentSnippet(PhoneSearchResult row, List<String> terms) {
- final preview = row.preview;
+String? phoneContentSnippet(
+ PhoneDestination row,
+ List<String> terms,
+ SessionPreviewStore? previews,
+) {
+ final key = row.previewKey;
+ final preview = key == null ? null : previews?.read(key);
if (preview == null) return null;
for (final term in terms) {
if (phoneBestFieldMatch(row, term) != null) continue;
diff --git a/mobile/lib/phone/phone_search_results.dart b/mobile/lib/phone/phone_search_results.dart
index ae1976bad..2a2b58d11 100644
--- a/mobile/lib/phone/phone_search_results.dart
+++ b/mobile/lib/phone/phone_search_results.dart
@@ -8,44 +8,41 @@ import 'package:harness_mobile/shared/widgets/empty_state.dart';
import 'package:harness_mobile/state/app_state.dart';
import 'agent_index.dart';
+import 'phone_destination.dart';
import 'phone_navigation.dart';
-import 'phone_search_folder_header.dart';
-import 'phone_search_groups.dart';
-import 'phone_search_index.dart';
-import 'phone_search_order.dart';
+import 'phone_search_commands.dart';
+import 'phone_search_controller.dart';
import 'phone_search_rank.dart';
import 'phone_search_row.dart';
-import 'phone_section_label.dart';
+import 'resume_agent.dart';
-/// What [query] reaches, drawn: the Recent list before a word is typed, then
-/// matching agents under their folders.
+/// What the query reaches, drawn.
///
/// ⚠️ Public because two screens draw it: [PhoneSearchPage], and the terminal's
-/// own in-place search (see `terminal_search.dart`), which expands out of the
-/// header bar rather than pushing a route. Both hand it the query and nothing
-/// else, so the two cannot return different rows — or walk a different pager —
-/// for the same words.
+/// own in-place search (see `terminal_search.dart`), which fades up over the
+/// terminal rather than pushing a route. Both hand it one
+/// [PhoneSearchController], so the two cannot return different rows — or walk a
+/// different pager — for the same words.
///
-/// A word that matches no agent is looked for in what the agents were last
-/// asked and answered — [AppNotifier.sessionPreviews], the desktop's own store.
-/// Keystrokes only ever read it, so typing stays instant and costs no data;
-/// opening the search just moves the agents offered first to the front of its
-/// background reads.
+/// ⚠️ **One flat ranked list, no folder headers.** The desktop has none either,
+/// and grouping fought the ranking it sat on: a folder whose best row was third
+/// dragged its other two up past better matches, and a header over every
+/// single-agent folder halved how many rows fit on a phone. Each row names its
+/// own project and machine instead, which is what the desktop's detail line is.
///
/// Opening it also re-reaches every machine on the account
-/// ([AppNotifier.reachAllMachines]) and pins the rows where they are drawn
-/// ([PhoneSearchOrder]) — the list fills out, and never reorders while it is
-/// being read.
+/// ([AppNotifier.reachAllMachines]), so the one screen that claims to search
+/// every agent stops quietly missing whole machines of them.
class PhoneSearchResults extends StatefulWidget {
const PhoneSearchResults({
super.key,
required this.notifier,
- required this.query,
+ required this.controller,
this.onOpen,
});
final AppNotifier notifier;
- final String query;
+ final PhoneSearchController controller;
/// Called the moment a row is tapped, before anything opens.
///
@@ -60,25 +57,36 @@ class PhoneSearchResults extends StatefulWidget {
}
class _PhoneSearchResultsState extends State<PhoneSearchResults> {
+ /// The row whose agent is being brought back, if any — see [_open].
+ ///
+ /// One at a time: the resume is a round trip to the machine, and a list that
+ /// let a second tap start another would leave two agents restarting for one
+ /// person who only meant to open one.
+ String? _resuming;
+
+ /// ⚠️ **Three sources, and they answer different questions.**
+ ///
+ /// The controller says WHICH rows and in what order. The other two are what
+ /// the rows SAY: `working` replacing an age, a quote appearing as its preview
+ /// lands, an attention rim as an agent stops to ask something. The controller
+ /// deliberately stays quiet through all of that — its catalog is cached, and a
+ /// turn event changes no row's place — so without these the list would hold a
+ /// minutes-old age while the terminal behind it streamed.
late final Listenable _changes = Listenable.merge([
+ widget.controller,
widget.notifier,
widget.notifier.sessionPreviews,
]);
- /// Holds the rows where they were first drawn — see [PhoneSearchOrder]. Owned
- /// by the State, so it lives exactly as long as one search.
- final _order = PhoneSearchOrder();
-
@override
void initState() {
super.initState();
final notifier = widget.notifier;
// ⚠️ **Opening the search is what re-reaches the fleet.** Until here the app
// has only the machines that happened to answer at launch, and a machine the
- // account reported down was never even dialled — so the one screen that
- // claims to search EVERY agent was the one screen quietly missing whole
- // machines of them. Asked on the way in, not awaited: what is already known
- // draws immediately, and each machine adds its agents as it answers.
+ // account reported down was never even dialled. Asked on the way in, not
+ // awaited: what is already known draws immediately, and each machine adds
+ // its agents as it answers.
unawaited(notifier.reachAllMachines());
notifier.sessionPreviews.warm([
for (final entry in recentAgents(agentIndex(notifier)))
@@ -91,122 +99,139 @@ class _PhoneSearchResultsState extends State<PhoneSearchResults> {
listenable: _changes,
builder: (context, _) {
AppTheme.watch(context);
- final all = _order.arrange(phoneSearchIndex(widget.notifier));
- if (all.isEmpty) {
- return const EmptyState(
- icon: LucideIcons.laptopMinimal300,
- title: 'Nothing to search yet',
- message: 'Link a machine and its agents will be findable from here.',
- );
- }
- final query = widget.query.trim();
- if (query.isEmpty) return _recentList(all);
- final rows = rankPhoneSearch(all, query);
- if (rows.isEmpty) {
- return EmptyState.noMatches(
- compact: false,
- message: 'Nothing matches “$query”.',
- );
- }
- return _groupedList(phoneSearchGroups(rows), phoneSearchTerms(query));
- },
- );
-
- /// Every agent in one run, the one that had moved last WHEN THE SEARCH OPENED
- /// on top — and still on top a minute later, whatever has moved since. See
- /// [PhoneSearchOrder].
- ///
- /// No folder headers here. Before a word is typed the question is "which one
- /// was I just on", and grouping answers a different one: a folder with one
- /// fresh agent and one stale one drags the stale one up past fresher agents
- /// elsewhere, and a header over every single-agent folder halves how many
- /// rows fit on the screen. Each row names its own folder and machine instead.
- Widget _recentList(List<PhoneSearchResult> rows) {
- final now = DateTime.now();
- return _ResultsList(
- children: [
- const PhoneSectionLabel(
- 'Recent',
- padding: EdgeInsets.fromLTRB(10, 14, 10, 4),
+ final search = widget.controller;
+ final rows = search.rows;
+ if (rows.isEmpty) return _empty(search);
+ final terms = phoneSearchTerms(search.matchQuery);
+ final now = DateTime.now();
+ final previews = widget.notifier.sessionPreviews;
+ return ListView.builder(
+ // The keyboard is up and the finger is already on the glass; dragging
+ // the list is how somebody reaches a result without putting it away
+ // first.
+ keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
+ padding: EdgeInsets.fromLTRB(
+ 16,
+ 4,
+ 16,
+ MediaQuery.paddingOf(context).bottom + 16,
),
- for (final row in rows)
- PhoneSearchRow(
+ itemCount: rows.length,
+ itemBuilder: (context, index) {
+ final row = rows[index];
+ return PhoneSearchRow(
row: row,
- terms: const [],
+ terms: terms,
now: now,
- place: PhoneRowContext.placed,
- onTap: () => _open(rows, row),
- ),
- ],
+ openable: search.canSubmit(row) && _resuming == null,
+ resuming: _resuming == row.id,
+ // A row that is here for something said in its conversation quotes
+ // it in place of its detail: nothing else on the row would explain
+ // why it matched.
+ quote: phoneContentSnippet(row, terms, previews),
+ onTap: () => _tap(row),
+ );
+ },
+ );
+ },
+ );
+
+ Widget _empty(PhoneSearchController search) {
+ if (search.total == 0 && search.matchQuery.trim().isEmpty) {
+ return const EmptyState(
+ icon: LucideIcons.laptopMinimal300,
+ title: 'Nothing to search yet',
+ message: 'Link a machine and its agents will be findable from here.',
+ );
+ }
+ return EmptyState.noMatches(
+ compact: false,
+ message: 'Nothing matches “${search.matchQuery.trim()}”.',
);
}
- /// Matching agents under their folders, best match first — see
- /// [phoneSearchGroups] for why grouping never buries it.
- Widget _groupedList(List<PhoneSearchGroup> groups, List<String> terms) {
- final drawn = phoneSearchGroupedRows(groups);
- final now = DateTime.now();
- return _ResultsList(
- children: [
- for (final group in groups) ...[
- PhoneSearchFolderHeader(group: group),
- for (final row in group.rows)
- PhoneSearchRow(
- row: row,
- terms: terms,
- now: now,
- onTap: () => _open(drawn, row),
- ),
- ],
- ],
- );
+ /// A tap goes to the controller first, which absorbs the ones that only move
+ /// the search: a `?` row taking its mode, a project or machine narrowing it.
+ /// What comes back is something to actually open.
+ void _tap(PhoneDestination row) {
+ final opened = widget.controller.submit(row);
+ if (opened == null) return;
+ if (opened.isCommand) {
+ widget.onOpen?.call();
+ _run(opened);
+ return;
+ }
+ final entry = opened.entry;
+ if (entry == null) return;
+ if (entry.agent.isStopped) {
+ unawaited(_resumeThenOpen(opened.id, entry));
+ return;
+ }
+ _openAgent(entry);
}
- /// Opens the agent as a pager over the OTHER rows on screen.
+ /// Bring a stopped agent back, then open it — the desktop's
+ /// `_resumeStoppedDestination` followed by its activation.
///
- /// The neighbours are the rows as drawn, not the Agents tab's list: swiping
- /// walks exactly what the query returned, in the order the person was looking
- /// at when they tapped. Handing it the unfiltered index instead would swipe
- /// into agents the query had just excluded.
- ///
- /// ⚠️ [drawn] is the order ON SCREEN — for the grouped list, not the ranked
- /// rows. Grouping pulls a folder's rows together, so the ranked list can hold
- /// a different agent at any given index than the screen does.
- void _open(List<PhoneSearchResult> drawn, PhoneSearchResult row) {
+ /// ⚠️ **Awaited before the terminal is pushed, not alongside it.** A stopped
+ /// agent has no terminal to attach to, so opening first would land on a screen
+ /// with nothing on it and no reason given. The row says `Stopped`, then spins,
+ /// then the terminal arrives.
+ Future<void> _resumeThenOpen(String id, AgentEntry entry) async {
+ setState(() => _resuming = id);
+ final error = await resumeAgentForOpen(widget.notifier, entry);
+ if (!mounted) return;
+ setState(() => _resuming = null);
+ if (error != null) {
+ ScaffoldMessenger.maybeOf(
+ context,
+ )?.showSnackBar(SnackBar(content: Text(error)));
+ return;
+ }
+ // ⚠️ Re-read from the catalog rather than reusing `entry`. The resume
+ // replaced the agent in its machine's list (`_upsertAgent`), so the entry
+ // captured before the await names a terminal that is still the old one.
+ final resumed = widget.controller.rows
+ .where((row) => row.id == id)
+ .firstOrNull
+ ?.entry;
+ _openAgent(resumed ?? entry);
+ }
+
+ void _openAgent(AgentEntry entry) {
widget.onOpen?.call();
- final entry = row.entry;
- if (entry == null || !entry.agent.terminalAvailable) return;
- // ⚠️ Built from [phoneSearchAgentEntries] rather than by unwrapping each
- // row here. A `?result.entry` collapse would silently SHORTEN this list if
- // an agent row ever arrived without its entry, and the pager walks it by
- // index — a shorter list than the one on screen sends a swipe to the wrong
- // agent, with nothing on screen to explain why.
+ // The neighbours are the rows as drawn, not the Agents tab's list: swiping
+ // walks exactly what the query returned, in the order the person was
+ // looking at when they tapped.
openAgentPager(
context,
widget.notifier,
- phoneSearchAgentEntries(drawn),
+ phoneSearchAgentEntries(widget.controller.rows),
entry,
);
}
-}
-
-/// The scrolling list both layouts share.
-class _ResultsList extends StatelessWidget {
- const _ResultsList({required this.children});
-
- final List<Widget> children;
- @override
- Widget build(BuildContext context) => ListView(
- // The keyboard is up and the finger is already on the glass; dragging the
- // list is how somebody reaches a result without putting it away first.
- keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
- padding: EdgeInsets.fromLTRB(
- 16,
- 0,
- 16,
- MediaQuery.paddingOf(context).bottom + 16,
- ),
- children: children,
- );
+ void _run(PhoneDestination row) {
+ final id = row.commandId;
+ if (id == null) return;
+ for (final command in widget.controller.commands?.call() ??
+ const <PhoneCommand>[]) {
+ if (command.id != id) continue;
+ unawaited(Future.sync(command.run));
+ return;
+ }
+ }
}
+
+/// The agent rows among [rows], in the order they are drawn — what a pager
+/// opened from one of them swipes along.
+///
+/// ⚠️ **One entry out, one agent row in.** [PhoneDestination.entry] is null on
+/// every other kind, so unwrapping it at the call site invites a null-collapse
+/// that quietly drops a row. The pager walks this list BY INDEX against the rows
+/// on screen: a list one shorter than the one somebody tapped sends the next
+/// swipe to a different agent than the one beside it.
+List<AgentEntry> phoneSearchAgentEntries(List<PhoneDestination> rows) => [
+ for (final row in rows)
+ if (row.isAgent && row.entry != null) row.entry!,
+];
diff --git a/mobile/lib/phone/phone_search_row.dart b/mobile/lib/phone/phone_search_row.dart
index bf4cbd84f..e0fe5ed1a 100644
--- a/mobile/lib/phone/phone_search_row.dart
+++ b/mobile/lib/phone/phone_search_row.dart
@@ -1,72 +1,61 @@
import 'package:flutter/material.dart';
-import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
-import 'package:harness_mobile/widgets/engine_identity.dart';
-import 'phone_search_index.dart';
-import 'phone_search_rank.dart';
+import 'phone_destination.dart';
+import 'phone_prompt_context.dart';
import 'phone_search_row_trailing.dart';
-import 'phone_status.dart';
import 'search_result_text.dart';
-import 'status_pill.dart';
-/// How much of where an agent lives the row has to say for itself, which is
-/// decided by what the list draws ABOVE it.
+/// One result: the name, and under it where the thing lives.
///
-/// One enum rather than a second boolean beside [PhoneSearchRow.placed] was:
-/// the three cases are exclusive, and a row that answered to two flags could be
-/// asked to repeat the machine its header just named.
-enum PhoneRowContext {
- /// A folder header over the row names both the folder and the machine, so the
- /// row's second line is free for what tells its agents apart.
- grouped(),
-
- /// Nothing above the row places it: it names its own work, folder and
- /// machine. The search's Recent run.
- placed(),
-
- /// A machine header over the row names the machine and nothing else, so the
- /// row still owes the folder. [AgentsListPage].
- machined();
-
- const PhoneRowContext();
-
- /// The line this context asks [row] for.
- String subtitleOf(PhoneSearchResult row) => switch (this) {
- PhoneRowContext.grouped => row.subtitle,
- PhoneRowContext.placed => row.placedSubtitle,
- PhoneRowContext.machined => row.machinedSubtitle,
- };
-}
-
-/// One result: the mark, the two lines, and what is worth knowing before a tap.
+/// The desktop's `_SearchRowContent` in its `stacked` form, which is not a
+/// concession — the desktop stacks whenever its result column is under 700px
+/// (`swarm_switcher.dart`), and a phone always is. Everything else is the
+/// desktop's: the name set in the terminal's own face, and under it the identity
+/// line drawn as segments with their own glyphs rather than written out as
+/// `Codex · work · box`.
///
-/// Shorter than the tabs' 70pt [PhoneCard] and without its fill. A result list
-/// is read top to bottom against a query and abandoned the moment the right row
-/// is seen, so it is built for scanning: more rows in a thumb's reach, and the
-/// emphasis carried by the bolded match rather than by a card edge.
+/// ⚠️ **No leading mark and no trailing age.** Both were the phone's own, and
+/// both are what made the two lists look like different features. The engine is
+/// said by `>_ Claude` at the head of the identity line, exactly where the
+/// desktop says it; a machine or a project says its kind in its own detail.
class PhoneSearchRow extends StatefulWidget {
const PhoneSearchRow({
super.key,
required this.row,
required this.terms,
required this.now,
+ required this.openable,
required this.onTap,
- this.place = PhoneRowContext.grouped,
+ this.quote,
+ this.resuming = false,
});
- final PhoneSearchResult row;
+ final PhoneDestination row;
final List<String> terms;
/// One clock for the whole list, so two rows built a frame apart cannot
- /// disagree about what "4m" means.
+ /// disagree about what a row says. Only reached for on a row that cannot be
+ /// opened — see [PhoneSearchTrailing].
final DateTime now;
+
+ /// Whether a tap can do anything — the controller's `canSubmit`. A row that
+ /// cannot is dimmed with the reason on its trailing edge rather than hidden:
+ /// an agent whose terminal has gone is still the answer to "where did it go".
+ final bool openable;
+
final VoidCallback onTap;
- /// How much of where the agent lives this row still owes — see
- /// [PhoneRowContext], which is decided by the header the list draws over it.
- final PhoneRowContext place;
+ /// Whether this row's agent is being brought back right now, so the trailing
+ /// edge spins instead of repeating `Stopped` at somebody already waiting.
+ final bool resuming;
+
+ /// The line of session content that explains a row nothing else on it would:
+ /// see [phoneContentSnippet]. Replaces the identity line when there is one,
+ /// because a row matched on something said in its conversation has nothing on
+ /// it that says why.
+ final String? quote;
@override
State<PhoneSearchRow> createState() => _PhoneSearchRowState();
@@ -75,20 +64,8 @@ class PhoneSearchRow extends StatefulWidget {
class _PhoneSearchRowState extends State<PhoneSearchRow> {
bool _pressed = false;
- /// An agent whose terminal has gone cannot be opened, the same rule
- /// [AgentRow] applies. A machine opens unless it is offline — a locked one
- /// opens on its password form, which is the thing to do about it, but a
- /// switched-off one has nothing to take a password.
- bool get _openable => switch (widget.row.kind) {
- PhoneSearchKind.agent => widget.row.entry?.agent.terminalAvailable ?? false,
- PhoneSearchKind.machine =>
- widget.row.machine == null ||
- phoneMachineStatusOf(widget.row.machine!) !=
- PhoneMachineStatus.offline,
- };
-
void _press(bool pressed) {
- if (!_openable || _pressed == pressed) return;
+ if (!widget.openable || _pressed == pressed) return;
setState(() => _pressed = pressed);
}
@@ -104,64 +81,49 @@ class _PhoneSearchRowState extends State<PhoneSearchRow> {
AppTheme.watch(context);
final row = widget.row;
final matches = phoneResultMatches(row, widget.terms);
- // A row that is here for something said in its conversation quotes it in
- // place of its subtitle: nothing else on the row would explain the match.
- final quote = phoneContentSnippet(row, widget.terms);
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: (_) => _press(true),
onTapUp: (_) => _press(false),
onTapCancel: () => _press(false),
- onTap: _openable ? _open : null,
+ onTap: widget.openable ? _open : null,
child: AnimatedContainer(
duration: AppMotion.press,
curve: AppMotion.curve,
- height: 58,
- padding: const EdgeInsets.symmetric(horizontal: 10),
+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 9),
decoration: BoxDecoration(
- // No resting fill. The tabs' cards earn one because they are the
- // screen's content; a result row is a line of an answer, and forty of
- // them each in their own box is a wall rather than a list.
+ // No resting fill. The desktop's picker has none either: forty rows
+ // each in their own box is a wall rather than a list.
color: _pressed ? AppGlass.rowFill : Colors.transparent,
borderRadius: BorderRadius.circular(AppCard.radius),
),
child: Opacity(
- opacity: _openable ? 1 : 0.55,
+ opacity: widget.openable ? 1 : 0.55,
child: Row(
children: [
- _Mark(row: row),
- const SizedBox(width: 12),
Expanded(
child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SearchResultText(
row.title,
- matches: matches,
- style: TextStyle(
+ matches: matches.where((match) => match.title),
+ style: phoneBoxMonoStyle(
+ size: 14,
color: AppPalette.textPrimary,
- fontSize: 15.5,
- fontWeight: FontWeight.w600,
+ weight: FontWeight.w500,
),
),
const SizedBox(height: 3),
- SearchResultText(
- quote ?? widget.place.subtitleOf(row),
- matches: quote == null
- ? matches
- : phoneContentMatches(widget.terms),
- style: TextStyle(
- color: AppPalette.textFaint,
- fontSize: 12.5,
- ),
- ),
+ _detail(row, matches),
],
),
),
PhoneSearchTrailing(
row: row,
- openable: _openable,
+ openable: widget.openable,
+ resuming: widget.resuming,
now: widget.now,
),
],
@@ -170,45 +132,33 @@ class _PhoneSearchRowState extends State<PhoneSearchRow> {
),
);
}
-}
-
-/// The square mark at the head of a result: an agent's engine, a machine's
-/// screen. Smaller than the tabs' 44pt [PhoneCardGlyph], to match the shorter
-/// row.
-class _Mark extends StatelessWidget {
- const _Mark({required this.row});
- final PhoneSearchResult row;
-
- @override
- Widget build(BuildContext context) {
- AppTheme.watch(context);
- return Container(
- width: 36,
- height: 36,
- decoration: BoxDecoration(
- color: AppSurface.recess,
- borderRadius: BorderRadius.circular(10),
- // The same attention rim the Agents tab puts on a waiting row, so an
- // agent that has stopped to ask something is findable here too.
- border: row.entry?.isWaiting ?? false
- ? Border.all(color: AppPalette.warn.withValues(alpha: 0.42))
- : null,
- ),
- child: Center(
- child: switch (row.kind) {
- PhoneSearchKind.agent => EngineMark(
- engine: row.entry?.agent.engine,
- displayName: row.entry?.agent.engineDisplayName,
- size: 18,
- ),
- PhoneSearchKind.machine => Icon(
- LucideIcons.laptopMinimal300,
- size: 18,
- color: phoneToneColor(row.summary.tone),
- ),
- },
- ),
+ /// The identity line, or what stands in for it.
+ ///
+ /// Three cases, in the desktop's own order of preference: a quote from the
+ /// conversation when that is why the row is here, the drawn identity when the
+ /// row has one, and otherwise the plain detail a group or a command carries.
+ Widget _detail(PhoneDestination row, List<PhoneFieldMatch> matches) {
+ final quote = widget.quote;
+ if (quote != null) {
+ return SearchResultText(
+ quote,
+ matches: phoneContentMatches(widget.terms),
+ style: phoneBoxMonoStyle(size: 12, color: AppPalette.textFaint),
+ );
+ }
+ final identity = row.promptContext;
+ if (identity != null) {
+ return PhonePromptContextView(
+ contextData: identity,
+ matches: matches.where((match) => !match.title),
+ );
+ }
+ if (row.detail.isEmpty) return const SizedBox.shrink();
+ return SearchResultText(
+ row.detail,
+ matches: matches.where((match) => !match.title),
+ style: phoneBoxMonoStyle(size: 12, color: AppPalette.textFaint),
);
}
}
diff --git a/mobile/lib/phone/phone_search_row_trailing.dart b/mobile/lib/phone/phone_search_row_trailing.dart
index 9576d1ef3..6242789e9 100644
--- a/mobile/lib/phone/phone_search_row_trailing.dart
+++ b/mobile/lib/phone/phone_search_row_trailing.dart
@@ -2,83 +2,91 @@ import 'package:flutter/material.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
-import 'compact_age.dart';
-import 'phone_search_index.dart';
+import 'phone_destination.dart';
import 'phone_status.dart';
-import 'status_pill.dart';
-/// A search row's trailing edge: why it cannot be opened, or else how fresh it
-/// is.
+/// A search row's trailing edge: why it cannot be opened, and nothing else.
///
-/// An agent that opens says when its conversation last moved — `4m` — or that
-/// it is `working` right now, which is what explains a row sorted above a
-/// fresher one. Unboxed and faint: it is read after the name, never instead.
+/// ⚠️ **The age is gone, on purpose.** The row used to end in `19h` or
+/// `working`, and the desktop's picker ends in nothing — it puts recency in the
+/// ordering instead, which the phone now does too. Two lists that hold the same
+/// rows should not end differently.
///
-/// A boxed word is kept for what a tap would NOT make obvious: a machine's
+/// What survives is the one thing a tap would NOT make obvious: a machine's
/// Unlock or Offline, and an agent whose terminal has gone. Dimming alone leaves
-/// the person tapping a row that cannot answer and reading nothing about why.
+/// somebody tapping a row that cannot answer and reading nothing about why. The
+/// desktop says the same thing in the line under its box, which a phone has no
+/// room for.
class PhoneSearchTrailing extends StatelessWidget {
const PhoneSearchTrailing({
super.key,
required this.row,
required this.openable,
required this.now,
+ this.resuming = false,
});
- final PhoneSearchResult row;
+ final PhoneDestination row;
final bool openable;
+
+ /// Whether the agent is being restarted right now — see
+ /// `PhoneSearchResults._resumeThenOpen`.
+ final bool resuming;
+
final DateTime now;
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
+ if (resuming) return const _Spinner();
final badge = _badge;
- if (badge != null) return _Badge(badge);
- final entry = row.entry;
- if (entry == null) return const SizedBox.shrink();
- if (entry.isWorking) {
- return _Recency('working', color: phoneToneColor(PhoneTone.busy));
- }
- final at = entry.lastActiveAt;
- if (at == null) return const SizedBox.shrink();
- return _Recency(compactAge(at, now), color: AppPalette.textFaint);
+ return badge == null ? const SizedBox.shrink() : _Badge(badge);
}
String? get _badge {
final machine = row.machine;
return switch (row.kind) {
- PhoneSearchKind.agent => openable ? null : 'No terminal',
- PhoneSearchKind.machine => switch (machine == null
+ PhoneDestinationKind.agent => !openable
+ ? 'No terminal'
+ // Saved work, not a dead row: the tap restarts it and opens it. Said
+ // plainly because the wait that follows is a second or two of nothing.
+ : row.entry?.agent.isStopped == true
+ ? 'Stopped'
+ : null,
+ PhoneDestinationKind.machine => switch (machine == null
? null
: phoneMachineStatusOf(machine)) {
PhoneMachineStatus.offline => 'Offline',
PhoneMachineStatus.needsPassword => 'Unlock',
- // Its state, not a verb: the tap brings a sheet of actions, and "View"
- // promised a screen that is no longer there.
- _ => 'Connected',
+ _ => null,
},
+ // A group says its size in its own detail line ("Project · 3 harnesses"),
+ // and a command has nothing to be fresh about.
+ _ => null,
};
}
}
-class _Recency extends StatelessWidget {
- const _Recency(this.text, {required this.color});
-
- final String text;
- final Color color;
+/// The wait between tapping stopped work and its terminal arriving. Sized to
+/// the badge it replaces, so the row does not reflow when it appears.
+class _Spinner extends StatelessWidget {
+ const _Spinner();
@override
- Widget build(BuildContext context) => Padding(
- padding: const EdgeInsets.only(left: 8),
- child: Text(
- text,
- style: TextStyle(
- color: color,
- fontSize: 12,
- fontFeatures: AppFont.tabularFigures,
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return Padding(
+ padding: const EdgeInsets.only(left: 8),
+ child: SizedBox(
+ width: 13,
+ height: 13,
+ child: CircularProgressIndicator(
+ strokeWidth: 1.6,
+ color: AppPalette.textFaint,
+ ),
),
- ),
- );
+ );
+ }
}
class _Badge extends StatelessWidget {
diff --git a/mobile/lib/phone/phone_search_scope_bar.dart b/mobile/lib/phone/phone_search_scope_bar.dart
new file mode 100644
index 000000000..5108cf71f
--- /dev/null
+++ b/mobile/lib/phone/phone_search_scope_bar.dart
@@ -0,0 +1,71 @@
+import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+
+import 'phone_search_controller.dart';
+
+/// The line between the field and the results: what is being searched, and how
+/// much of it the query has left.
+///
+/// The desktop's box title and its `4/7`. The count is the quickest answer to
+/// "did that narrow it, or is it just not here?", and on the phone the title is
+/// also the only thing that says a mode is open at all — there is no box chrome
+/// around the list to carry it.
+///
+/// Absent on a plain empty query, where the list IS the answer and a header over
+/// it would cost a row.
+class PhoneSearchScopeBar extends StatelessWidget {
+ const PhoneSearchScopeBar({super.key, required this.search});
+
+ final PhoneSearchController search;
+
+ @override
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: search,
+ builder: (context, _) {
+ AppTheme.watch(context);
+ final scoped = search.canGoBack;
+ final typed = search.matchQuery.trim().isNotEmpty;
+ if (!scoped && !typed && search.title == 'Search') {
+ return const SizedBox.shrink();
+ }
+ final faint = TextStyle(color: AppPalette.textFaint, fontSize: 12);
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(26, 6, 26, 6),
+ child: Row(
+ children: [
+ if (scoped) ...[
+ Icon(
+ LucideIcons.cornerDownRight300,
+ size: 13,
+ color: AppPalette.textFaint,
+ ),
+ const SizedBox(width: 6),
+ ],
+ Flexible(
+ child: Text(
+ search.title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: faint.copyWith(
+ color: AppPalette.textSecondary,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ const Spacer(),
+ Text(
+ // Only once the query has actually excluded something: `7/7`
+ // over an untouched list is noise dressed as information.
+ search.matchCount == search.total
+ ? '${search.total}'
+ : '${search.matchCount}/${search.total}',
+ style: faint.copyWith(fontFeatures: AppFont.tabularFigures),
+ ),
+ ],
+ ),
+ );
+ },
+ );
+}
diff --git a/mobile/lib/phone/resume_agent.dart b/mobile/lib/phone/resume_agent.dart
new file mode 100644
index 000000000..0f047b927
--- /dev/null
+++ b/mobile/lib/phone/resume_agent.dart
@@ -0,0 +1,68 @@
+import 'dart:async';
+
+import 'package:harness_mobile/state/app_state.dart';
+
+import 'agent_index.dart';
+
+/// How long to wait for a resumed agent's terminal to be reported before giving
+/// up and saying so.
+///
+/// The restart itself has already succeeded by then; this is the machine
+/// allocating a pty and the daemon pushing the agent back. Long enough for a
+/// cold engine on a phone's connection, short enough that a person who is going
+/// to be told "try again" is not left holding a spinner.
+const _terminalWait = Duration(seconds: 12);
+
+/// Bring stopped work back, and return only once something can be opened on it.
+///
+/// Returns null on success, or the message to show.
+///
+/// ⚠️ **The wait is the point, not the restart.** The desktop does the same in
+/// `_resumeStoppedDestination`: it sends the lifecycle command and then races
+/// the reply against an observer watching for `terminalAvailable`, because the
+/// RPC returning does not mean there is a pty yet. Opening the pager on an agent
+/// that has not got one lands on an empty screen — worse, the phone's pager
+/// filters its pages to agents WITH terminals (`agent_swipe_list.dart`), so the
+/// swipe would silently open a different agent than the row that was tapped.
+///
+/// Shared by the search and the Agents list so the two cannot disagree about
+/// what tapping stopped work does.
+Future<String?> resumeAgentForOpen(
+ AppNotifier notifier,
+ AgentEntry entry,
+) async {
+ final result = await notifier.resumeAgent(entry.machineId, entry.agent.id);
+ if (result.error case final error?) return error;
+ if (_openable(notifier, entry)) return null;
+
+ final ready = Completer<bool>();
+ void check() {
+ if (ready.isCompleted) return;
+ if (_openable(notifier, entry)) ready.complete(true);
+ }
+
+ notifier.addListener(check);
+ Timer? timeout;
+ try {
+ timeout = Timer(_terminalWait, () {
+ if (!ready.isCompleted) ready.complete(false);
+ });
+ // Checked once more after subscribing: the agent can land between the test
+ // above and the listener going on, and nothing would fire again.
+ check();
+ if (await ready.future) return null;
+ } finally {
+ timeout?.cancel();
+ notifier.removeListener(check);
+ }
+ return 'Resumed, but its terminal has not come back yet. Try again in a moment.';
+}
+
+bool _openable(AppNotifier notifier, AgentEntry entry) =>
+ notifier
+ .stateOf(entry.machineId)
+ ?.agents
+ .where((agent) => agent.id == entry.agent.id)
+ .firstOrNull
+ ?.terminalAvailable ??
+ false;
diff --git a/mobile/lib/phone/search_result_text.dart b/mobile/lib/phone/search_result_text.dart
index 7a475ec18..7d24461ce 100644
--- a/mobile/lib/phone/search_result_text.dart
+++ b/mobile/lib/phone/search_result_text.dart
@@ -2,15 +2,16 @@ import 'package:flutter/widgets.dart';
import 'package:harness_mobile/core/fuzzy_match.dart';
-import 'phone_search_index.dart';
+import 'phone_destination.dart';
import 'phone_search_rank.dart';
-/// Which field earned each query term its score, and whether that field is the
-/// row's title.
+/// Which field earned each query term its score, and whether that field is one
+/// of the row's names.
typedef PhoneFieldMatch = ({String field, String term, bool title});
/// [terms] as matches on a content quote (see [phoneContentSnippet]): each term
-/// is its own field, so the emphasis lands on the word wherever the quote holds it.
+/// is its own field, so the emphasis lands on the word wherever the quote holds
+/// it.
List<PhoneFieldMatch> phoneContentMatches(List<String> terms) => [
for (final term in terms.take(12).toSet())
(field: term, term: term, title: false),
@@ -22,7 +23,7 @@ List<PhoneFieldMatch> phoneContentMatches(List<String> terms) => [
/// bounded by what is on screen, and keeping it out of the ranking path means
/// scrolling never pays for emphasis it has already drawn.
List<PhoneFieldMatch> phoneResultMatches(
- PhoneSearchResult row,
+ PhoneDestination row,
List<String> terms,
) {
final matches = <PhoneFieldMatch>[];
@@ -35,7 +36,7 @@ List<PhoneFieldMatch> phoneResultMatches(
matches.add((
field: row.fields[best.index],
term: term,
- title: best.index < row.titleFields,
+ title: best.index < row.titleFieldCount,
));
}
return matches;
@@ -75,8 +76,8 @@ List<PhoneTextRun> phoneTextRuns(
folded.write(lower);
}
final normalized = folded.toString();
-
final positions = <({int start, int end})>[];
+
for (final match in matches) {
// A row can match on a field it never draws — an engine id, a project path.
// Emphasising something in unrelated text because of it would be a lie about
@@ -137,16 +138,27 @@ class SearchResultText extends StatelessWidget {
super.key,
required this.matches,
required this.style,
+ this.inlineIcon,
+ this.iconOffset = 0,
});
final String text;
final Iterable<PhoneFieldMatch> matches;
final TextStyle style;
+ /// A decorative mark dropped into the line — the branch glyph — without
+ /// changing the searchable text or moving a single match offset. The desktop
+ /// puts its git fork here for the same reason: a branch that reads as a
+ /// branch costs a glyph, and spelling out "branch" costs a phone's whole width.
+ final Widget? inlineIcon;
+ final int iconOffset;
+
@override
Widget build(BuildContext context) {
final runs = phoneTextRuns(text, matches);
- if (!runs.any((run) => run.matched)) {
+ final insertIcon =
+ inlineIcon != null && iconOffset >= 0 && iconOffset < text.length;
+ if (!insertIcon && !runs.any((run) => run.matched)) {
return Text(
text,
maxLines: 1,
@@ -154,18 +166,41 @@ class SearchResultText extends StatelessWidget {
style: style,
);
}
- return Text.rich(
- TextSpan(
- children: [
- for (final run in runs)
- TextSpan(
- text: run.text,
- style: run.matched
- ? const TextStyle(fontWeight: FontWeight.w700)
- : null,
+ final spans = <InlineSpan>[];
+ var offset = 0;
+ for (final run in runs) {
+ final emphasis = run.matched
+ ? const TextStyle(fontWeight: FontWeight.w700)
+ : null;
+ if (insertIcon &&
+ iconOffset >= offset &&
+ iconOffset < offset + run.text.length) {
+ final split = iconOffset - offset;
+ if (split > 0) {
+ spans.add(
+ TextSpan(text: run.text.substring(0, split), style: emphasis),
+ );
+ }
+ spans.add(
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: ExcludeSemantics(
+ child: Padding(
+ padding: const EdgeInsets.only(right: 4),
+ child: inlineIcon!,
+ ),
),
- ],
- ),
+ ),
+ );
+ spans.add(TextSpan(text: run.text.substring(split), style: emphasis));
+ } else {
+ spans.add(TextSpan(text: run.text, style: emphasis));
+ }
+ offset += run.text.length;
+ }
+ return Text.rich(
+ TextSpan(children: spans),
+ semanticsLabel: insertIcon ? text : null,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: style,
diff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dart
index acc703e37..f5911a2bc 100644
--- a/mobile/lib/phone/terminal_search.dart
+++ b/mobile/lib/phone/terminal_search.dart
@@ -3,8 +3,11 @@ import 'package:flutter/material.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/state/app_state.dart';
+import 'phone_search_actions.dart';
+import 'phone_search_controller.dart';
import 'phone_search_field.dart';
import 'phone_search_results.dart';
+import 'phone_search_scope_bar.dart';
/// Search, opened in place over a terminal rather than pushed as a page.
///
@@ -54,15 +57,38 @@ class TerminalSearchOverlay extends StatefulWidget {
class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {
final _controller = TextEditingController();
final _focus = FocusNode(debugLabel: 'Terminal search');
- String _query = '';
+ late final PhoneSearchController _search = PhoneSearchController(
+ notifier: widget.notifier,
+ history: widget.notifier.searchHistory,
+ commands: () => phoneSearchCommands(context, widget.notifier),
+ );
+
+ @override
+ void initState() {
+ super.initState();
+ widget.notifier.searchHistory.load().then((_) {
+ if (mounted) _search.setQuery(_search.query);
+ });
+ }
@override
void dispose() {
_controller.dispose();
_focus.dispose();
+ _search.dispose();
super.dispose();
}
+ /// Back leaves the chosen project or machine first, and only then the search —
+ /// the same step `#`/`@` took to get in.
+ void _back() {
+ if (_search.back()) {
+ _controller.text = _search.query;
+ return;
+ }
+ _close();
+ }
+
/// ⚠️ Drops the keyboard BEFORE handing back, so the terminal underneath does
/// not inherit an inset that belongs to this field. The page's own keyboard
/// tracking reads the inset, not the focus, and would otherwise come back
@@ -80,7 +106,7 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {
// still underneath, and this is what is covering it.
canPop: false,
onPopInvokedWithResult: (didPop, _) {
- if (!didPop) _close();
+ if (!didPop) _back();
},
// ⚠️ No [ListenableBuilder] around this any more. [PhoneSearchResults]
// watches the notifier itself — and its recall store with it — so a
@@ -92,27 +118,32 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {
color: AppPalette.windowBg,
child: Column(
children: [
- PhoneSearchField(
- controller: _controller,
- focus: _focus,
- onChanged: (value) => setState(() => _query = value),
- onClear: () {
- _controller.clear();
- setState(() => _query = '');
- // Clearing is a step back into browsing, not out of the
- // search — the caret stays where the next query will go.
- _focus.requestFocus();
- },
- onBack: _close,
+ ListenableBuilder(
+ listenable: _search,
+ builder: (context, _) => PhoneSearchField(
+ controller: _controller,
+ focus: _focus,
+ hintText: _search.hint,
+ onChanged: _search.setQuery,
+ onClear: () {
+ _controller.clear();
+ _search.setQuery('');
+ // Clearing is a step back into browsing, not out of the
+ // search — the caret stays where the next query will go.
+ _focus.requestFocus();
+ },
+ onBack: _back,
+ ),
),
Divider(height: 1, color: AppGlass.hair),
+ PhoneSearchScopeBar(search: _search),
// ⚠️ Handed the query and nothing else. Ranking lives inside it,
// so this screen and [PhoneSearchPage] cannot drift into
// returning different rows for the same words.
Expanded(
child: PhoneSearchResults(
notifier: widget.notifier,
- query: _query,
+ controller: _search,
// ⚠️ Nothing pops this search — opening an agent swaps the
// terminal underneath it instead — so tapping a row has to
// close it by hand. Without this the keyboard would still be
diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dart
index c151fc7d7..b999175b9 100644
--- a/mobile/lib/state/app_state.dart
+++ b/mobile/lib/state/app_state.dart
@@ -24,6 +24,7 @@ import '../core/engine_availability.dart';
import '../core/local_hostname.dart';
import '../core/local_git_projects.dart';
import '../core/last_opened_agent.dart';
+import '../core/phone_search_history.dart';
import '../core/machine_cache.dart';
import '../core/test_run.dart';
import '../core/models.dart';
@@ -321,6 +322,20 @@ class RailRow {
int get hashCode => Object.hash(machineId, agentId);
}
+/// What every `agents_list` asks for.
+///
+/// ⚠️ **`includeStopped` is not optional polish — without it the fleet is
+/// silently incomplete.** The daemon answers a plain `agents_list` with
+/// `registry.advertised()`, which is live agents only, and adds saved-but-
+/// stopped work only when asked (`cli/src/backendSocket.ts`, `agents_list`).
+/// This app did not ask, so a machine with nine stopped harnesses reported
+/// none of them and the phone showed a different fleet than the desktop on the
+/// same account — for the search, the Agents tab and every count drawn off them.
+///
+/// The daemon ignores the flag for the hardware dial (`sessionRole == 'device'`);
+/// this app pairs as `'web'`, so it is honoured here.
+const kAgentsListPayload = {'includeStopped': true};
+
class AppNotifier extends ChangeNotifier {
final AuthSession session;
AppConfig config;
@@ -1202,6 +1217,7 @@ class AppNotifier extends ChangeNotifier {
agentPreference = AgentPreference(paneLayoutStore?.storage),
projectHistory = ProjectHistory(paneLayoutStore?.storage),
lastOpenedAgent = LastOpenedAgent(paneLayoutStore?.storage),
+ searchHistory = PhoneSearchHistory(paneLayoutStore?.storage),
// On the same terms as the stores above: a layout store means this is a
// real app with a real Harness home to cache into, and its absence means
// a test, which must not read or write one.
@@ -1274,6 +1290,15 @@ class AppNotifier extends ChangeNotifier {
/// The agent the phone's terminal had open, kept across launches — see [LastOpenedAgent].
final LastOpenedAgent lastOpenedAgent;
+ /// The agents and commands reached from the search, most recent first — what
+ /// ranks the box before a word is typed. See [PhoneSearchHistory].
+ ///
+ /// ⚠️ **On the app, not on the search screen.** It has to outlive one opening
+ /// of the box: a history built per page would load the last run's visits and
+ /// then forget every visit made since, which is exactly the half that matters
+ /// while somebody is switching between two agents.
+ final PhoneSearchHistory searchHistory;
+
/// Last run's machine list, used to start dialling before this run's
/// `/api/machines` answers — see [MachineCache] and [_warmStartMachines].
/// Null in tests, which have no Harness home to cache into.
@@ -3112,6 +3137,7 @@ class AppNotifier extends ChangeNotifier {
try {
final response = await connection.request(
'agents_list',
+ payload: kAgentsListPayload,
timeout: const Duration(seconds: 10),
);
final agents = (response['agents'] as List<dynamic>? ?? [])
@@ -3818,7 +3844,11 @@ class AppNotifier extends ChangeNotifier {
);
final response = await StartupTrace.time(
'agents.list',
- () => connection.request('agents_list', timeout: remaining),
+ () => connection.request(
+ 'agents_list',
+ payload: kAgentsListPayload,
+ timeout: remaining,
+ ),
);
if (!_machineWorkCurrent(machine, revision)) return;
final rawAgents = response['agents'] as List<dynamic>? ?? [];
@@ -4423,7 +4453,9 @@ class AppNotifier extends ChangeNotifier {
/// Machines tab's pull-to-refresh, the screen whose job is listing them.
///
/// Nothing on screen waits for this: each machine publishes as it answers,
- /// and the rows already drawn keep their places (`PhoneSearchOrder`).
+ /// and the rows already drawn keep their places — the search ranks on the
+ /// visit history and the name, neither of which a late-answering machine
+ /// moves. See [PhoneSearchHistory] and `rankPhoneDestinations`.
Future<void> reachAllMachines() async {
// No transport yet — before sign-in, or in a test with no fake connection.
// The same guard [_canFetchPreview] uses, and for the same reason: `_conn`
@@ -4957,6 +4989,32 @@ class AppNotifier extends ChangeNotifier {
/// confirmed, so this upserts from the reply directly — idempotent on `agent.id`, same as
/// [createAgent], and safe even if the CLI's own `agent_synced` push for the restart arrives
/// separately (fire-and-forget on the CLI side, unordered relative to this reply).
+ /// Bring a stopped agent back, so something can be opened on it.
+ ///
+ /// The desktop's `resumeAgent`: a thin guard over [restartAgent], which is the
+ /// same `agent_restart` RPC. Split out because the two have different
+ /// preconditions — restart is "this agent is misbehaving, relaunch it", resume
+ /// is "this agent is not running, it should be".
+ ///
+ /// An agent that already has a terminal succeeds without touching the machine:
+ /// the caller's job is "make it openable", and it is.
+ Future<RestartAgentResult> resumeAgent(String machineId, String agentId) {
+ final agent = stateOf(
+ machineId,
+ )?.agents.where((agent) => agent.id == agentId).firstOrNull;
+ if (agent?.terminalAvailable == true) {
+ return Future.value(const RestartAgentResult());
+ }
+ if (agent?.isStopped != true) {
+ return Future.value(
+ const RestartAgentResult(
+ error: 'That harness is no longer available. Search again.',
+ ),
+ );
+ }
+ return restartAgent(machineId, agentId);
+ }
+
Future<RestartAgentResult> restartAgent(
String machineId,
String agentId,
diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml
index 78e3194d7..70031ccc2 100644
--- a/mobile/pubspec.yaml
+++ b/mobile/pubspec.yaml
@@ -79,4 +79,9 @@ flutter:
assets:
- assets/engine-icons/
# The real app icon, shown on the sign-in and bootstrapping screens.
+ #
+ # ⚠️ `assets/app_icon.svg` beside it is the MASTER this and all 20 launcher
+ # slots are rendered from (`scripts/build_app_icons.py`), and is deliberately
+ # NOT listed: Flutter cannot draw an SVG without a package this app does not
+ # depend on, so bundling it would only add its weight to every install.
- assets/app_icon.png
diff --git a/mobile/scripts/build_app_icons.py b/mobile/scripts/build_app_icons.py
new file mode 100644
index 000000000..261f0dd85
--- /dev/null
+++ b/mobile/scripts/build_app_icons.py
@@ -0,0 +1,263 @@
+#!/usr/bin/env python3
+"""Rebuild every app-icon slot from `assets/app_icon.svg`.
+
+ python3 scripts/build_app_icons.py # write the icons
+ python3 scripts/build_app_icons.py --check # verify only, write nothing
+
+Needs Pillow (`pip install Pillow`) and a macOS `swift` for `render_svg.swift`.
+
+WHY A SCRIPT. The 21 slots were last rebuilt by hand from a raster source, and
+the commit that did it had to explain a flood fill, a least-squares gradient fit
+and a per-slot mask reuse to justify the result. None of that is repeatable, and
+none of it can be re-run when the art changes. The art is a vector now, so the
+whole set is one deterministic pass over it.
+
+THREE RULES THE SLOTS DO NOT SHARE, each a platform's and not a taste:
+
+ * **iOS carries no alpha.** App Store Connect rejects an icon that does, so
+ these are flattened to RGB and drawn square — iOS applies its own squircle
+ and would fight a rounding baked into the file.
+
+ * **Android and `assets/app_icon.png` keep the alpha they already had.** Their
+ masks are reused pixel for pixel rather than redrawn from a guessed radius,
+ so new art drops into the geometry the project already shipped and a diff of
+ the alpha channel is empty. `assets/app_icon.png` is the in-app logo, drawn
+ by `login_screen` and `bootstrapping_screen` with no `ClipRRect` — its
+ corners have to be in the file.
+
+ * **The mark is inset, the background is not.** See [TILE].
+"""
+
+from __future__ import annotations
+
+import argparse
+import json
+import re
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+from PIL import Image
+
+MOBILE = Path(__file__).resolve().parent.parent
+SOURCE = MOBILE / "assets" / "app_icon.svg"
+RENDERER = MOBILE / "scripts" / "render_svg.swift"
+
+IOS_SET = MOBILE / "ios/Runner/Assets.xcassets/AppIcon.appiconset"
+ANDROID_RES = MOBILE / "android/app/src/main/res"
+ANDROID_DENSITIES = ["mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"]
+IN_APP_LOGO = MOBILE / "assets" / "app_icon.png"
+
+# How much of the canvas the artwork's own 400x400 tile is given, the rest
+# being background the gradient runs on through.
+#
+# ⚠️ **Measured off the icon this replaces, not chosen.** The mark in the
+# shipping 1024 icon spans 0.906 of the canvas and centres at y=493; the tile at
+# this fraction reproduces both to a pixel, so the new art lands exactly where
+# the old art sat and the change is the drawing alone.
+#
+# ⚠️ **It is also the clearance the masks need.** The source is drawn to its own
+# edges — full-bleed at 1024 the circle's top sits ON row 0, and the guide
+# square's bottom corners clear the iOS corner arc by 2.7px. Neither is a cut,
+# and both are close enough that the real squircle (which is not this circular
+# -cornered approximation) is a coin toss. At this fraction the mark keeps 48px
+# of room at 1024. See [CLEARANCE], which is what actually holds the line.
+TILE = 0.938
+
+# How far inside the mask the art has to stay, as a fraction of the canvas —
+# not merely inside it. Every icon here passes "nothing is cut" even drawn to
+# the edges, so that test alone would have let art through that touches the rim
+# and reads as clipped on a phone whether or not a pixel was lost.
+CLEARANCE = 0.015
+
+# The master every slot is resampled from. Supersampled on purpose: a 2.2px
+# stroke on a 400 tile is a third of a pixel at the 20pt slot, and downsampling
+# a large render keeps it as a grey line where rasterising straight to 20px
+# drops it.
+MASTER = 2048
+
+# iOS masks with a superellipse; a circular-cornered rounded rect at Apple's
+# published 22.37% corner radius is a slightly TIGHTER shape than the real
+# squircle, so content that clears this clears the real one.
+IOS_CORNER = 0.2237
+
+
+def read_source() -> tuple[str, str, str]:
+ """The mark (circle, guide square, figure) and the tile's two gradient stops.
+
+ The tile's own rounded rect is dropped: the background below is what fills
+ the canvas, and two gradients over different spans would band where they met.
+ """
+ svg = SOURCE.read_text()
+ body = re.search(r"<g clip-path=[^>]*>(.*?)</g>", svg, re.S)
+ stops = re.findall(r'<stop[^>]*stop-color="(#[0-9A-Fa-f]{6})"', svg)
+ if body is None or len(stops) != 2:
+ sys.exit(f"{SOURCE} is not the shape this script knows how to read")
+ mark = re.sub(r"<rect width=\"400\" height=\"400\"[^>]*/>\s*", "", body.group(1))
+ if "<circle" not in mark or "<path" not in mark:
+ sys.exit(f"{SOURCE}: no mark left after dropping the tile")
+ return mark.strip(), stops[0], stops[1]
+
+
+def master_svg(size: int) -> str:
+ """The icon as a square: gradient edge to edge, the mark inset by [TILE]."""
+ mark, top, bottom = read_source()
+ scale = TILE * size / 400
+ offset = (1 - TILE) / 2 * size
+ return (
+ f'<svg width="{size}" height="{size}" viewBox="0 0 {size} {size}" '
+ 'fill="none" xmlns="http://www.w3.org/2000/svg">\n'
+ "<defs>\n"
+ '<linearGradient id="tile" x1="0" y1="0" '
+ f'x2="0" y2="{size}" gradientUnits="userSpaceOnUse">\n'
+ f'<stop stop-color="{top}"/>\n'
+ f'<stop offset="1" stop-color="{bottom}"/>\n'
+ "</linearGradient>\n"
+ "</defs>\n"
+ f'<rect width="{size}" height="{size}" fill="url(#tile)"/>\n'
+ f'<g transform="translate({offset:.4f} {offset:.4f}) scale({scale:.6f})">\n'
+ f"{mark}\n"
+ "</g>\n"
+ "</svg>\n"
+ )
+
+
+def render_master() -> Image.Image:
+ with tempfile.TemporaryDirectory() as tmp:
+ svg = Path(tmp) / "master.svg"
+ png = Path(tmp) / "master.png"
+ svg.write_text(master_svg(MASTER))
+ subprocess.run(
+ ["swift", str(RENDERER), str(svg), str(png), str(MASTER)],
+ check=True,
+ capture_output=True,
+ )
+ return Image.open(png).convert("RGBA").copy()
+
+
+def resample(master: Image.Image, size: int) -> Image.Image:
+ return master.resize((size, size), Image.LANCZOS)
+
+
+def ink(image: Image.Image) -> Image.Image:
+ """The drawn mark alone: everything clearly darker than the green field.
+
+ A threshold on luminance is enough because nothing in between is used — the
+ field is a bright gradient and the mark is very nearly black.
+
+ ⚠️ **Transparent pixels are not ink**, and saying so is not pedantry: a
+ cleared pixel is (0,0,0,0), which drops to black the moment alpha is
+ discarded, and without this every corner the mask already cut would be
+ counted as art the mask cut.
+ """
+ dark = Image.eval(image.convert("RGB").convert("L"), lambda v: 255 if v < 110 else 0)
+ if "A" not in image.getbands():
+ return dark
+
+ from PIL import ImageChops
+
+ opaque = Image.eval(image.getchannel("A"), lambda v: 255 if v >= 128 else 0)
+ return ImageChops.multiply(dark, opaque)
+
+
+def rounded_mask(size: int, radius: float, inset: float = 0) -> Image.Image:
+ """A rounded square at 4x, downsampled — the corners have to be smooth.
+
+ [inset] pulls every edge in by that many pixels and takes the same off the
+ radius, which is the shape a clearance is measured against.
+ """
+ scale = 4
+ mask = Image.new("L", (size * scale, size * scale), 0)
+ from PIL import ImageDraw
+
+ edge = inset * scale
+ ImageDraw.Draw(mask).rounded_rectangle(
+ (edge, edge, size * scale - 1 - edge, size * scale - 1 - edge),
+ radius=max(0.0, (radius - inset) * scale),
+ fill=255,
+ )
+ return mask.resize((size, size), Image.LANCZOS)
+
+
+def clipped(art: Image.Image, mask: Image.Image) -> int:
+ """How many ink pixels the mask would cut. Zero is the only passing answer."""
+ marked = ink(art)
+ outside = Image.eval(mask, lambda v: 255 if v < 128 else 0)
+ from PIL import ImageChops
+
+ return sum(ImageChops.multiply(marked, outside).point(lambda v: v > 0).getdata())
+
+
+def ios_slots() -> dict[str, int]:
+ """Every file Contents.json names, with the pixel size it must be."""
+ contents = json.loads((IOS_SET / "Contents.json").read_text())
+ slots: dict[str, int] = {}
+ for entry in contents["images"]:
+ side = float(entry["size"].split("x")[0])
+ pixels = round(side * float(entry["scale"].rstrip("x")))
+ name = entry["filename"]
+ if slots.setdefault(name, pixels) != pixels:
+ sys.exit(f"{name} is asked for at two different sizes")
+ return slots
+
+
+def build(check: bool) -> int:
+ master = render_master()
+ failures: list[str] = []
+
+ def verify(label: str, art: Image.Image, mask: Image.Image) -> None:
+ cut = clipped(art, mask)
+ if cut:
+ failures.append(f"{label}: {cut} ink pixels outside its mask")
+
+ def verify_clearance(label: str, art: Image.Image, size: int) -> None:
+ """iOS only: inside the squircle is not enough — see [CLEARANCE]."""
+ mask = rounded_mask(size, IOS_CORNER * size, inset=CLEARANCE * size)
+ close = clipped(art, mask)
+ if close:
+ failures.append(f"{label}: {close} ink pixels inside the rim")
+
+ # iOS — square, opaque, and checked against the squircle it will be cut by.
+ for name, size in sorted(ios_slots().items(), key=lambda kv: kv[1]):
+ art = resample(master, size).convert("RGB")
+ verify(f"ios/{name}", art, rounded_mask(size, IOS_CORNER * size))
+ verify_clearance(f"ios/{name}", art, size)
+ if not check:
+ art.save(IOS_SET / name)
+
+ # Android — the alpha each file already had, reused pixel for pixel.
+ for density in ANDROID_DENSITIES:
+ path = ANDROID_RES / f"mipmap-{density}" / "ic_launcher.png"
+ previous = Image.open(path).convert("RGBA")
+ art = resample(master, previous.width)
+ art.putalpha(previous.getchannel("A"))
+ verify(f"android/{density}", art, previous.getchannel("A"))
+ if not check:
+ art.save(path)
+
+ # The in-app logo — its mask insets before it rounds, so the tile is drawn
+ # into the box the alpha actually covers rather than full-bleed and cropped.
+ previous = Image.open(IN_APP_LOGO).convert("RGBA")
+ alpha = previous.getchannel("A")
+ box = alpha.getbbox()
+ logo = Image.new("RGBA", previous.size, (0, 0, 0, 0))
+ logo.paste(resample(master, box[2] - box[0]), (box[0], box[1]))
+ logo.putalpha(alpha)
+ verify("assets/app_icon.png", logo, alpha)
+ if not check:
+ logo.save(IN_APP_LOGO)
+
+ for failure in failures:
+ print(f"FAIL {failure}", file=sys.stderr)
+ if failures:
+ return 1
+ print(f"{'checked' if check else 'wrote'} {len(ios_slots())} iOS slots, "
+ f"{len(ANDROID_DENSITIES)} Android densities and the in-app logo")
+ return 0
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--check", action="store_true", help="verify, write nothing")
+ sys.exit(build(parser.parse_args().check))
diff --git a/mobile/scripts/render_svg.swift b/mobile/scripts/render_svg.swift
new file mode 100644
index 000000000..2f83d87ca
--- /dev/null
+++ b/mobile/scripts/render_svg.swift
@@ -0,0 +1,40 @@
+// Rasterise one local SVG to a square PNG, at whatever size is asked for.
+//
+// Native macOS, because nothing else on a stock developer machine reads SVG:
+// there is no `rsvg-convert`, no Inkscape, and `cairosvg` needs a cairo the
+// repo does not install. `NSImage` decodes SVG on its own, without launching
+// an app or a browser.
+//
+// A twin of `desktop/tool/render_svg.swift`, which is fixed at 256 and belongs
+// to that package. This one takes the size, because the icon builder renders a
+// supersampled master and then resamples each of the 21 slots from it.
+//
+// swift render_svg.swift app_icon.svg out.png 2048
+import AppKit
+
+let args = CommandLine.arguments
+guard args.count == 4, let size = Int(args[3]), size > 0 else {
+ fatalError("Usage: render_svg.swift source.svg output.png size")
+}
+guard let image = NSImage(contentsOfFile: args[1]) else {
+ fatalError("Could not read \(args[1]) as an image")
+}
+guard let bitmap = NSBitmapImageRep(
+ bitmapDataPlanes: nil, pixelsWide: size, pixelsHigh: size,
+ bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true,
+ isPlanar: false, colorSpaceName: .deviceRGB,
+ bytesPerRow: 0, bitsPerPixel: 0
+) else {
+ fatalError("Could not allocate a \(size)x\(size) bitmap")
+}
+NSGraphicsContext.saveGraphicsState()
+NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: bitmap)
+NSGraphicsContext.current?.imageInterpolation = .high
+// The whole square, not fitted: the SVG this renders is authored square, and a
+// fit would silently letterbox a source that stopped being one.
+image.draw(in: NSRect(x: 0, y: 0, width: size, height: size))
+NSGraphicsContext.restoreGraphicsState()
+guard let data = bitmap.representation(using: .png, properties: [:]) else {
+ fatalError("Could not encode the bitmap as PNG")
+}
+try data.write(to: URL(fileURLWithPath: args[2]))
diff --git a/mobile/test/phone_search_test.dart b/mobile/test/phone_search_test.dart
index bc3f2ecff..9e135feed 100644
--- a/mobile/test/phone_search_test.dart
+++ b/mobile/test/phone_search_test.dart
@@ -1,17 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/auth/auth_session.dart';
import 'package:harness_mobile/core/config.dart';
import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/phone/agent_index.dart';
import 'package:harness_mobile/phone/compact_age.dart';
+import 'package:harness_mobile/phone/phone_destination.dart';
+import 'package:harness_mobile/phone/phone_search_catalog.dart';
+import 'package:harness_mobile/phone/phone_search_commands.dart';
+import 'package:harness_mobile/phone/phone_search_controller.dart';
import 'package:harness_mobile/phone/phone_search_field.dart';
-import 'package:harness_mobile/phone/phone_search_folder_header.dart';
import 'package:harness_mobile/phone/phone_search_groups.dart';
-import 'package:harness_mobile/phone/phone_search_index.dart';
-import 'package:harness_mobile/phone/phone_search_order.dart';
import 'package:harness_mobile/phone/phone_search_page.dart';
import 'package:harness_mobile/phone/phone_search_rank.dart';
+import 'package:harness_mobile/phone/resume_agent.dart';
import 'package:harness_mobile/phone/terminal_search.dart';
import 'package:harness_mobile/state/app_state.dart';
import 'package:harness_mobile/state/pending_question.dart';
@@ -25,12 +28,14 @@ Agent _agent(
String cwd = '/srv/work',
int? minutesAgo,
bool terminal = true,
+ bool stopped = false,
String? gridModel,
String? dshName,
}) => Agent(
id: id,
name: 'work · $id',
title: title,
+ status: stopped ? 'stopped' : 'active',
engine: 'codex',
gridModel: gridModel,
dshName: dshName,
@@ -38,7 +43,7 @@ Agent _agent(
updatedAt: minutesAgo == null
? null
: _now.subtract(Duration(minutes: minutesAgo)),
- terminalAvailable: terminal,
+ terminalAvailable: stopped ? false : terminal,
);
MachineState _machine(String id, List<Agent> agents) =>
@@ -120,6 +125,58 @@ class _RecentConn extends WsConn {
}
}
+/// A machine that records the PAYLOAD of every `agents_list`, and can bring a
+/// stopped agent back.
+class _StoppedConn extends WsConn {
+ _StoppedConn(this.agents)
+ : super(
+ wsBaseUrl: 'ws://fixture.invalid',
+ autonomousEnv: 'test',
+ machineId: 'box',
+ accessTokenProvider: (_, _) async => '',
+ onAuthFailure: (_) {},
+ onEvent: (_) {},
+ onStatus: (_) {},
+ );
+
+ /// What `agents_list` answers with; replaced by a restart.
+ List<Map<String, dynamic>> agents;
+ final payloads = <Map<String, dynamic>>[];
+ final restarted = <String>[];
+
+ @override
+ Future<void> waitUntilReady({required Duration timeout}) async {}
+
+ @override
+ Future<Map<String, dynamic>> request(
+ String type, {
+ Map<String, dynamic> payload = const {},
+ Duration timeout = const Duration(seconds: 20),
+ }) async {
+ if (type == 'agents_list') {
+ payloads.add(payload);
+ return {'agents': agents};
+ }
+ if (type == 'agent_restart') {
+ final id = payload['agentId'] as String;
+ restarted.add(id);
+ final agent = {
+ 'id': id,
+ 'name': 'work · $id',
+ 'engine': 'claude',
+ 'status': 'active',
+ 'terminal': {'available': true},
+ };
+ agents = [
+ for (final row in agents)
+ if (row['id'] == id) agent else row,
+ ];
+ return {'agent': agent, 'resumed': true};
+ }
+ throw StateError('unexpected $type');
+ }
+}
+
/// One machine that answers `agents_list`, and records that it was asked.
///
/// The fleet shares one [asked] list, so a test can say WHICH machines the
@@ -166,11 +223,37 @@ Future<void> _settle() async {
}
}
-List<String> _agentIds(List<PhoneSearchResult> rows) => [
+List<String> _agentIds(List<PhoneDestination> rows) => [
for (final row in rows)
if (row.entry != null) row.entry!.agent.id,
];
+/// The agent rows of [app]'s catalog.
+///
+/// Through a [PhoneSearchCatalogCache], as the screens do: the cache is what
+/// decides whether a row can move, so a test that skipped it would be testing a
+/// path nothing runs. Pass one in to ask a second question of the SAME catalog.
+List<PhoneDestination> _agentRows(
+ AppNotifier app, [
+ PhoneSearchCatalogCache? cache,
+]) => [
+ for (final row in (cache ?? PhoneSearchCatalogCache()).read(app))
+ if (row.isAgent) row,
+];
+
+/// [query] over [app]'s agents, ranked as the box ranks them.
+List<PhoneDestination> _rank(
+ AppNotifier app,
+ String query, {
+ List<String> recent = const [],
+ PhoneSearchCatalogCache? cache,
+}) => rankPhoneDestinations(
+ _agentRows(app, cache),
+ query,
+ recent: recent,
+ previews: app.sessionPreviews,
+);
+
void main() {
group('Agent.fromJson', () {
test('reads the title and when the conversation last moved', () {
@@ -276,18 +359,21 @@ void main() {
]),
]);
addTearDown(withFolderHit.dispose);
- final ranked = rankPhoneSearch(phoneSearchIndex(withFolderHit), 'review');
+ final ranked = _rank(withFolderHit, 'review');
expect(_agentIds(ranked), ['48e9', 'f00d']);
- expect(ranked.first.subtitle, 'Review payment flow');
+ // The title earned the row its place, so the title is what is bolded —
+ // and the detail line stays the desktop's: engine · project · machine.
+ expect(ranked.first.detail, 'Codex · work · box');
});
- test('groups keep recency: the freshest agent heads the first group', () {
- final groups = phoneSearchGroups(phoneSearchIndex(app));
- expect([for (final group in groups) group.folder], ['work', 'node']);
- expect(_agentIds(phoneSearchGroupedRows(groups)), [
+ test('the machine grouping keeps the order the ranking handed it', () {
+ final groups = phoneMachineGroups(_agentRows(app));
+ expect([for (final group in groups) group.machineName], ['box']);
+ // Catalog order, which the grouping preserves rather than re-sorting.
+ expect(_agentIds(phoneMachineGroupedRows(groups)), [
'3188',
- '48e9',
'2312',
+ '48e9',
]);
});
@@ -300,16 +386,12 @@ void main() {
]),
]);
addTearDown(models.dispose);
- final all = phoneSearchIndex(models);
- expect(_agentIds(rankPhoneSearch(all, 'llama')), ['2222']);
- expect(_agentIds(rankPhoneSearch(all, 'model manager')), ['3333']);
+ expect(_agentIds(_rank(models, 'llama')), ['2222']);
+ expect(_agentIds(_rank(models, 'model manager')), ['3333']);
});
- test('the best match is the first row of the first group', () {
- final ranked = rankPhoneSearch(phoneSearchIndex(app), '2312');
- final groups = phoneSearchGroups(ranked);
- expect(groups.first.folder, 'node');
- expect(_agentIds(groups.first.rows).first, '2312');
+ test('the best match heads the list', () {
+ expect(_agentIds(_rank(app, '2312')).first, '2312');
});
});
@@ -327,7 +409,7 @@ void main() {
app.previewKey('box', app.machineStates['box']!.agents.single),
]);
await _settle();
- expect(rankPhoneSearch(phoneSearchIndex(app), 'deploy'), isEmpty);
+ expect(_rank(app, 'deploy'), isEmpty);
// The reply lands while the phone is away; on return the machine re-sends
// the agent with a later `updatedAt`, well inside the store's freshFor.
@@ -346,9 +428,7 @@ void main() {
});
await _settle();
expect(conn.asked, ['live', 'live']);
- expect(_agentIds(rankPhoneSearch(phoneSearchIndex(app), 'deploy')), [
- 'live',
- ]);
+ expect(_agentIds(_rank(app, 'deploy')), ['live']);
},
);
@@ -368,20 +448,19 @@ void main() {
]),
], conn: conn);
addTearDown(app.dispose);
- expect(_agentIds(rankPhoneSearch(phoneSearchIndex(app), 'llama')), [
- 'named',
- ]);
+ expect(_agentIds(_rank(app, 'llama')), ['named']);
app.sessionPreviews.warm([
for (final agent in app.machineStates['box']!.agents)
app.previewKey('box', agent),
]);
await _settle();
- final ranked = rankPhoneSearch(phoneSearchIndex(app), 'llama');
+ final ranked = _rank(app, 'llama');
expect(_agentIds(ranked), ['named', 'said']);
- expect(phoneContentSnippet(ranked.first, ['llama']), isNull);
+ final previews = app.sessionPreviews;
+ expect(phoneContentSnippet(ranked.first, ['llama'], previews), isNull);
expect(
- phoneContentSnippet(ranked.last, ['llama']),
+ phoneContentSnippet(ranked.last, ['llama'], previews),
'which llama.cpp build is running?',
);
},
@@ -406,10 +485,10 @@ void main() {
});
await event('text_delta', {'content': 'It is llama.cpp b4521.'});
- final ranked = rankPhoneSearch(phoneSearchIndex(app), 'b4521');
+ final ranked = _rank(app, 'b4521');
expect(_agentIds(ranked), ['live']);
expect(
- phoneContentSnippet(ranked.single, ['b4521']),
+ phoneContentSnippet(ranked.single, ['b4521'], app.sessionPreviews),
'It is llama.cpp b4521.',
);
});
@@ -427,7 +506,7 @@ void main() {
expect(compactAge(now.add(const Duration(minutes: 5)), now), 'now');
});
- testWidgets('before a word: one Recent run, newest first, each row placed', (
+ testWidgets('before a word: the hint names every mode the box has', (
tester,
) async {
final app = _app([
@@ -441,27 +520,274 @@ void main() {
await tester.pumpWidget(MaterialApp(home: PhoneSearchPage(notifier: app)));
await tester.pump();
- expect(find.text('RECENT'), findsOneWidget);
- expect(find.byType(PhoneSearchFolderHeader), findsNothing);
- expect(find.text('Fix login redirect · work · box'), findsOneWidget);
- expect(find.text('node · box'), findsOneWidget);
- expect(find.text('4m'), findsOneWidget);
- expect(find.text('30m'), findsOneWidget);
+ // The one line that teaches `>`, `#`, `@` and `?` exist at all. It used to
+ // read "Search agents", and so nothing on the phone ever mentioned them.
+ expect(find.text(kPhoneSearchHint), findsOneWidget);
+ // One flat list: no Recent heading, no folder headings.
+ expect(find.text('RECENT'), findsNothing);
+ // ⚠️ The identity line is DRAWN as segments, not written as one string —
+ // this is the difference the desktop's picker has and the phone's did not.
+ // `Codex · work · box` as a single run of text is exactly what it must not
+ // be any more.
+ expect(find.text('Codex · work · box'), findsNothing);
+ expect(find.text('Codex'), findsNWidgets(3));
+ expect(find.text('node'), findsOneWidget);
+ expect(find.text('box'), findsNWidgets(3));
+ // ⚠️ Agents only in a plain query — the desktop lists no machine or project
+ // row either until `@` or `#` asks for one. A `Machine · …` line here would
+ // be the phone inventing a row the desktop has never had.
+ expect(find.textContaining('Machine · '), findsNothing);
+ expect(find.textContaining('Project · '), findsNothing);
+ // Each segment carries the desktop's own glyph.
+ expect(find.byIcon(LucideIcons.monitor300), findsNWidgets(3));
+ expect(find.byIcon(LucideIcons.folder300), findsNWidgets(3));
+ // And no age on the trailing edge: the desktop's rows end in nothing.
+ expect(find.text('4m'), findsNothing);
+ expect(find.text('30m'), findsNothing);
+
double top(String name) => tester.getTopLeft(find.text(name)).dy;
- // The fresh `work` agent, then `node`, then the stale `work` one: a folder
- // does not pull its old agent up past a fresher one elsewhere.
+ // Nothing has been reached for yet, so the freshest conversation leads —
+ // NOT the alphabet, which is what the desktop falls back to only because
+ // its own visit history has already placed everything by then.
expect(top('work · 3188'), lessThan(top('work · 2312')));
expect(top('work · 2312'), lessThan(top('work · 9999')));
await tester.enterText(find.byType(TextField), 'login');
await tester.pump();
- expect(find.text('RECENT'), findsNothing);
+ // `login` is in the agent's own title, which ranks like its name.
+ expect(find.text('work · 3188'), findsOneWidget);
expect(find.text('work · 2312'), findsNothing);
- expect(find.byType(PhoneSearchFolderHeader), findsOneWidget);
});
- group('the list holds still while it is being read', () {
- test('a row that moves in the index keeps the place it was drawn in', () {
+ testWidgets('the modes: ? lists them, and each one takes you there', (
+ tester,
+ ) async {
+ final app = _app([
+ _machine('box', [_agent('3188', minutesAgo: 4)]),
+ ]);
+ addTearDown(app.dispose);
+ await tester.pumpWidget(MaterialApp(home: PhoneSearchPage(notifier: app)));
+ await tester.pump();
+
+ await tester.enterText(find.byType(TextField), '?');
+ await tester.pump();
+ expect(find.text('> Commands'), findsOneWidget);
+ expect(find.text('# Projects'), findsOneWidget);
+ expect(find.text('@ Machines'), findsOneWidget);
+
+ // A `?` row rewrites the query in place rather than opening anything.
+ await tester.tap(find.text('@ Machines'));
+ await tester.pump();
+ expect(find.text('Machines'), findsOneWidget);
+ expect(find.text('box'), findsOneWidget);
+ // And the agent rows are gone: `@` lists machines, not their contents.
+ expect(find.text('work · 3188'), findsNothing);
+ });
+
+ testWidgets('choosing a machine narrows the search to its agents', (
+ tester,
+ ) async {
+ final app = _app([
+ _machine('box', [_agent('3188', minutesAgo: 4)]),
+ _machine('lab', [_agent('7777', minutesAgo: 9)]),
+ ]);
+ addTearDown(app.dispose);
+ await tester.pumpWidget(MaterialApp(home: PhoneSearchPage(notifier: app)));
+ await tester.pump();
+
+ await tester.enterText(find.byType(TextField), '@box');
+ await tester.pump();
+ await tester.tap(find.text('box'));
+ await tester.pump();
+
+ // Scoped: its own agents, and the bar says which machine they are in.
+ expect(find.text('Agents · box'), findsOneWidget);
+ expect(find.text('work · 3188'), findsOneWidget);
+ expect(find.text('work · 7777'), findsNothing);
+
+ // Back leaves the machine before it leaves the screen, and puts the query
+ // that chose it back in the field.
+ await tester.tap(find.bySemanticsLabel('Back'));
+ await tester.pumpAndSettle();
+ expect(find.byType(PhoneSearchPage), findsOneWidget);
+ expect(find.text('Agents · box'), findsNothing);
+ });
+
+ testWidgets('# lists projects, and a machine row says what it holds', (
+ tester,
+ ) async {
+ final app = _app([
+ _machine('box', [
+ _agent('3188', minutesAgo: 4),
+ _agent('2312', minutesAgo: 9),
+ ]),
+ ]);
+ addTearDown(app.dispose);
+ await tester.pumpWidget(MaterialApp(home: PhoneSearchPage(notifier: app)));
+ await tester.pump();
+
+ await tester.enterText(find.byType(TextField), '#');
+ await tester.pump();
+ expect(find.text('work'), findsOneWidget);
+ expect(find.text('Project · 2 harnesses'), findsOneWidget);
+
+ await tester.enterText(find.byType(TextField), '@');
+ await tester.pump();
+ expect(find.text('Machine · 2 harnesses'), findsOneWidget);
+ });
+
+ testWidgets('> runs a command by name', (tester) async {
+ final app = _app([
+ _machine('box', [_agent('3188', minutesAgo: 4)]),
+ ]);
+ addTearDown(app.dispose);
+ var ran = 0;
+ await tester.pumpWidget(
+ MaterialApp(
+ home: PhoneSearchPage(
+ notifier: app,
+ commands: () => [
+ PhoneCommand(
+ id: 'test.thing',
+ title: 'Do the thing',
+ detail: 'A command, by name',
+ run: () => ran++,
+ ),
+ ],
+ ),
+ ),
+ );
+ await tester.pump();
+
+ await tester.enterText(find.byType(TextField), '> thing');
+ await tester.pump();
+ expect(find.text('Do the thing'), findsOneWidget);
+ // An agent is not a command: `>` searches one list only.
+ expect(find.text('work · 3188'), findsNothing);
+
+ await tester.tap(find.text('Do the thing'));
+ await tester.pump();
+ expect(ran, 1);
+ });
+
+ group('stopped work', () {
+ test('every agents_list asks for it', () async {
+ final conn = _StoppedConn([
+ {'id': 'live', 'name': 'work · live', 'terminal': {'available': true}},
+ ]);
+ final app = _app([_machine('box', [])], conn: conn);
+ addTearDown(app.dispose);
+ await app.reachAllMachines();
+ await _settle();
+
+ // ⚠️ Without this the daemon answers `registry.advertised()` — live
+ // agents only — and the phone silently shows a smaller fleet than the
+ // desktop on the same account. See `cli/src/backendSocket.ts`.
+ expect(conn.payloads, isNotEmpty);
+ for (final payload in conn.payloads) {
+ expect(payload['includeStopped'], isTrue);
+ }
+ });
+
+ test('a stopped agent is listed, and a tap can land on it', () {
+ final app = _app([
+ _machine('box', [
+ _agent('live', minutesAgo: 30),
+ _agent('saved', minutesAgo: 1, stopped: true),
+ ]),
+ ]);
+ addTearDown(app.dispose);
+ final rows = _agentRows(app);
+ expect(_agentIds(rows), contains('saved'));
+
+ // It has no terminal and never will until something restarts it, so the
+ // bare `terminalAvailable` test would have buried it AND made it dead.
+ final saved = rows.firstWhere((row) => row.entry!.agent.id == 'saved');
+ expect(saved.entry!.agent.terminalAvailable, isFalse);
+ expect(saved.entry!.isOpenable, isTrue);
+
+ final search = PhoneSearchController(notifier: app);
+ addTearDown(search.dispose);
+ expect(search.canSubmit(saved), isTrue);
+ // And it is not sorted below the live agent for lacking a terminal.
+ expect(_agentIds(_rank(app, '')).first, 'saved');
+ });
+
+ test('opening it restarts it, and waits for the terminal', () async {
+ final conn = _StoppedConn([
+ {
+ 'id': 'saved',
+ 'name': 'work · saved',
+ 'engine': 'claude',
+ 'status': 'stopped',
+ 'terminal': {'available': false},
+ },
+ ]);
+ final app = _app([
+ _machine('box', [_agent('saved', minutesAgo: 1, stopped: true)]),
+ ], conn: conn);
+ addTearDown(app.dispose);
+ final entry = agentIndex(app).single;
+ expect(entry.agent.terminalAvailable, isFalse);
+
+ expect(await resumeAgentForOpen(app, entry), isNull);
+ expect(conn.restarted, ['saved']);
+ // ⚠️ The point of the wait: it returns only once there is a terminal to
+ // open. The pager filters its pages to agents that have one, so handing
+ // it an agent still without would have opened a different agent than the
+ // row that was tapped.
+ expect(app.stateOf('box')!.agents.single.terminalAvailable, isTrue);
+ });
+
+ test('a resume that fails is reported, not opened past', () async {
+ final app = _app([
+ _machine('box', [_agent('gone', minutesAgo: 1)]),
+ ]);
+ addTearDown(app.dispose);
+ // Not stopped and with no terminal: nothing to resume, and nothing that
+ // pretending otherwise would achieve.
+ final entry = agentIndex(app).single;
+ app.machineStates['box']!.agents = [
+ _agent('gone', minutesAgo: 1, terminal: false),
+ ];
+ expect(await resumeAgentForOpen(app, entry), isNotNull);
+ });
+
+ testWidgets('it is drawn as saved work, not as a dead row', (
+ tester,
+ ) async {
+ final app = _app([
+ _machine('box', [
+ _agent('live', minutesAgo: 30),
+ _agent('saved', minutesAgo: 1, stopped: true),
+ ]),
+ ]);
+ addTearDown(app.dispose);
+ await tester.pumpWidget(
+ MaterialApp(home: PhoneSearchPage(notifier: app)),
+ );
+ await tester.pump();
+
+ // `Stopped` says a tap will bring it back; `No terminal` said a tap would
+ // do nothing. The two must not be confused for each other.
+ expect(find.text('Stopped'), findsOneWidget);
+ expect(find.text('No terminal'), findsNothing);
+ });
+ });
+
+ group('the order is decided, not observed', () {
+ // ⚠️ This group replaces the old `PhoneSearchOrder` freeze, and the class
+ // with it. That freeze existed because the list was ordered by
+ // `lastActiveAt`, which MOVES: a turn event stamped an agent and its row
+ // jumped to the top, out from under a finger already reaching for it, and
+ // the only fix available was to pin the rows where they were first drawn.
+ //
+ // The desktop never needed one, because its empty-query order is the visit
+ // history plus the name — neither of which a daemon can change. Ranking the
+ // phone the same way makes the jump impossible rather than merely pinned,
+ // so a row that arrives mid-search now lands where it belongs instead of
+ // being parked at the bottom for ever.
+ test('a turn event does not move a row', () {
final machine = _machine('box', [
_agent('first', minutesAgo: 1),
_agent('second', minutesAgo: 2),
@@ -469,23 +795,20 @@ void main() {
]);
final app = _app([machine]);
addTearDown(app.dispose);
- final order = PhoneSearchOrder();
- expect(_agentIds(order.arrange(phoneSearchIndex(app))), [
- 'first',
- 'second',
- 'third',
- ]);
+ final cache = PhoneSearchCatalogCache();
+ expect(
+ _agentIds(_rank(app, '', cache: cache)),
+ ['first', 'second', 'third'],
+ );
- // What a turn event does: the oldest agent is suddenly the most recent,
- // and `recentAgents` puts it on top.
+ // What a turn event does: the oldest agent is suddenly the most recently
+ // active. The catalog is keyed on the SHAPE of the fleet, which a turn
+ // does not change — so the list it is sitting in never hears about it.
machine.agentActivityAt['third'] = DateTime.now();
- expect(_agentIds(phoneSearchIndex(app)), ['third', 'first', 'second']);
- // The list somebody is reading does not follow it.
- expect(_agentIds(order.arrange(phoneSearchIndex(app))), [
- 'first',
- 'second',
- 'third',
- ]);
+ expect(
+ _agentIds(_rank(app, '', cache: cache)),
+ ['first', 'second', 'third'],
+ );
});
test('an agent that starts working stays where it is', () {
@@ -495,32 +818,50 @@ void main() {
]);
final app = _app([machine]);
addTearDown(app.dispose);
- final order = PhoneSearchOrder();
- expect(_agentIds(order.arrange(phoneSearchIndex(app))), ['idle', 'busy']);
+ final cache = PhoneSearchCatalogCache();
+ expect(_agentIds(_rank(app, '', cache: cache)), ['idle', 'busy']);
machine.processingAgentIds.add('busy');
- expect(_agentIds(phoneSearchIndex(app)), ['busy', 'idle']);
- expect(_agentIds(order.arrange(phoneSearchIndex(app))), ['idle', 'busy']);
+ expect(_agentIds(_rank(app, '', cache: cache)), ['idle', 'busy']);
});
- test('an agent that arrives mid-search goes last, not into the middle', () {
- final machine = _machine('box', [
- _agent('first', minutesAgo: 10),
- _agent('second', minutesAgo: 20),
+ test('the agents visited lead, in the order they were visited', () {
+ final app = _app([
+ _machine('box', [
+ _agent('alpha', minutesAgo: 90),
+ _agent('bravo', minutesAgo: 60),
+ _agent('delta', minutesAgo: 1),
+ ]),
]);
- final app = _app([machine]);
addTearDown(app.dispose);
- final order = PhoneSearchOrder();
- order.arrange(phoneSearchIndex(app));
-
- // The freshest agent on the account — and still it waits at the bottom
- // rather than shoving the two rows somebody is looking at down one.
- machine.agents = [...machine.agents, _agent('joined', minutesAgo: 0)];
- expect(_agentIds(order.arrange(phoneSearchIndex(app))), [
- 'first',
- 'second',
- 'joined',
+ // Untouched, the freshest conversation leads — the catalog's own order,
+ // which is what the desktop reaches for its name comparison instead of.
+ expect(_agentIds(_rank(app, '')), ['delta', 'bravo', 'alpha']);
+
+ // Once something HAS been reached for, the history outranks all of that:
+ // the agent visited leads even though its conversation is the stalest.
+ expect(
+ _agentIds(_rank(app, '', recent: ['agent:box\u0000alpha'])),
+ ['alpha', 'delta', 'bravo'],
+ );
+ });
+
+ test('the agent the search was opened from is not buried', () {
+ // ⚠️ Regression. The desktop demotes the pane it has focused, and porting
+ // that rule literally inverted it: the desktop's box always targets a new
+ // tab, so it almost never fires there (the agent you came from sat 2nd of
+ // 16 in a live window), while a phone's search is always opened FROM a
+ // terminal, so it fired every time and sent that agent to the bottom.
+ final app = _app([
+ _machine('box', [
+ _agent('here', minutesAgo: 1),
+ _agent('older', minutesAgo: 60),
+ ]),
]);
+ addTearDown(app.dispose);
+ // `here` is the agent the terminal behind the search is showing, and it
+ // leads because it is the freshest — nothing demotes it for being open.
+ expect(_agentIds(_rank(app, '')), ['here', 'older']);
});
test('a machine redialling gives its rows back where they were', () {
@@ -528,20 +869,19 @@ void main() {
final lab = _machine('lab', [_agent('b', minutesAgo: 50)]);
final app = _app([box, lab]);
addTearDown(app.dispose);
- final order = PhoneSearchOrder();
- expect(_agentIds(order.arrange(phoneSearchIndex(app))), ['a', 'b']);
+ expect(_agentIds(_rank(app, '')), ['a', 'b']);
// Backgrounding the app drops every socket; `box` is the one that has not
// answered yet on the way back.
box
..connectionStatus = ConnectionStatus.connecting
..agentLoadStatus = AgentLoadStatus.loading;
- expect(_agentIds(order.arrange(phoneSearchIndex(app))), ['b']);
+ expect(_agentIds(_rank(app, '')), ['b']);
box
..connectionStatus = ConnectionStatus.connected
..agentLoadStatus = AgentLoadStatus.loaded;
- expect(_agentIds(order.arrange(phoneSearchIndex(app))), ['a', 'b']);
+ expect(_agentIds(_rank(app, '')), ['a', 'b']);
});
});
@@ -595,7 +935,7 @@ void main() {
);
});
- testWidgets('the Recent list does not reshuffle under a finger', (
+ testWidgets('the list does not reshuffle under a finger', (
tester,
) async {
final machine = _machine('box', [
@@ -621,9 +961,6 @@ void main() {
expect(top('work · 9999'), was);
expect(top('work · 3188'), lessThan(top('work · 2312')));
expect(top('work · 2312'), lessThan(top('work · 9999')));
- // Still live in what it SAYS — only where it sits is pinned.
- expect(find.text('now'), findsOneWidget);
- expect(find.text('90m'), findsNothing);
});
testWidgets('opening search warms content; the matching line is quoted', (