Commit Graph

206 Commits

Author SHA1 Message Date
hanishkvc 9039a917d0 SimpleSallap:SimpleMCP: Cleanup, Readme updates
Update the documentation a bit wrt switch from simpleproxy to
simplemcp with mcp-ish kind of handshake between the chat client
and simplemcp.

Rename proxyUrl and related to mcpServerUrl and mcpServerAuth.
Now include the path in the url itself, given that in future,
we may want to allow the chat client logic to handshake with
other mcp servers, which may expose their services through a
different path or so.

Drop SearchEngine related config entries from chat session
settings, given that its now controlled directly in SimpleMCP.
2025-12-08 06:21:24 +05:30
hanishkvc 2981033fac SimpleChatTCRV:UICleanup:Ai Reasoning/Live response
Implement todo noted in last commit, and bit more.

This brings in clearing of the external ai tool call special chat
session divStream during chat show, which ensures that it gets
hidden by default wrt other chat sessions and inturn only get
enabled if user triggers a new tool call involving external ai
tool call.

This patch also ensures that if ext ai tool call takes too much
time and so logic gives you back control with a timed out response
as a possible response back to ai wrt the tool call, then the
external ai tool call's ai live response is no longer visible in
the current chat session ui. So user can go ahead with the timed
out response or some other user decided response as the response
to the tool call. And take the chat in a different direction of
their and ai's choosing.

Or else, if they want to they can switch to the External Ai
specific special chat session and continue to monitor the response
from the tool call there, to understand what the final response
would have been wrt that tool call.

Rather this should keep the ui flow clean.

ALERT: If the user triggers a new ext ai tool call, when the
old one is still alive in the background, then response from
both will be in a race for user visibility, so beware of it.
2025-12-04 19:41:40 +05:30
hanishkvc 29f9abede9 SimpleChatTCRV:UICleanup: Show own divstream mostly, ShowInfo all
Always show all the info wihen show_info is called, inturn avoid
the corresponding all info enable flag wrt show_info as well as
chat_show.

Now chat_show gives the option to its caller to enable showing of
its own chat session divStream. This is in addition to the handle
multipart response also calling corresponding divStream show.

Previously chat_show would have not only cleared corresponding chat
session's divStream contents but would have also hidden divStream.

Now except for the clearChat case, in all other cases own divStream
is unhidden, when chat_show is called.

Without this, when a tool call takes too much time and inturn
a chat session times out the tool call and inturn user switches
between chat sessions, if the tool call was external_ai, then its
related live ai response would no longer be visible in any of the
chat sessions, including the external_ai special chat session, if
the user had switched to this external_ai special chat session.
But now in the external_ai special chat session, the live response
will be visible.

TODO: With this new semantic wrt chat_show, where a end user can
always peek into a chat session's ai live stream response if any,
as long as that chat session's ai server handshake is still active,
So now After tool call timeout, which allows users to switch between
sessions, it is better to disable the external ai live divStream
in other chat sessions, when user switches into them. This ensures
that

1. if user doesnt switch out of the chat session which triggered
external_ai, for now the user can continue to see the ext ai live
response stream.

2. Switching out of the chat session which triggered ext ai, will
automatically disable viewing of external ai live response from
all chat sessions except for the external ai's special chat session.

IE I need to explicitly clear not just the own divStream, but also
the external ai related divStream, which is appened to end of all
chat session's UI.

This will tidy up the usage flow and ui and avoid forcefully showing
external ai tool call's ai live response in other chat sessions,
which didnt trigger the ext ai tool call. And also in the chat
session which triggered ext ai, it will stop showing if user exits
out of that chat session. Same time user can always look at the
ext ai live response stream in the special chat session corresponding
to ext ai.
2025-12-04 19:41:40 +05:30
hanishkvc afd6365ecc SimpleChatTCRV:CMTextFormat: Common flow accounting User and Auto
If user explicitly makes a content text format selection, the
same will be used.

Else based on session settings, a format will be used.

