diff --git a/pkg/interface/webterm/Tabs.tsx b/pkg/interface/webterm/Tabs.tsx index 37d64eed5c..bf3d32b64b 100644 --- a/pkg/interface/webterm/Tabs.tsx +++ b/pkg/interface/webterm/Tabs.tsx @@ -3,29 +3,28 @@ import api from './api'; import React from 'react'; import useTermState from './state'; import { Tab } from './Tab'; +import { SESSION_ID_REGEX } from './constants'; export const Tabs = () => { const { sessions, names } = useTermState(); const onAddClick = () => { const name = prompt('please entew a session name uwu'); - if (!name) { + if (!name || !SESSION_ID_REGEX.test(name) || names.includes(name)) { + console.log('invalid session name:', name); return; } - //TODO name must be @ta - api.poke(pokeTask(name, { open: { term: 'hood', apps: [{ who: '~'+(window as any).ship, app: 'dojo' }] } })); + api.poke(pokeTask(name, { open: { term: 'hood', apps: [{ who: '~' + (window as any).ship, app: 'dojo' }] } })); useTermState.getState().set(state => { state.names = [name, ...state.names].sort(); state.selected = name; state.sessions[name] = null; }); - - } return (