Merge remote-tracking branch 'origin/master' into philip/latter

This commit is contained in:
Philip Monk 2021-11-12 20:50:04 -08:00
commit eae479f829
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
11 changed files with 117 additions and 69 deletions

View File

@ -680,11 +680,11 @@
|= [kel=weft except=(set desk) force=?] |= [kel=weft except=(set desk) force=?]
^+ kiln ^+ kiln
=/ ded (find-blocked kel except) =/ ded (find-blocked kel except)
?: force =? kiln force (suspend-many ded)
=. kiln (suspend-many ded) ?: |(force =(~ ded))
(bump-many kel (all-desks-but (~(uni in except) ded))) ?: !=(zuse+zuse kel)
?: =(~ ded) (bump-one kel %base)
(bump-many kel (all-desks-but except)) (bump-many (all-desks-but (~(uni in except) ded)))
=- (^emit (pyre:pass leaf/- ~)) =- (^emit (pyre:pass leaf/- ~))
"kiln: desks blocked upgrade to {<zuse/zuse>}: {<ded>}" "kiln: desks blocked upgrade to {<zuse/zuse>}: {<ded>}"
:: ::
@ -704,7 +704,7 @@
$(ded t.ded, kiln abet:(suspend i.ded)) $(ded t.ded, kiln abet:(suspend i.ded))
:: ::
++ bump-many ++ bump-many
|= [kel=weft live=(set desk)] |= live=(set desk)
^+ kiln ^+ kiln
:: ensure %base is always reloaded first :: ensure %base is always reloaded first
:: ::
@ -718,7 +718,7 @@
:: ::
|- ^+ kiln |- ^+ kiln
?~ liv kiln ?~ liv kiln
$(liv t.liv, kiln (bump-one kel i.liv)) $(liv t.liv, kiln (bump-one zuse+zuse i.liv))
:: ::
++ bump-one ++ bump-one
|= [kel=weft =desk] |= [kel=weft =desk]
@ -733,7 +733,7 @@
?: =(kel u.kul) ?: =(kel u.kul)
~> %slog.(fmt "{here} already at {<[lal num]:kel>}") ~> %slog.(fmt "{here} already at {<[lal num]:kel>}")
update-running-dudes update-running-dudes
=^ tem rail.rak (crank-next %| kel) =^ tem rail.rak (crank-next kel)
?^ tem ?^ tem
(emit merge-main:pass) (emit merge-main:pass)
=- (emit (pyre:pass leaf/- ~)) =- (emit (pyre:pass leaf/- ~))
@ -861,7 +861,8 @@
++ kelvin-same ++ kelvin-same
^+ vats ^+ vats
~> %slog.(fmt "merging into {here}") ~> %slog.(fmt "merging into {here}")
=. rail.rak +:(crank-next %& (dec aeon:ral)) ?> ?=(^ rail.rak)
=. next.u.rail.rak ~
(emil ~[merge-main sync-ud]:pass) (emil ~[merge-main sync-ud]:pass)
:: ::
++ do-base ++ do-base
@ -878,7 +879,8 @@
=/ =diff [%block loc rak new-weft blockers] =/ =diff [%block loc rak new-weft blockers]
(emil sync-ud:pass (diff:give diff) ~) (emil sync-ud:pass (diff:give diff) ~)
~> %slog.(fmt "applying OTA to {here}, kelvin: {<new-weft>}") ~> %slog.(fmt "applying OTA to {here}, kelvin: {<new-weft>}")
=. rail.rak +:(crank-next %& (dec aeon:ral)) ?> ?=(^ rail.rak)
=. next.u.rail.rak ~
=. wef =. wef
?: =(old-weft new-weft) ~ ?: =(old-weft new-weft) ~
`new-weft `new-weft
@ -912,11 +914,7 @@
update-running-dudes update-running-dudes
?. =(%base loc) ?. =(%base loc)
kiln kiln
=/ kel=[@tas @ud] (bump-many (all-desks-but (get-unblockers ark)))
?~ rail.rak zuse/zuse
?~ next.u.rail.rak zuse/zuse
weft.i.next.u.rail.rak
(bump-many kel (all-desks-but (get-unblockers ark)))
:: ::
++ take-merge-main ++ take-merge-main
|= syn=sign-arvo |= syn=sign-arvo
@ -991,7 +989,7 @@
:: +crank-next: pop stale items from .next until one matches :: +crank-next: pop stale items from .next until one matches
:: ::
++ crank-next ++ crank-next
|= new=(each aeon weft) |= new=weft
^+ [match=*(unit rung) rail.rak] ^+ [match=*(unit rung) rail.rak]
?~ rail.rak ?~ rail.rak
~| [%no-rail-for desk=loc] ~| [%no-rail-for desk=loc]
@ -1000,10 +998,7 @@
=- [match `u.rail.rak(next next)] =- [match `u.rail.rak(next next)]
|- ^- [match=(unit rung) next=(list rung)] |- ^- [match=(unit rung) next=(list rung)]
?~ rog [~ next.u.rail.rak] ?~ rog [~ next.u.rail.rak]
?: ?- -.new ?: =(new weft.i.rog)
%& =(p.new aeon.i.rog)
%| =(p.new weft.i.rog)
==
[`i.rog t.rog] [`i.rog t.rog]
$(rog t.rog) $(rog t.rog)
:: ::