Now when the popover menu is shown, the current message's format
type is reflected in the popover menu.
2025-12-04 19:41:40 +05:30
hanishkvc c68316bf07 SimpleChatTCRV:CMTextFormat: PopOver & Message UI adjust
Add format selection box to the popover.

Update show_message logic to allow refreshing a existing message
ui element, rather than creating a new one.

Trigger refresh of the message ui element, when format selection
changes.
2025-12-04 19:41:40 +05:30
hanishkvc 701ebca477 SimpleChatTCRV:CMContentTextFormat: towards user fine adjustable
Add a textFormat field wrt ChatMessageEx.

User can be allowed to change how to interpret the text content
at a individual message level.
2025-12-04 19:41:40 +05:30
hanishkvc d97147568f SimpleChatTCRV:Markdown: Usage flow cleanup
Move all markdown configs into a single object field.

Add always flag, which if set, all roles' message contents will be
treated as markdown, else only ai assistant's messages will be
treated as markdown.
2025-12-04 19:41:40 +05:30
hanishkvc 707b719f67 SimpleChatTCRV:Markdown:ReEnable Sanitize, lineRaw
Maintain raw and sanitized versions of line.

Make blockquote work with raw line and not the sanitized line.
So irrespective of whether sanitize is enabled or not, the logic
will still work. Inturn re-enable HtmlSanitize.
2025-12-04 19:41:40 +05:30
hanishkvc edba012d80 SimpleChatTCRV:Markdown:BlockQuote support 2025-12-04 19:41:40 +05:30
hanishkvc 654e234a4e SimpleChatTCRV:Markdown:User configurable per session
User can enable or disable the simple minded bruteforce markdown
parsing from the per session settings.

Add grey shading and align text to left wrt table headings of
markdown to html converted tables.
2025-12-04 19:41:40 +05:30
hanishkvc d3f1a398d8 SimpleChatTCRV:Markdown:Initial skeleton
Try identify headings, and blocks in markdown and convert them
into equivalent stuff in html

Show the same in the chat message blocks.
2025-12-04 19:41:40 +05:30
hanishkvc 3cd2e3fd90 SimpleChatTCRV:UI:Cleanup: Have common div+label+el logic
Avoid seperate duplicated logic for creating the div+label+el based
element
2025-12-04 19:41:40 +05:30
hanishkvc 073c570cad SimpleChatTCRV:AiCallingAi ToolCall: flow cleanup and flexibility
By default ensure external_ai tool call related special chat session
starts with tool calls disabled and client side sliding window of 1.

Add a helper in SimpleChat class to set these along with clearing of
any chat history.

Inturn now give the user flexibility to change this from within
the program, if they need to for what ever reason, till the program
restarts.
2025-12-04 19:41:40 +05:30
hanishkvc b1cfedaba7 SimpleChatTCRV:Misc cleanup continues... 2025-12-04 19:41:40 +05:30
hanishkvc 4bca1f6f3e SimpleChatTCRV:UIRefresh cleanup: Show only msgs in sliding window
Ensure we are working with the Chat Messages in Chat session, which
are in the currently active sliding window.

Remove any chat message blocks in the chat session ui, which are
no longer in the sliding window of context.

This brings uirefresh semantic to be in sync with chat_show logic
2025-12-04 19:41:40 +05:30
hanishkvc 856f403f1d SimpleChatTCRV:AnveshikaSallap: cleanup in general
Rename the default 2 chat session names to make them neutral.

Update internal name to include AnveshikaSallap, better matching
the semantic of the logic, given support for tool calling, vision,
reasoning, ...

Also update usage note wrt simpleproxy.py for web access related
tool calls and few other minor tweeks.
2025-12-04 19:41:40 +05:30
hanishkvc a4e023d21c SimpleChatTCRV:Config++:Cleanup the initial go
Ensure toolNames array is reset, each time setup is called, so
that it doesnt end up with duplicate entries and equally dont
end up with entries of tool calls which are no longer available,
maybe because some config changed etal.

