Comp AI CRM is an open source, CRM designed for AI agents. Agentic-first CRM.
TypeScript
"use client";
import { Button } from "@crm/ui/components/button";
import { InkField } from "@crm/ui/components/ink-field";
import { Kbd } from "@crm/ui/components/kbd";
import {
Sheet,
SheetContent,
SheetDescription,
SheetTitle,
} from "@crm/ui/components/sheet";
import { cn } from "@crm/ui/lib/utils";
import { MenuIcon, SearchIcon } from "lucide-react";
import { Slot } from "radix-ui";
import type * as React from "react";
import { createContext, useContext, useMemo, useRef } from "react";
const MARK_PATH =
"M199.73 49.56L199.73 49.56Q195.47 46.24 191.20 42.92L151.80 12.28Q136.01 0.00 120.22 12.28L15.79 93.49Q0.00 105.77 0.00 125.77L0.00 146.22Q0.00 166.22 15.79 178.50L120.22 259.72Q136.01 272.00 151.80 259.72L256.21 178.50Q272.00 166.22 272.00 146.22L272.00 125.77Q272.00 105.77 256.21 93.49L208.27 56.21Q204.00 52.88 199.73 49.56ZM151.80 38.91L167.48 51.10Q178.35 59.55 167.47 68.00L157.57 75.70Q156.60 76.45 155.63 77.20L155.63 77.20Q154.65 77.96 153.68 77.20L145.33 70.71Q136.01 63.46 126.69 70.71L90.93 98.52Q81.61 105.77 90.93 113.02L91.69 113.61Q100.25 120.27 108.81 126.93L108.81 126.93Q117.37 133.59 125.93 140.25L126.69 140.84Q136.01 148.09 145.33 140.84L181.09 113.00Q190.40 105.76 181.09 98.51L172.75 92.02Q171.78 91.26 172.75 90.51L172.75 90.51Q173.72 89.75 174.70 89.00L184.60 81.31Q195.48 72.86 206.35 81.31L226.91 97.31Q237.79 105.77 226.92 114.23L226.92 114.23Q216.04 122.69 205.16 131.15L151.81 172.65Q136.02 184.93 120.23 172.66L102.24 158.66Q93.69 152.01 85.13 145.36L85.13 145.36Q76.57 138.71 68.01 132.05L66.28 130.70Q55.98 122.70 45.69 114.70L45.11 114.24Q34.24 105.78 45.12 97.33L120.22 38.91Q136.01 26.63 151.80 38.91Z";
const WORDMARK_PATH =
"M356.9 136.2L357.0 140.2L357.2 144.2L357.5 148.0L357.9 151.8L358.4 155.4L359.1 159.0L359.9 162.5L360.8 165.8L361.8 169.1L362.9 172.3L364.2 175.4L365.5 178.4L367.0 181.2L368.6 184.0L370.3 186.7L372.1 189.2L373.9 191.7L375.9 194.0L377.9 196.2L380.1 198.3L382.4 200.2L384.7 202.1L387.2 203.9L389.7 205.5L392.3 207.0L395.0 208.4L397.8 209.6L400.6 210.8L403.5 211.7L406.4 212.6L409.4 213.3L412.5 213.9L415.6 214.4L418.8 214.7L422.1 214.9L425.5 215.0L428.5 214.9L431.5 214.8L434.4 214.5L437.2 214.2L440.0 213.8L442.7 213.2L445.3 212.6L447.9 211.9L450.4 211.1L452.8 210.2L455.1 209.1L457.4 208.0L459.6 206.9L461.7 205.6L463.8 204.2L465.7 202.8L467.7 201.3L469.5 199.7L471.3 198.1L473.0 196.4L474.6 194.6L476.2 192.7L477.7 190.7L479.1 188.7L480.4 186.6L481.7 184.4L482.9 182.2L484.0 179.9L485.0 177.5L486.0 175.1L486.4 174.0Q486.8 172.9 485.9 172.2L468.9 159.0Q467.8 158.1 467.6 159.5L467.3 160.9L466.7 163.6L466.0 166.2L465.2 168.7L464.3 171.1L463.3 173.4L462.1 175.6L460.9 177.7L459.5 179.7L458.1 181.6L456.5 183.4L454.8 185.2L453.0 186.8L451.1 188.2L449.1 189.5L446.9 190.7L444.7 191.8L442.3 192.7L439.8 193.4L437.2 194.1L434.5 194.5L431.7 194.9L428.7 195.1L425.7 195.2L423.3 195.1L421.1 195.0L418.9 194.7L416.7 194.4L414.6 193.9L412.5 193.4L410.5 192.8L408.5 192.0L406.6 191.2L404.8 190.3L403.0 189.3L401.2 188.1L399.5 186.9L397.8 185.6L396.3 184.2L394.7 182.8L393.3 181.2L391.9 179.6L390.6 177.8L389.3 176.0L388.1 174.1L387.0 172.2L385.9 170.1L384.9 167.9L384.0 165.7L383.1 163.4L382.3 161.0L381.7 158.5L381.0 156.0L380.5 153.4L380.1 150.7L379.7 148.0L379.4 145.1L379.2 142.2L379.1 139.3L379.1 136.2L379.1 133.2L379.2 130.2L379.4 127.3L379.7 124.4L380.1 121.7L380.5 119.0L381.0 116.4L381.7 113.8L382.3 111.4L383.1 109.0L384.0 106.6L384.9 104.4L385.9 102.2L387.0 100.1L388.1 98.1L389.3 96.2L390.6 94.4L391.9 92.6L393.3 91.0L394.7 89.4L396.3 87.9L397.8 86.5L399.5 85.2L401.2 84.0L403.0 82.8L404.8 81.8L406.6 80.8L408.5 80.0L410.5 79.3L412.5 78.6L414.6 78.1L416.7 77.6L418.9 77.3L421.1 77.0L423.3 76.9L425.7 76.8L428.6 76.9L431.4 77.1L434.1 77.4L436.7 77.8L439.2 78.4L441.6 79.1L443.9 79.9L446.0 80.9L448.1 81.9L450.1 83.1L451.9 84.4L453.7 85.9L455.3 87.4L456.8 89.1L458.3 90.8L459.6 92.7L460.8 94.6L462.0 96.6L463.0 98.7L464.0 100.9L464.8 103.2L465.6 105.6L466.2 108.1L466.5 109.4Q466.7 110.7 467.8 109.9L484.5 96.9Q485.3 96.2 484.9 95.2L484.6 94.2L483.1 90.8L481.5 87.6L479.8 84.4L477.9 81.4L475.9 78.6L473.7 75.9L471.4 73.4L468.9 71.0L466.2 68.8L463.4 66.7L460.4 64.9L457.3 63.2L453.9 61.8L450.4 60.5L446.7 59.5L442.9 58.6L438.8 57.9L434.6 57.4L430.2 57.1L425.7 57.0L422.3 57.1L418.9 57.3L415.7 57.6L412.5 58.1L409.4 58.7L406.3 59.4L403.4 60.3L400.5 61.3L397.6 62.4L394.9 63.7L392.2 65.1L389.6 66.6L387.1 68.3L384.6 70.0L382.3 71.9L380.1 73.9L377.9 76.0L375.9 78.2L373.9 80.6L372.0 83.0L370.3 85.6L368.6 88.3L367.0 91.1L365.5 94.0L364.2 97.0L362.9 100.1L361.8 103.3L360.8 106.6L359.9 109.9L359.1 113.4L358.4 117.0L357.9 120.6L357.5 124.4L357.2 128.2L357.0 132.2ZM503.3 154.9L503.4 157.9L503.5 160.8L503.8 163.7L504.1 166.5L504.5 169.2L505.0 171.8L505.6 174.4L506.2 176.9L507.0 179.4L507.9 181.8L508.8 184.1L509.8 186.3L511.0 188.5L512.2 190.6L513.4 192.6L514.8 194.5L516.2 196.4L517.7 198.1L519.3 199.8L521.0 201.4L522.7 202.9L524.5 204.3L526.4 205.6L528.4 206.9L530.4 208.0L532.5 209.1L534.6 210.0L536.8 210.9L539.0 211.6L541.3 212.3L543.7 212.9L546.0 213.3L548.5 213.7L551.0 213.9L553.5 214.1L556.1 214.1L558.8 214.1L561.3 213.9L563.9 213.7L566.3 213.3L568.7 212.9L571.1 212.3L573.4 211.6L575.6 210.9L577.8 210.0L579.9 209.1L582.0 208.0L584.0 206.9L586.0 205.6L587.8 204.3L589.6 202.9L591.4 201.4L593.0 199.8L594.6 198.1L596.1 196.4L597.5 194.5L598.8 192.6L600.1 190.6L601.3 188.5L602.4 186.3L603.5 184.1L604.4 181.8L605.3 179.4L606.0 176.9L606.7 174.4L607.3 171.8L607.8 169.2L608.2 166.5L608.5 163.7L608.7 160.8L608.9 157.9L608.9 154.9L608.9 152.0L608.7 149.0L608.5 146.2L608.2 143.4L607.8 140.7L607.3 138.1L606.7 135.5L606.0 133.0L605.3 130.6L604.4 128.2L603.5 125.9L602.4 123.7L601.3 121.5L600.1 119.4L598.8 117.4L597.5 115.5L596.1 113.7L594.6 111.9L593.0 110.3L591.4 108.7L589.6 107.2L587.8 105.8L586.0 104.5L584.0 103.2L582.0 102.1L579.9 101.0L577.8 100.1L575.6 99.2L573.4 98.4L571.1 97.8L568.7 97.2L566.3 96.8L563.9 96.4L561.3 96.2L558.8 96.0L556.1 96.0L553.5 96.0L551.0 96.2L548.5 96.4L546.0 96.8L543.7 97.2L541.3 97.8L539.0 98.4L536.8 99.2L534.6 100.1L532.5 101.0L530.4 102.1L528.4 103.2L526.4 104.5L524.5 105.8L522.7 107.2L521.0 108.7L519.3 110.3L517.7 111.9L516.2 113.7L514.8 115.5L513.4 117.4L512.2 119.4L511.0 121.5L509.8 123.7L508.8 125.9L507.9 128.2L507.0 130.6L506.2 133.0L505.6 135.5L505.0 138.1L504.5 140.7L504.1 143.4L503.8 146.2L503.5 149.0L503.4 152.0ZM524.8 154.9L524.9 151.8L525.1 148.9L525.4 146.0L525.8 143.2L526.3 140.6L526.9 138.0L527.7 135.6L528.5 133.3L529.5 131.1L530.6 129.1L531.8 127.1L533.1 125.3L534.6 123.5L536.1 122.0L537.7 120.5L539.4 119.3L541.2 118.2L543.0 117.2L545.0 116.4L547.1 115.7L549.2 115.2L551.4 114.8L553.7 114.6L556.1 114.5L558.6 114.6L560.9 114.8L563.2 115.2L565.3 115.7L567.4 116.4L569.4 117.2L571.2 118.2L573.0 119.3L574.7 120.5L576.3 122.0L577.8 123.5L579.2 125.3L580.5 127.1L581.7 129.1L582.8 131.1L583.8 133.3L584.6 135.6L585.4 138.0L586.0 140.6L586.5 143.2L586.9 146.0L587.2 148.9L587.4 151.8L587.4 154.9L587.4 158.1L587.2 161.1L586.9 164.0L586.5 166.8L586.0 169.4L585.4 172.0L584.6 174.4L583.8 176.7L582.8 178.9L581.7 181.0L580.5 183.0L579.2 184.8L577.8 186.6L576.3 188.1L574.7 189.5L573.0 190.8L571.2 191.9L569.4 192.9L567.4 193.7L565.3 194.4L563.2 194.9L560.9 195.3L558.6 195.5L556.1 195.6L553.7 195.5L551.4 195.3L549.2 194.9L547.1 194.4L545.0 193.7L543.0 192.9L541.2 191.9L539.4 190.8L537.7 189.5L536.1 188.1L534.6 186.6L533.1 184.8L531.8 183.0L530.6 181.0L529.5 178.9L528.5 176.7L527.7 174.4L526.9 172.0L526.3 169.4L525.8 166.8L525.4 164.0L525.1 161.1L524.9 158.1ZM629.8 206.2Q629.8 211.6 635.1 211.6L645.1 211.6Q650.4 211.6 650.4 206.2L650.4 144.7L650.4 143.1L650.5 141.6L650.6 140.1L650.8 138.6L651.0 137.2L651.2 135.8L651.5 134.4L651.8 133.1L652.2 131.8L652.6 130.5L653.0 129.3L653.5 128.1L654.0 127.0L654.6 125.9L655.2 124.8L655.8 123.8L656.5 122.8L657.2 121.9L657.9 121.1L658.7 120.2L659.5 119.4L660.3 118.7L661.2 118.0L662.1 117.4L663.1 116.8L664.0 116.2L665.0 115.7L666.0 115.3L667.1 114.9L668.1 114.6L669.2 114.3L670.4 114.1L671.5 113.9L672.7 113.8L673.9 113.7L675.1 113.7L677.0 113.7L678.9 113.9L680.6 114.2L682.3 114.6L683.8 115.1L685.3 115.7L686.7 116.4L687.9 117.3L689.1 118.3L690.2 119.3L691.1 120.5L692.0 121.8L692.8 123.3L693.6 124.8L694.2 126.3L694.8 128.0L695.3 129.8L695.8 131.7L696.2 133.6L696.5 135.7L696.7 137.8L696.9 140.0L697.0 142.3L697.0 144.7L697.0 206.2Q697.0 211.6 702.4 211.6L711.7 211.6Q717.0 211.6 717.0 206.2L717.0 144.7L717.1 143.1L717.1 141.5L717.2 140.0L717.4 138.5L717.6 137.1L717.8 135.7L718.1 134.3L718.4 132.9L718.8 131.7L719.2 130.4L719.6 129.2L720.1 128.0L720.6 126.9L721.2 125.8L721.8 124.8L722.4 123.8L723.1 122.8L723.8 121.9L724.5 121.0L725.3 120.2L726.1 119.4L726.9 118.7L727.7 118.0L728.6 117.4L729.6 116.8L730.5 116.2L731.5 115.7L732.5 115.3L733.5 114.9L734.6 114.6L735.7 114.3L736.8 114.1L737.9 113.9L739.1 113.8L740.3 113.7L741.5 113.7L743.3 113.7L745.1 113.9L746.8 114.1L748.4 114.5L749.9 115.0L751.4 115.5L752.7 116.2L754.0 117.0L755.2 117.9L756.3 118.9L757.4 120.0L758.3 121.2L759.2 122.5L760.0 123.9L760.7 125.4L761.4 127.1L762.0 128.8L762.5 130.6L762.9 132.5L763.2 134.5L763.5 136.7L763.7 138.9L763.8 141.2L763.9 143.7L763.9 206.2Q763.9 211.6 769.2 211.6L779.2 211.6Q784.5 211.6 784.5 206.2L784.5 138.8L784.5 136.5L784.4 134.3L784.2 132.2L784.0 130.1L783.8 128.1L783.4 126.2L783.1 124.3L782.6 122.4L782.1 120.6L781.5 118.9L780.9 117.2L780.2 115.6L779.5 114.0L778.7 112.5L777.9 111.1L776.9 109.7L776.0 108.4L774.9 107.1L773.9 106.0L772.7 104.8L771.5 103.8L770.3 102.8L769.0 101.9L767.6 101.0L766.2 100.2L764.7 99.5L763.1 98.8L761.6 98.2L759.9 97.7L758.2 97.2L756.5 96.9L754.7 96.5L752.9 96.3L751.0 96.1L749.0 96.0L747.0 96.0L745.5 96.0L744.0 96.1L742.6 96.2L741.2 96.4L739.7 96.6L738.4 96.9L737.0 97.2L735.7 97.6L734.4 98.0L733.1 98.5L731.9 99.0L730.7 99.6L729.5 100.2L728.3 100.9L727.2 101.6L726.1 102.4L725.1 103.2L724.1 104.0L723.1 104.9L722.2 105.8L721.3 106.8L720.4 107.8L719.6 108.8L718.8 109.9L718.1 111.1L717.4 112.2L716.7 113.5L716.1 114.7L715.5 116.1L715.0 117.4L714.5 118.8L714.4 119.1Q714.3 119.5 714.1 119.1L713.7 117.7L712.8 115.7L711.9 113.8L710.9 111.9L709.8 110.2L708.6 108.5L707.3 106.9L706.0 105.5L704.5 104.1L702.9 102.8L701.3 101.6L699.6 100.5L697.8 99.6L695.9 98.7L693.9 98.0L691.9 97.4L689.8 96.9L687.6 96.5L685.4 96.2L683.0 96.0L680.6 96.0L679.3 96.0L677.9 96.1L676.6 96.2L675.2 96.4L673.9 96.6L672.7 96.9L671.4 97.2L670.1 97.6L668.9 98.0L667.7 98.5L666.5 99.0L665.3 99.6L664.2 100.2L663.0 100.9L661.9 101.6L660.9 102.4L659.8 103.2L658.8 104.0L657.9 104.9L656.9 105.8L656.0 106.8L655.2 107.8L654.3 108.8L653.5 109.9L652.7 111.1L652.0 112.2L651.3 113.4L650.6 114.7L650.0 115.9L649.4 117.2L649.3 117.6Q649.2 117.9 649.1 117.6L648.8 103.9Q648.7 98.5 643.4 98.5L635.1 98.5Q629.8 98.5 629.8 103.9ZM810.8 238.2Q810.8 243.5 816.2 243.5L826.2 243.5Q831.5 243.5 831.5 238.2L831.5 196.6Q831.5 196.2 831.7 196.5L831.8 196.8L832.5 197.9L833.1 198.9L833.9 199.9L834.6 200.9L835.4 201.8L836.3 202.7L837.2 203.6L838.1 204.5L839.0 205.3L840.0 206.1L841.0 206.8L842.0 207.5L843.1 208.2L844.2 208.9L845.4 209.5L846.5 210.1L847.7 210.6L848.9 211.1L850.2 211.6L851.5 212.0L852.7 212.4L854.0 212.8L855.4 213.1L856.7 213.4L858.1 213.6L859.4 213.8L860.8 213.9L862.2 214.0L863.7 214.1L865.1 214.1L867.8 214.1L870.5 213.9L873.0 213.6L875.5 213.2L877.9 212.7L880.3 212.1L882.5 211.3L884.6 210.5L886.7 209.5L888.7 208.4L890.6 207.2L892.5 205.9L894.2 204.5L895.9 203.0L897.5 201.5L899.0 199.9L900.5 198.2L901.8 196.4L903.1 194.5L904.3 192.6L905.5 190.6L906.5 188.6L907.5 186.4L908.4 184.2L909.3 181.9L910.0 179.6L910.7 177.3L911.3 174.9L911.9 172.6L912.3 170.1L912.7 167.7L913.1 165.2L913.3 162.7L913.5 160.1L913.6 157.6L913.6 154.9L913.6 152.3L913.5 149.8L913.3 147.2L913.1 144.7L912.7 142.2L912.3 139.8L911.9 137.4L911.3 135.0L910.7 132.6L910.0 130.3L909.3 128.0L908.4 125.8L907.5 123.6L906.5 121.5L905.5 119.4L904.3 117.4L903.1 115.5L901.8 113.7L900.5 111.9L899.0 110.2L897.5 108.6L895.9 107.1L894.2 105.6L892.5 104.2L890.6 102.9L888.7 101.7L886.7 100.6L884.6 99.6L882.5 98.8L880.3 98.0L877.9 97.4L875.5 96.9L873.0 96.5L870.5 96.2L867.8 96.0L865.1 96.0L863.0 96.0L860.9 96.2L858.8 96.4L856.8 96.7L854.8 97.1L852.9 97.6L851.1 98.2L849.2 98.9L847.4 99.6L845.7 100.5L844.0 101.4L842.3 102.5L840.7 103.6L839.2 104.8L837.8 106.1L836.4 107.5L835.1 108.9L833.9 110.5L832.8 112.1L831.7 113.8L830.8 115.6L830.7 115.7Q830.7 115.8 830.7 115.7L830.3 103.9Q830.2 98.5 824.9 98.5L816.2 98.5Q810.8 98.5 810.8 103.9ZM831.5 154.9L831.5 152.8L831.6 150.7L831.7 148.6L831.9 146.6L832.1 144.6L832.4 142.8L832.8 140.9L833.1 139.1L833.6 137.4L834.1 135.8L834.6 134.1L835.2 132.6L835.9 131.1L836.5 129.7L837.3 128.3L838.0 127.0L838.8 125.8L839.7 124.6L840.6 123.5L841.5 122.5L842.5 121.5L843.6 120.6L844.6 119.8L845.7 119.0L846.9 118.3L848.1 117.6L849.3 117.0L850.6 116.5L851.9 116.0L853.2 115.6L854.6 115.3L856.0 115.0L857.4 114.8L858.9 114.6L860.4 114.5L861.9 114.5L864.2 114.6L866.4 114.8L868.6 115.2L870.6 115.7L872.6 116.4L874.5 117.2L876.3 118.2L878.0 119.3L879.6 120.5L881.2 122.0L882.7 123.5L884.1 125.3L885.3 127.1L886.5 129.1L887.6 131.1L888.5 133.3L889.4 135.6L890.1 138.0L890.7 140.6L891.2 143.2L891.6 146.0L891.9 148.9L892.1 151.8L892.1 154.9L892.1 158.1L891.9 161.1L891.6 164.0L891.2 166.8L890.7 169.4L890.1 172.0L889.4 174.4L888.5 176.7L887.6 178.9L886.5 181.0L885.3 183.0L884.1 184.8L882.7 186.6L881.2 188.1L879.6 189.5L878.0 190.8L876.3 191.9L874.5 192.9L872.6 193.7L870.6 194.4L868.6 194.9L866.4 195.3L864.2 195.5L861.9 195.6L860.4 195.6L858.9 195.5L857.4 195.3L856.0 195.1L854.6 194.8L853.2 194.4L851.9 194.0L850.6 193.6L849.3 193.0L848.1 192.4L846.9 191.7L845.7 191.0L844.6 190.2L843.6 189.4L842.5 188.4L841.5 187.5L840.6 186.4L839.7 185.3L838.8 184.2L838.0 182.9L837.3 181.6L836.5 180.3L835.9 178.9L835.2 177.4L834.6 175.9L834.1 174.3L833.6 172.6L833.1 170.9L832.8 169.1L832.4 167.3L832.1 165.4L831.9 163.4L831.7 161.4L831.6 159.3L831.5 157.1ZM976.0 206.5Q974.2 211.6 979.5 211.6L991.4 211.6Q996.7 211.6 998.5 206.5L1009.4 175.7Q1011.2 170.7 1016.5 170.7L1068.3 170.7Q1073.6 170.7 1075.3 175.7L1086.1 206.5Q1087.8 211.6 1093.2 211.6L1105.3 211.6Q1110.6 211.6 1108.8 206.5L1057.9 65.5Q1056.1 60.4 1050.8 60.4L1034.0 60.4Q1028.7 60.4 1026.9 65.5ZM1023.1 151.1Q1017.8 151.1 1019.6 146.1L1040.6 85.1Q1042.3 80.0 1044.0 85.1L1065.0 146.1Q1066.8 151.1 1061.4 151.1ZM1126.4 206.2Q1126.4 211.6 1131.7 211.6L1142.4 211.6Q1147.7 211.6 1147.7 206.2L1147.7 65.8Q1147.7 60.4 1142.4 60.4L1131.7 60.4Q1126.4 60.4 1126.4 65.8Z";
type AppShellNav = { close: () => void };
const AppShellNavContext = createContext<AppShellNav>({ close: () => {} });
function useAppShellNav(): AppShellNav {
return useContext(AppShellNavContext);
}
function Wordmark(props: React.SVGProps<SVGSVGElement>) {
return (
<svg
width={1167}
height={272}
viewBox="0 0 1167 272"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-auto"
{...props}
>
<path d={MARK_PATH} fill="currentColor" />
<path d={WORDMARK_PATH} fill="currentColor" />
</svg>
);
}
function AppShellHome({
asChild = false,
className,
children,
onClick,
...props
}: React.ComponentProps<"a"> & { asChild?: boolean }) {
const Comp = asChild ? Slot.Root : "a";
const { close } = useAppShellNav();
return (
<Comp
data-slot="app-shell-home"
className={cn(
"flex shrink-0 items-center rounded-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
className,
)}
{...props}
onClick={(event) => {
onClick?.(event);
if (!event.defaultPrevented) close();
}}
>
<Slot.Slottable>{children}</Slot.Slottable>
<Wordmark aria-hidden />
</Comp>
);
}
function AppShellSearch({
placeholder,
label = "Search",
shortcut = "⌘K",
disabled = false,
onOpen,
}: {
placeholder: string;
label?: string;
shortcut?: string;
disabled?: boolean;
onOpen?: () => void;
}) {
return (
<>
<button
type="button"
data-slot="app-shell-search"
aria-label={label}
aria-keyshortcuts="Meta+K Control+K"
disabled={disabled}
onClick={onOpen}
className="hidden h-8 w-full max-w-md items-center gap-2 rounded-md bg-background px-2.5 text-muted-foreground text-sm shadow-border outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:shadow-focus disabled:pointer-events-none sm:flex"
>
<SearchIcon aria-hidden className="size-4 shrink-0" />
<span className="flex-1 truncate text-left">{placeholder}</span>
<Kbd>{shortcut}</Kbd>
</button>
<Button
type="button"
variant="ghost"
size="icon-sm"
aria-label={label}
disabled={disabled}
onClick={onOpen}
className="sm:hidden"
>
<SearchIcon aria-hidden />
</Button>
</>
);
}
function AppShell({
sidebar,
mobileSidebar,
home,
product,
search,
agent,
end,
navOpen,
onNavOpenChange,
children,
}: {
sidebar: React.ReactNode;
mobileSidebar?: React.ReactNode;
home: React.ReactNode;
product?: string;
search?: React.ReactNode;
agent?: React.ReactNode;
end?: React.ReactNode;
navOpen: boolean;
onNavOpenChange: (open: boolean) => void;
children: React.ReactNode;
}) {
const menuRef = useRef<HTMLButtonElement>(null);
const nav = useMemo(
() => ({ close: () => onNavOpenChange(false) }),
[onNavOpenChange],
);
return (
<AppShellNavContext.Provider value={nav}>
<div
data-slot="app-shell"
className="relative isolate flex h-svh min-h-0 bg-background md:bg-[var(--rail,#0c1712)]"
>
<InkField className="hidden w-64 md:block" />
<div
data-slot="app-shell-rail"
className="shell-rail relative z-1 hidden w-58 shrink-0 flex-col md:flex [view-transition-name:app-rail]"
>
<div className="flex h-13 shrink-0 items-center gap-2.5 pl-5">
{home}
{product ? (
<span className="border-l pl-2.5 font-medium text-[0.8125rem] text-muted-foreground">
{product}
</span>
) : null}
</div>
{sidebar}
</div>
<div
data-slot="app-shell-sheet"
className="flex min-w-0 flex-1 flex-col bg-background md:shell-cut"
>
<svg
aria-hidden
data-slot="app-shell-cut-edge"
className="pointer-events-none absolute inset-y-0 left-0 z-10 hidden h-full w-6 text-border md:dark:block"
>
<path
d="M26 0.5Q22.17 0.5 19.15 2.85L3.47 15.03Q0.5 17.34 0.5 21.1V100000"
fill="none"
stroke="currentColor"
strokeLinejoin="round"
strokeWidth={1}
/>
</svg>
<header
data-slot="app-shell-top-bar"
className="flex h-13 shrink-0 items-center gap-2 border-b px-2 md:px-4 [view-transition-name:app-header]"
>
<div className="flex shrink-0 items-center gap-1 md:hidden">
<Button
type="button"
variant="ghost"
size="icon-sm"
ref={menuRef}
aria-label="Open navigation"
aria-expanded={navOpen}
onClick={() => onNavOpenChange(true)}
>
<MenuIcon aria-hidden />
</Button>
{home}
</div>
<div className="flex min-w-0 flex-1 items-center justify-end gap-2 sm:grid sm:grid-cols-[1fr_minmax(0,28rem)_1fr]">
<div className="flex min-w-0 justify-center sm:col-start-2">
{search}
</div>
<div className="flex items-center justify-end gap-2 sm:col-start-3">
{agent}
{end}
</div>
</div>
</header>
<div
data-slot="app-shell-body"
className="flex min-h-0 min-w-0 flex-1"
>
{children}
</div>
</div>
</div>
<Sheet open={navOpen} onOpenChange={onNavOpenChange}>
<SheetContent
side="left"
showCloseButton={false}
onCloseAutoFocus={(event) => {
event.preventDefault();
menuRef.current?.focus();
}}
className="w-72 gap-0 overflow-hidden bg-background p-0 text-foreground md:hidden"
>
<div className="flex min-h-0 flex-1 flex-col pt-2">
<SheetTitle className="sr-only">Navigation</SheetTitle>
<SheetDescription className="sr-only">
Move between the pages of this workspace.
</SheetDescription>
{mobileSidebar ?? sidebar}
</div>
</SheetContent>
</Sheet>
</AppShellNavContext.Provider>
);
}
export { AppShell, AppShellHome, AppShellSearch, useAppShellNav };