View File

@ -1,5 +1,5 @@
|% |%
+$ bump [%kiln-bump except=(set desk) force=_|] +$ bump [except=(set desk) force=_|]
-- --
|_ b=bump |_ b=bump
++ grad %noun ++ grad %noun
@ -9,7 +9,6 @@
++ json ++ json
^- $-(^json bump) ^- $-(^json bump)
=, dejs:format =, dejs:format
%+ pe %kiln-bump
%- ot %- ot
:~ except+(as so) :~ except+(as so)
force+bo force+bo

View File

@ -1,10 +1,10 @@
:~ title+'System' :~ title+'System'
info+'An app launcher for Urbit.' info+'An app launcher for Urbit.'
color+0xee.5432 color+0xee.5432
glob-http+['https://bootstrap.urbit.org/glob-0v5.fdf99.nph65.qecq3.ncpjn.q13mb.glob' 0v5.fdf99.nph65.qecq3.ncpjn.q13mb] glob-http+['https://bootstrap.urbit.org/glob-0v4.64ana.19ug9.ik7l6.og080.68ce4.glob' 0v4.64ana.19ug9.ik7l6.og080.68ce4]
::glob-ames+~zod^0v0 ::glob-ames+~zod^0v0
base+'grid' base+'grid'
version+[1 0 1] version+[1 0 2]
website+'https://tlon.io' website+'https://tlon.io'
license+'MIT' license+'MIT'
== ==

View File