Ensure the ChatId is logged wrt the toolweb related setup actions.

Ensure that ExternalAi tool call related chat session, has its
tools config disabled, when its created itself, so that end user
doesnt get confused, given that external_ai toolcall explicitly
forces tools support to disabled.

Update some of the notes and readme
2025-12-04 19:41:40 +05:30
hanishkvc 57cf87b19a SimpleChatTCRV:Config++:Save/Load Configs 2025-12-04 19:41:40 +05:30
hanishkvc f7e9bdeed5 SimpleChatTCRV:Config++:Cleanup: Hide/Show UserIn and ValidateTC
When switching to settings ui, hide the User input and ValidateTC
areas.

When switching back to any chat session, unhide User input, while
the ValidateTC ui will be handled by corresponding helper logic
called through the ShowMessage
2025-12-04 19:41:40 +05:30
hanishkvc 7d6971a737 SimpleChatTCRV:Config++: ValidatedToolCall UI updated
Given that ValidatedToolCallTrigger UI setup has to also setup
the auto trigger logic, which inturn is dependent on the autosecs
value in the Config associated with the Chat session involved, so
pass chatId to ShowMessage and inturn ValidatedToolCallTriggerUI
setup logic

Rename the function name to better match the semantic.
2025-12-04 19:41:40 +05:30
hanishkvc 8e39afb05e SimpleChatTCRV:Config:Tools: Adapt for SimpleChat with Config
Split init from setup wrt Tools. Init is called when the program
is started, while setup is called when ever a session is created
and or when ever any tools setup related config is changed (like
proxyUrl getting modified or so).

This allows one to modify tool related config and inturn update
the tools related states wrt same (like wrt the proxyUrl, bcas
the simpleproxy server will change, one needs to cross check which
and all web services are available with the new simpleproxy server
and so and so ...)

To help with the above, now ToolsManager maintains multiple tool
call switches, where there will be a tc_switch wrt each chat
session.

All tool related codes, where needed have been updated to work
with the chat session for which they have been called, instead
of any global states.

In future, this can enable one to allow user to enable or disable
the tool calls exposed in each of the chat sessions,

This immidiately needed toolweb and toolai to account for chat
session as needed.

In future, if we want to keep the data store isolated across
chat sessions, then this can be useful, in that it can create
uniq store names for each of the chat sessions, isntead of
sharing a common store name across all sessions.

The chat session creation as well as tool init/setup related
flows have been updated to chain through or account for the
promises as needed
2025-12-04 19:41:40 +05:30
hanishkvc d07e16af74 SimpleChatTCRV:Config+:WIP:CleanUp: Have sensible chatIds
Given that now currently settings relates to only those related
to the current chat session, so indicate the name/chatId of the
current chat session in the Settings heading.

* this inturn makes the id dynamic, so change the css rule wrt
settings block from using id to classname, and to help with same
also set a class name for the top level settings block.

As part of same, as well as to help and ensure sanity in general
add a helper to clean up a string to be a form usable as a chatId
2025-12-04 19:41:40 +05:30
hanishkvc 68e4285288 SimpleChatTCRV:Config:WIP:Switch SimpleChat to Config from Me
Update SimpleChat to have a duplicated instance of Config instead
of a reference to the global Me instance.

Most logics updated to work with the config entries corresponding
to the current chat session.

ShowSettings, ShowInfo and getting current sliding window size in
user friendly textual form have been moved to Config from Me.

ALERT: With this now, user clicking settings will be able to modify
only the settings corresponding to current in focus chat session.

TODO:
ToolsMgr related use within SimpleChat and beyond needs to be thought
through and updated as needed.

Should tools.proxyUrl be unique to each SimpleChat or ...
2025-12-04 19:41:40 +05:30
hanishkvc f3f65895b6 SimpleChatTCRV:Config:WIP: Move config fields into a Config class
TODO: Rather than maintaining a reference to Me within SimpleChat,
maintain an duplicated instance of the Config class in there, bcas
that is what is needed in SimpleChat wrt Me.

