webterm: small cleanup, comments

Also includes a more-sane prompt() description.
This commit is contained in:
fang 2022-03-15 01:34:19 +01:00
parent 586c2da857
commit 0d2c135959
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
3 changed files with 10 additions and 4 deletions

View File

@ -191,7 +191,7 @@ export default function Buffer({ name, selected, dark }: BufferProps) {
console.log(`subscription error, id ${id}:`, e);
},
quit: async () => { // quit
console.error('oops quit, reconnecting...');
console.error('quit, reconnecting...');
try {
const newSubscriptionId = await retry(initSubscription, () => {
console.log('attempting to reconnect ...');

View File

@ -1,4 +1,5 @@
export const DEFAULT_SESSION = '';
export const DEFAULT_HANDLER = 'hood';
/**
* Session ID validity:

View File

@ -1,4 +1,8 @@
import { AGENT_SESSION_REGEX, SESSION_ID_REGEX } from '../constants';
import {
DEFAULT_HANDLER,
AGENT_SESSION_REGEX,
SESSION_ID_REGEX
} from '../constants';
import useTermState from '../state';
import api from '../api';
import { pokeTask } from '@urbit/api/term';
@ -8,10 +12,10 @@ export const useAddSession = () => {
const { names } = useTermState();
const addSession = useCallback(async () => {
let agent = 'hood'; // default agent
let agent = DEFAULT_HANDLER;
let sessionName: string;
const userInput = prompt('please entew a session name uwu');
const userInput = prompt('Please enter an alpha-numeric session name.');
// user canceled or did not enter a value
if (!userInput) {
return;
@ -42,6 +46,7 @@ export const useAddSession = () => {
}
try {
//TODO eventually, customizable app pre-linking?
await api.poke(pokeTask(sessionName, { open: { term: agent, apps: [{ who: '~' + (window as any).ship, app: 'dojo' }] } }));
useTermState.getState().set((state) => {
state.names = [sessionName, ...state.names].sort();