!7 cmodule TrainableBot > DynSockPuppetConvo { LS suggestions; S functions; transient SingleComponentPanel scpSuggestions; transient FunctionsLoader loader; transient Thread playThread; start { onPostAdded.add(post -> startPlaying()); } visual jvsplit(super, withMargin(jhsplit( jCenteredSection("Suggestions", scpSuggestions = singleComponentPanel(renderSuggestions())), northAndCenterWithMargin( jrightaligned(jbutton("Load", rThreadEnter loadFunctions)), dm_textAreaAsSection functions())))); JComponent renderSuggestions() { ret ele_renderSuggestions(null, suggestions, sayAction := (IVF1) s -> addPost(s, true), submitAction := (IVF1) s -> addPost(s, false)); } void showSuggestions(Cl suggestions) { setField(suggestions := asList(suggestions)); showSuggestions(); } void showSuggestions { scpSuggestions?.setComponent(renderSuggestions()); } void loadFunctions { dispose loader; loader = new FunctionsLoader(tlftj(functions)); loader.onLoaded(r startPlaying); loader.loadInBackground(); } void startPlaying enter { if (loader == null) loadFunctions(); cancelThread(playThread); playThread = null; playThread = startThread(rEnter play); } void play { //showSuggestions(ll("test " + now())); new LinkedHashSet l; S input = lastInput(); for ping (S f : loader.functions) { addIfInstanceOf(l, S, pcallOpt(loader.blob, f)); ping(); if (nempty(input)) addIfInstanceOf(l, S, pcallOpt(loader.blob, f, input)); } showSuggestions(l); } }