This should also avoid the seperete data object which was created
yesterday to accomodate external_ai tool call.
2025-12-04 19:41:40 +05:30
hanishkvc fe0e118a6b SimpleChatTCRV:ToolCall:ExternalAi: Show its response live
Include the DivStream of ExternalAi toolcall in the other chat
session UIs, so that user can see what the external_ai toolcall
is doing, without having to switch out to external ai session tab.

Update the name of the tool call external ai session.

Ensure to clear previous chat session wrt external ai tool calls
As the ai may call external ai toolcall with the same system
prompt sometimes, which wont trigger the autoclear logic, wrt
the corresponding chat session.

TODO: In future maybe provide a option to continue any previous
chat session if the system prompt is not changed wrt external ai
toolcall.
2025-12-04 19:41:40 +05:30
hanishkvc 97ba0cbf43 SimpleChatTCRV:DivStream: Make it a class
Add logic for hiding and showing and use them as needed.
2025-12-04 19:41:40 +05:30
hanishkvc 2d141a48a4 SimpleChatTCRV:DivStreams: Enhanced Object using JSDoc++
Make DivStream hold a Role element and Data element and inturn
have the live got data go into the data element.

Set some of the relavent classes wrt these, so that it is themed
matching other chat blocks, to any extent.

Add a clear helper function to cleanup as and when needed.

NOTE: Remember to use this to get hold of the DivStream instance
being worked on.

NOTE: Dont forget that setting a parent wrt a HTMLElement wont
automatically add it to the corresponding DOM with a parent child
relation. The new html element will just remain in memory ignored
by everyone else.
2025-12-04 19:41:40 +05:30
hanishkvc d5e5d58d85 SimpleChatTCRV:DivStreams: Prepared for switching in middle
Missing DivStream caught. Logic ready for a distant future,
where one may allow the chat session to be switched even
if there is a pending ai server / tool call response.

Avoids the unneeded removeChild before calling appendChild.

Also found the reason why sometimes the DivStream was missing
from DivChat. Rather when I switched from the transient <p>
element to the persistant session specific <div> elements,
I had forgotten to convert the flow fully, rather I had
forgotten to replace the elP.remove() with elP.replaceChildren

Also retaining that debug log wrt missing DivStream path, Just
in case for now, to cross check once later, I havent missed
any other path.
2025-12-04 19:41:40 +05:30
hanishkvc 5a1eaf94bf SimpleChatTCRV:DivStreams: Why missing - still a mystry
Sometimes the session specific DivStream seems to be missing from
DivChat. Explicitly spliting the remove and append just for the
heck of it didnt help. So also have used try-catch-finally to
ensure it gets added back even if its not already in there, by
not allowing removeChild failure to bypass append etal.

Retaining this here just for the heck of it. WIll be switching
to the appendChild only flow (given it automatically moves the
node, as needed).
2025-12-04 19:41:40 +05:30
hanishkvc 17de6d4a47 SimpleChatTCRV:DivStreams: Have sep div for each chat session
For reasons mentioned in last commit

Also include removing and reappending the chat session specific
div in uirefresh.
2025-12-04 19:41:40 +05:30
hanishkvc 08d165427b SimpleChatTCRV:DivStream: Allow predetermined div for streamd resp
This will help ensure that switching sessions etal wont lead to
loosing handle to sessions that one exited from, with additional
logic to be added later.

Rather I am thinking, maybe it may make more sense to dynamically
pick the currently active chat sessions latestResponse field to
inturn show into a div element at end of the elDivChat.

On thinking further, maybe making elDivStream into elDivStreams
with seperate div for each session is the better thing, as the
SC.handle_response will be able to update its corresponding div
and the session switch can link the currently visible session's
div to be mapped to elDivChat.