@ -49,8 +49,6 @@ const AppRoutes = () => {
} }
}, [isDarkMode, theme]); }, [isDarkMode, theme]);
useEffect(() => {}, []);
useEffect( useEffect(
handleError(() => { handleError(() => {
window.name = 'grid'; window.name = 'grid';

View File

@ -227,6 +227,7 @@ export const Leap = React.forwardRef(
[selection, rawInput, match, matches, selectedMatch] [selection, rawInput, match, matches, selectedMatch]
); );
return ( return (
<div className="relative z-50 w-full"> <div className="relative z-50 w-full">
<form <form
@ -234,6 +235,7 @@ export const Leap = React.forwardRef(
'flex items-center h-full w-full px-2 rounded-full bg-white default-ring focus-within:ring-2', 'flex items-center h-full w-full px-2 rounded-full bg-white default-ring focus-within:ring-2',
shouldDim && 'opacity-60', shouldDim && 'opacity-60',
!navOpen ? 'bg-gray-50' : '', !navOpen ? 'bg-gray-50' : '',
menu === 'upgrading' ? 'bg-orange-500' : '',
className className
)} )}
onSubmit={onSubmit} onSubmit={onSubmit}
@ -241,28 +243,32 @@ export const Leap = React.forwardRef(
<label <label
htmlFor="leap" htmlFor="leap"
className={classNames( className={classNames(
'inline-block flex-none p-2 h4 text-blue-400', 'inline-block flex-none p-2 h4 ',
!selection && 'sr-only' menu === 'upgrading' ? 'text-white' : !selection ? 'sr-only' : 'text-blue-400'
)} )}
> >
{selection || 'Search'} {menu === 'upgrading'
? 'Your Urbit is being updated, this page will update when ready'
: selection || 'Search'}
</label> </label>
<input {menu !== 'upgrading' ? (
id="leap" <input
type="text" id="leap"
ref={inputRef} type="text"
placeholder={selection ? '' : 'Search'} ref={inputRef}
className="flex-1 w-full h-full px-2 h4 text-base rounded-full bg-transparent outline-none" placeholder={selection ? '' : 'Search'}
value={rawInput} className="flex-1 w-full h-full px-2 h4 text-base rounded-full bg-transparent outline-none"
onClick={toggleSearch} value={rawInput}
onFocus={onFocus} onClick={toggleSearch}
onChange={onChange} onFocus={onFocus}
onKeyDown={onKeyDown} onChange={onChange}
autoComplete="off" onKeyDown={onKeyDown}
aria-autocomplete="both" autoComplete="off"
aria-controls={dropdown} aria-autocomplete="both"
aria-activedescendant={selectedMatch?.display || selectedMatch?.value} aria-controls={dropdown}
/> aria-activedescendant={selectedMatch?.display || selectedMatch?.value}
/>
) : null}
</form> </form>
{menu === 'search' && ( {menu === 'search' && (
<Link <Link

View File

@ -52,7 +52,8 @@ export type MenuState =
| 'search' | 'search'
| 'notifications' | 'notifications'
| 'help-and-support' | 'help-and-support'
| 'system-preferences'; | 'system-preferences'
| 'upgrading';
interface NavProps { interface NavProps {
menu?: MenuState; menu?: MenuState;
@ -68,7 +69,7 @@ export const Nav: FunctionComponent<NavProps> = ({ menu }) => {
const select = useLeapStore((state) => state.select); const select = useLeapStore((state) => state.select);
const menuState = menu || 'closed'; const menuState = menu || 'closed';
const isOpen = menuState !== 'closed'; const isOpen = menuState !== 'upgrading' && menuState !== 'closed';
const eitherOpen = isOpen || systemMenuOpen; const eitherOpen = isOpen || systemMenuOpen;
useEffect(() => { useEffect(() => {

View File

@ -12,7 +12,7 @@ function renderNotification(notification: Notification, key: string, lid: HarkLi
if (notification.bin.place.path === '/lag') { if (notification.bin.place.path === '/lag') {
return <RuntimeLagNotification key={key} />; return <RuntimeLagNotification key={key} />;
} }
if (notification.bin.place.path === '/blocked') { if (notification.bin.path === '/blocked' && notification.bin.place.path === '/desk/base') {
return <BaseBlockedNotification key={key} />; return <BaseBlockedNotification key={key} />;
} }
if (notification.bin.place.path === '/onboard') { if (notification.bin.place.path === '/onboard') {

View File

@ -1,4 +1,4 @@
import { pick } from 'lodash'; import { pick, pickBy, partition } from 'lodash';
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { kilnBump } from '@urbit/api/hood'; import { kilnBump } from '@urbit/api/hood';
import { AppList } from '../../components/AppList'; import { AppList } from '../../components/AppList';
@ -7,9 +7,12 @@ import { Dialog, DialogClose, DialogContent, DialogTrigger } from '../../compone
import { Elbow } from '../../components/icons/Elbow'; import { Elbow } from '../../components/icons/Elbow';
import api from '../../state/api'; import api from '../../state/api';
import { useCharges } from '../../state/docket'; import { useCharges } from '../../state/docket';
import useKilnState, { useVat } from '../../state/kiln';
import { NotificationButton } from './NotificationButton'; import { NotificationButton } from './NotificationButton';
import { disableDefault } from '../../state/util'; import { disableDefault } from '../../state/util';
import { Vat } from '@urbit/api';
import {useHistory} from 'react-router-dom';
export const RuntimeLagNotification = () => ( export const RuntimeLagNotification = () => (
<section <section
@ -35,16 +38,29 @@ export const RuntimeLagNotification = () => (
</section> </section>
); );
function vatIsBlocked(newKelvin: number, vat: Vat) {
return !(vat.arak?.rail?.next || []).find(({ aeon, weft }) => weft.kelvin === newKelvin);
}
export const BaseBlockedNotification = () => { export const BaseBlockedNotification = () => {
const desks: string[] = []; const base = useVat('base');
const { push } = useHistory();
// TODO: assert weft.name === 'zuse'??
const newKelvin = base?.arak?.rail?.next?.[0]?.weft?.kelvin || 420;
const charges = useCharges(); const charges = useCharges();
const blockedCharges = Object.values(pick(charges, desks)); const [blocked, unblocked] = useKilnState((s) => {
const [b, u] = partition(Object.entries(s.vats), ([desk, vat]) => vatIsBlocked(newKelvin, vat));
return [b.map(([d]) => d), u.map(([d]) => d)] as const;
});
const blockedCharges = Object.values(pick(charges, blocked));
const count = blockedCharges.length; const count = blockedCharges.length;
const handlePauseOTAs = useCallback(() => {}, []); const handlePauseOTAs = useCallback(() => {}, []);
const handleArchiveApps = useCallback(async () => { const handleArchiveApps = useCallback(async () => {
api.poke(kilnBump(true)); api.poke(kilnBump(true));
push('/leap/upgrading');
}, []); }, []);
return ( return (

View File

@ -1,27 +1,51 @@
import { map, omit } from 'lodash'; import { map, omit } from 'lodash';
import React, { FunctionComponent } from 'react'; import React, { FunctionComponent, useEffect } from 'react';
import { ErrorBoundary } from 'react-error-boundary'; import { ErrorBoundary } from 'react-error-boundary';
import { Route, RouteComponentProps } from 'react-router-dom'; import { Route, RouteComponentProps, useHistory, useParams } from 'react-router-dom';
import { ErrorAlert } from '../components/ErrorAlert'; import { ErrorAlert } from '../components/ErrorAlert';
import { MenuState, Nav } from '../nav/Nav'; import { MenuState, Nav } from '../nav/Nav';
import { useCharges } from '../state/docket'; import { useCharges } from '../state/docket';
import useKilnState from '../state/kiln';
import { RemoveApp } from '../tiles/RemoveApp'; import { RemoveApp } from '../tiles/RemoveApp';
import { SuspendApp } from '../tiles/SuspendApp'; import { SuspendApp } from '../tiles/SuspendApp';
import { Tile } from '../tiles/Tile'; import { Tile } from '../tiles/Tile';
import { TileInfo } from '../tiles/TileInfo'; import { TileInfo } from '../tiles/TileInfo';
type GridProps = RouteComponentProps<{ interface RouteProps {
menu?: MenuState; menu?: MenuState;
}>; }
export const Grid: FunctionComponent<GridProps> = ({ match, history }) => { export const Grid: FunctionComponent<{}> = () => {
const charges = useCharges(); const charges = useCharges();
const { push } = useHistory();
const { menu } = useParams<RouteProps>();
const chargesLoaded = Object.keys(charges).length > 0; const chargesLoaded = Object.keys(charges).length > 0;
useEffect(() => {
// TOOD: rework
// Heuristically detect reload completion and redirect
async function attempt(count = 0) {
if(count > 5) {
window.location.reload();
}
const start = performance.now();
await useKilnState.getState().fetchVats();
await useKilnState.getState().fetchVats();
if((performance.now() - start) > 5000) {
attempt(count+1);
} else {
push('/');
}
}
if(menu === 'upgrading') {
attempt();
}
}, [menu])
return ( return (
<div className="flex flex-col"> <div className="flex flex-col">
<header className="fixed sm:sticky bottom-0 sm:bottom-auto sm:top-0 left-0 z-30 flex justify-center w-full px-4"> <header className="fixed sm:sticky bottom-0 sm:bottom-auto sm:top-0 left-0 z-30 flex justify-center w-full px-4">
<Nav menu={match.params.menu} /> <Nav menu={menu} />
</header> </header>
<main className="h-full w-full flex justify-center pt-4 md:pt-16 pb-32 relative z-0"> <main className="h-full w-full flex justify-center pt-4 md:pt-16 pb-32 relative z-0">
@ -30,11 +54,11 @@ export const Grid: FunctionComponent<GridProps> = ({ match, history }) => {
<div className="grid justify-center grid-cols-2 sm:grid-cols-[repeat(auto-fit,minmax(auto,250px))] gap-4 px-4 md:px-8 w-full max-w-6xl"> <div className="grid justify-center grid-cols-2 sm:grid-cols-[repeat(auto-fit,minmax(auto,250px))] gap-4 px-4 md:px-8 w-full max-w-6xl">
{charges && {charges &&
map(omit(charges, window.desk), (charge, desk) => ( map(omit(charges, window.desk), (charge, desk) => (
<Tile key={desk} charge={charge} desk={desk} /> <Tile key={desk} charge={charge} desk={desk} disabled={menu === 'upgrading'} />
))} ))}
</div> </div>
)} )}
<ErrorBoundary FallbackComponent={ErrorAlert} onReset={() => history.push('/')}> <ErrorBoundary FallbackComponent={ErrorAlert} onReset={() => push('/')}>
<Route exact path="/app/:desk"> <Route exact path="/app/:desk">
<TileInfo /> <TileInfo />
</Route> </Route>

View File

@ -241,7 +241,17 @@ function createMockSysNotification(path: string, body: HarkBody[] = []) {
} }
const lag = createMockSysNotification('/lag'); const lag = createMockSysNotification('/lag');
const blocked = createMockSysNotification('/blocked'); const blocked = {
bin: {
place: {
desk: window.desk,
path: '/desk/base'
},
path: '/blocked'
},
time: Date.now() - 3_600,
body: []
};
const onboard = createMockSysNotification('/onboard'); const onboard = createMockSysNotification('/onboard');
const updateNotification = createMockSysNotification('/desk/bitcoin', [ const updateNotification = createMockSysNotification('/desk/bitcoin', [

View File

@ -13,19 +13,20 @@ import { Bullet } from '../components/icons/Bullet';
type TileProps = { type TileProps = {
charge: ChargeWithDesk; charge: ChargeWithDesk;
desk: string; desk: string;
disabled?: boolean;
}; };
export const Tile: FunctionComponent<TileProps> = ({ charge, desk }) => { export const Tile: FunctionComponent<TileProps> = ({ charge, desk, disabled = false }) => {
const addRecentApp = useRecentsStore((state) => state.addRecentApp); const addRecentApp = useRecentsStore((state) => state.addRecentApp);
const { title, image, color, chad, href } = charge; const { title, image, color, chad, href } = charge;
const vat = useVat(desk); const vat = useVat(desk);
const { lightText, tileColor, menuColor, suspendColor, suspendMenuColor } = useTileColor(color); const { lightText, tileColor, menuColor, suspendColor, suspendMenuColor } = useTileColor(color);
const loading = 'install' in chad; const loading = !disabled && 'install' in chad;
const suspended = 'suspend' in chad; const suspended = disabled || 'suspend' in chad;
const hung = 'hung' in chad; const hung = 'hung' in chad;
const active = chadIsRunning(chad); const active = !disabled && chadIsRunning(chad);
const link = getAppHref(href); const link = getAppHref(href);
const backgroundColor = active ? tileColor || 'purple' : suspendColor; const backgroundColor = suspended ? suspendColor : active ? tileColor || 'purple' : suspendColor;
return ( return (
<a <a
@ -47,14 +48,12 @@ export const Tile: FunctionComponent<TileProps> = ({ charge, desk }) => {
<> <>
{loading && <Spinner className="h-6 w-6 mr-2" />} {loading && <Spinner className="h-6 w-6 mr-2" />}
<span className="text-gray-500"> <span className="text-gray-500">
{suspended && 'Suspended'} {suspended ? 'Suspended' : loading ? 'Installing' : hung ? 'Errored' : null }
{loading && 'Installing'}
{hung && 'Errored'}
</span> </span>
</> </>
)} )}
</div> </div>
{vat?.arak.rail?.paused && ( {vat?.arak.rail?.paused && !disabled && (
<Bullet className="absolute z-10 top-5 left-5 sm:top-7 sm:left-7 w-4 h-4 text-orange-500 dark:text-black" /> <Bullet className="absolute z-10 top-5 left-5 sm:top-7 sm:left-7 w-4 h-4 text-orange-500 dark:text-black" />
)} )}
<TileMenu <TileMenu