NOTE: Rather this commit in itself should take care of the current
normal flow, which wont allow user to switch sessions when a tool
call or handshake with server is pending. However in future if
I want the ui to be freely switched independent of if a tool call
or server handshake is active, then I need the logic mentioned in
previous para.
2025-12-04 19:41:40 +05:30
hanishkvc 5025001bd4 SimpleChatTCRV:ToolCall Ai - Decouple SimpleChat from Me a bit
Had a custom struct for parts of Me needed by SimpleChat, and inturn
that need to be controlled when starting a independent parallel ai
session. For now if chat streaming is used or not and tools is enabled
or not is allowed to be explicitly controlled when handle_chat_hs is
called.

Inturn when toolai triggers the parallel ai session, it disables
tools calling support wrt this child/external ai tool call. Else
even the external ai session may end up triggering tool call wrt
external ai for the same job and thus get into a infinite recursive
loop.

Also
* update the toolai meta data a bit.
* increase time allowed for toolcall to return a response, especially
  usefull for external_ai tool call.

Cleanup some old notes and update readme in general.
2025-12-04 19:41:40 +05:30
hanishkvc 18529445ce SimpleChatTCRV:ToolCall:ExternalAi: initial go 2025-12-04 19:41:40 +05:30
hanishkvc ae552a9161 SimpleChatTCRV:UIClean: Avoid wip popover anchor position mech
Instead use the explicit positioning, which was already added to
support firefox, given that firefox still doesnt support anchor
based positioning.

Also move the popover to top of the chat message bubble/block,
instead of the bottom area. This ensures that the popover isnt
butting heads with the tool call trigger or user input blocks.
2025-12-04 19:41:40 +05:30
hanishkvc 9d1c7b59a9 SimpleChatTCRV:AnveshikaSallap, Color cleanup
Use variables in css for colors.

Change the tool response color to be bit more soothing and kind of
syncd with the user collor. However the tool call color is left
bit odder, to ensure user sight goes there for validating and
triggering.
2025-12-04 19:41:40 +05:30
hanishkvc 15dcd4a0a3 SimpleChatTCRV:ImagePopOver: To view and if reqd del before submit
Also had forgotten to rename to image_urls, when switching from
single image with its corresponding field image_url to image_urls,
wrt removing the same after it has been added to the content array.
2025-12-04 19:41:40 +05:30
hanishkvc 720818f8e7 SimpleChatTCRV:UICleanup: new icons short texts, tighter buttons
Update usage note wrt new icons.
2025-12-04 19:41:40 +05:30
hanishkvc 122c96e8a9 SimpleChatTCRV:MultipleImages:Update ChatMessage++ wrt same
Now NSChatMessage inturn ChatMessageEx, ... have been updated
to maintain a array of image data instead of a single image.

Inturn the ShowMessage as well as submit logics have been updated
to account for multiple images.

Also fix a oversight from previous commit, where when pushing new
image, I had forgotten to remove the old logic, which would have
always updated the 0th image data in the array.
2025-12-04 19:41:40 +05:30
hanishkvc 08ea5c364c SimpleChatTCRV:MultipleImages: Icon only buttons
Instead of having texts submit and image, replace them with equiv
unicode icons.

Adjust the size of these buttons to be smaller, given that now they
only contain icons in them.

Switch from btn+inputfile+img to btn+inputfile wrt image loading btn
given that the image will be shown in seperate dynamically created
images in the user in div.
2025-12-04 19:41:40 +05:30
hanishkvc 1b9190d722 SimpleChatTCRV:MultipleImages:UI: Load track multiple images 2025-12-04 19:41:40 +05:30
hanishkvc ae68ee1850 SimpleChatTCRV:UIClean:Free up vertical space
move sessions buttons div to heading block

and move program name to the default block added to chat div, if
there is no chat in a given chat session.

cleanup the default block helpers to follow a common pattern.

also make the chat message bubbles/blocks bit more prominently box
shadowy
2025-12-04 19:41:40 +05:30
hanishkvc 96f94b8439 SimpleChatTCRV:UICleanup: PopOver, Reasoning bubble
Now popover menu autocloses faster, so that it doesnt distract the
user too long, if not needed.

Reasoning bubble dashed border has been made thinner, so that it
appears pleasant and not over bearing.
2025-12-04 19:41:40 +05:30
hanishkvc d242e7021a SimpleChatTCRV:UICleanup: Full chat messages ui refresh when needed
Starting out with a new chat.

Switching back from settings directly.
2025-12-04 19:41:40 +05:30
hanishkvc 9e720e7688 SimpleChatTCRV:UICleanup:Popover Firefox work around
As firefox doesnt seem to currently support anchor based relative
positioning of the popover, so explicitly set the position of the
popover.

Also reposition the popover to be in the bottom right corner rather
than the previous top center position.
* Rather updated position-area css property ensures this automatically
  wrt chrome browsers.
* while for firefox the explicit code that is added is needed.

NOTE: Had added that id, just in case firefox was goofing up bcas of
the element not having unique id or so, either way the firefox issue
is unrelated and more fundamental lack of support for now.
2025-12-04 19:41:40 +05:30
hanishkvc 72a780e181 SimpleChatTCRV:UICleanup: ToolCall trigger and UserInput block
Add better visual cues wrt the tool call trigger block and the
user input block, and inturn remove the now unneeded horizontal
seperation line between chat messages block and the tool call
trigger block.

Bring in the user role color gradient to the full user input block

Change the TEMP roles to use -TEMP instead of .TEMP suffix, so
that role based css rules get applied without any complexity
that may inturn not get applied.

Avoid extra newlines in the err message returned by the tool call
workers. Given that now there is a proper tool call response
sent back to the ai backend/server, without using user and ai
text content block itself to maintain the tool call and its
response info (which is what this client was doing initially
and so more spacing was added to important parts to bring it
into better focus, just in case).
2025-12-04 19:41:40 +05:30
hanishkvc 519cc46f0e SimpleChatTCRV:Sessions++ button take two: normal html + js + css
Now use javascript to trap the button click and inturn change css
class to hide or show the corresponding div.

This moving away from details with summary being the top level
title + buttons block, avoids the warning wrt non standard use of
details element, as well as gives a clear icon to end users wrt
toggling the sessions+systemprompt block.
2025-12-04 19:41:40 +05:30
hanishkvc c039447494 SimpleChatTCRV:UiCleanup: Switch to icon only buttons and title 2025-12-04 19:41:40 +05:30
hanishkvc bf393380a9 SimpleChatTCRV:UICleanup: limit border-radius, SlidingWindow info
Allow AutoCreated Object Properties Editing UI to be themed to an
extent by assigning a id to the top level element, which is based
on the legend specified.

Use the same to add inline padding as well as adjust border radius
wrt the elements within, for the Settings ui. And min height and
border width wrt input, select and buttons within.

Similarly for the default Usage,Restore and SettingsInfo summary
titles, avoid border-radius.

Show the string representation of the sliding window selected.

Add some padding to system prompt input.
2025-12-04 19:41:40 +05:30
hanishkvc ab9e9c9ee8 SimpleChatTCRV:UICleanup: PopOverTO, buttonBorder, Restore, Usage
PopOver menu now auto closes, if user doesnt interact with it, for
a predefined timeout period.

Change the button border color, which seems to make it more pleasent
with current backgrounds at different places.

Update usage note wrt vision and click to toggle wrt title area.

Make the restore / load session block into a details based block.
Also place it into the parent div immidiately, but in hidden state.
Inturn only if a corresponding entry found in the db, create the
button for loading, as well as unhide it. This ensures that the
restore block's position|order doesnt change in the set of ui
elements wrt usage,restore,settings-info.
2025-12-04 19:41:40 +05:30
hanishkvc 08d84ecd85 SimpleChatTCRV:UI Cleanup
rename to ui_userinput_reset,

Initial review to ensure all paths make use of it suitably, wrt
handle user submit and tool call.
2025-12-04 19:41:40 +05:30