Commit Graph

746 Commits

Author SHA1 Message Date
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 7b4afc8652 SimpleChatTCRV:UICleanup: Scrollbar, role gradiants, textarea, ...
Reduce fullbody height by a tiny bit so that everything fits within
the overall height of the screen available, without needing a dummy
no use vertical scrollbar for full body. Rather its hardcoded for
now, in a sense, need to look into all elements competing for vertical
space and see how to make this auto adapt responsively, if there is
any subtle issue beyond me going beyond 100vh.

Set scrollbar in general to thin and minimal contrast subdued look.

Change user gradiant to blue hue, also add a subtle whitish hue based
gradiant to assistant chat messages. Also make trimmed content bgnd
a gradiant.

Wrt print media target, instead of trying to change the body color
directly, use the global variable added for same, so that other elements
also adjust suitably wrt the change like gradiants merging seemlessly
into the changed overall background and so.

Allow the input textarea to grow vertically to an extent, while still
ensuring that it doesnt cross a limit which could lead to additional
full page scrollbar showing up.

Add a border-radius by default across elements. In turn add padding
wrt toolcall details block so that things dont get cutoff and appear
proper.
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 92bd3557d5 SimpleChatTCRV:UI theme cleanup - html+css r3
Move the heading, sessions list and system prompt into a details
block so that user can hide them if required.

avoid the borders around chat message blocks and the chat message
role blocks within them, instead go for a subtle box shadow.

Use gradiants wrt heading, as well as chat message role based color
codings.

Update both the normal/screen view as well as the print view wr
above.
2025-12-04 19:41:40 +05:30
hanishkvc 9f782d70b8 SimpleChatTCRV:UI theme simple cleanup - css round 2
Have a common 1vmin radius wrt buttons in general and chat messages.

While the input area and its buttons have more rounded look.

Force a minimum height wrt the buttons in general, while ensuring
that the popover menu buttons tightly fit the content/icons in them.
2025-12-04 19:41:40 +05:30
hanishkvc 9baece7c93 SimpleChatTCRV:UI theme simple cleanup
Use slight off white body background & make user input area whiter.

Allow button and input area to have rounded borders.

Also adjust the rounding wrt chat messages and popover menu btns.
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
hanishkvc a49774817b SimpleChatTCRV:UICleanup: User Input area one bunch of clenaup
ui_reset_userinput now resets role associated with user input to
user always.

chat_show now does a full on ui_reset_userinput, and thus inturn
session switching now force cleans up User Input area, state and
associated data (like dataURLs) with chat_show->ui_reset_userinput.

UIRefresh helper does a partial ui_reset_userinput thus cleaning
up the user input state. Inturn given that addsmart_uishow calls
uirefresh, so avoid calling partial ui_reset_userinput after call
to addsmart_uishow.

show_message now sets user input area role to either ToolTemp or
User (all cases other than ToolTemp).
2025-12-04 19:41:40 +05:30
hanishkvc 735a8b382c SimpleChatTCRV:Cleanup: Starting flow, cleanup description, readme
Avoid chat_show getting called twice during starting.

Update description of sys_date_time to be more verbose

Update the readme DONE section, where I had few days back forgotten
and started making entries as parts of a item list or so.
2025-12-04 19:41:40 +05:30
hanishkvc c4cbeba463 SimpleChatTCRV:Cleanup:MouseEvents demote, UIRefreshy almost all
Demote the Popover related mouse event trapping related logs to
debug level, as they are no longer required.

Avoid using brute force chat_show instead use only the optimal
chat_uirefresh wrt all paths in handle_user_submit, rather had
forgotten to change previously.
2025-12-04 19:41:40 +05:30
hanishkvc c84ec53511 SimpleChatTCRV:UICleanup: loading message wrt restoring session
also update some notes
2025-12-04 19:41:40 +05:30
hanishkvc 511fcb0016 SimpleChatTCRV:UICleanup: Use chat_uirefresh not chat_show
Rename chatmsg_ui_refresh to chat_uirefresh.

Even in case of the delete path and inturn deleting one of the last
two messages in a chat session, now use the generified chat uirefresh
logic instead of the chat_show full session refresh / recreation of
the session ui

Inturn to make the uirefresh really generic and usable in all cases
including above case, now take care of clearing the tool call edit
/ trigger at the beginning, so that the last 2 messages decide in
turn whether to show a tool call edit/trigger ui or not, as well as
the tool call response edit / submit ui.
2025-12-04 19:41:40 +05:30
hanishkvc dda9f81d37 SimpleChatTCRV:UICleanupPlus: Fix oversights with initial go 2025-12-04 19:41:40 +05:30
hanishkvc 9ddd923412 SimpleChatTCRV:UI Flow cleanup plus
SC.add discards any temp role message and not just tool temp msg

New SC.add_smart which either adds a new message to the chat session
or replaces existing last message in the chat session, based on same
role or different, given that the chat session cant have the same
role type chat message occuring adjacent in it. Inturn rename MCUI
chatmsg_add_uishow to chatmsg_addsmart_uishow and use add_smart

* helps wrt trying to rerun a tool call with modified args or so.
  Rather prev discard temp role messages in SC.add not good enough
  as uniqId will change in its case.
  Helps avoid adding duplicate ToolTemp messages in chat session ui

* can help if loading a prev chat session which ended in a user
  message without a ai response. User can type in a new message
  and continue that old chat session, with the new message, replacing
  the old user message as well as initiating handshake with ai server
  in a proper manner.

Replace MCUI chatmsg_ui_updateprev_appendlast with chatmsg_ui_refresh
which is a more generic flow, which takes care of updating the ui as
needed irrespective of if the specified set of messages are already
in the chat session ui or not. Also allows the caller to control how
many messages at the end need to be refreshed wrt ui.
2025-12-04 19:41:40 +05:30
hanishkvc 161714f56e SimpleChatTCRV:CMUI:Scroll into view in optimized ui flows 2025-12-04 19:41:40 +05:30
hanishkvc d18745d02f SimpleChatTCRV:CMUI: remove live element, uidelete all matching 2025-12-04 19:41:40 +05:30
hanishkvc d29201be3d SimpleChatTCRV:Cleanup:Distinguish btw uiremove & del_uiupdate
Needed as some places we require to delete the chat message as
well as update the corresponding ui block.

And in other places we require to just remove the ui block from
chat session ui and not the underlying chat message from chat history.

Change ui updateprev appendlast to use the ui remove logic.
2025-12-04 19:41:40 +05:30
hanishkvc a2698d0521 SimpleChatTCRV:CMOptimisedShow: User respones
Now even the user response handling flow (handle_user_submit) has
been updated to use the optimised chat show logic which adjusts
/ updates the chat session ui wrt the last two messages only and
not the full chat history in the chat session.

Move the logic wrt last two messages and ui, into its own func
and inturn use it everywhere as required.
2025-12-04 19:41:40 +05:30
hanishkvc 3e20b5c680 SimpleChatTCRV:MCUI:CMAddShow:tool response happy path
Rename lastMsg to prevLastMsg to match semantic better

Return seperate flags to indicate add and show success or not

Update tool response happy path to use this optimised add show
instead of chat_show (which recreates the full chat session ui).
2025-12-04 19:41:39 +05:30
hanishkvc 1b4e1aa682 SimpleChatTCRV:MCUI:ChatMsgAddShow, Use4 toolresp nonhappy paths
Make the toolresp non happy path use a direct insert chat msg
wrt ui, rather than recreating the full chat session ui fresh.
2025-12-04 19:41:39 +05:30
hanishkvc 926b5cd8f3 SimpleChatTCRV:Cleanup:Delete and Chat UI suitable update
If deleting a non last (and non just before last) message, then
just directly remove the corresponding chat message block from the
ChatSession UI and be done with it.

However if deleting the last (or just before last) message, then
one needs to decide on whether tool call edit/trigger ui is shown
or removed and so... and similarly wrt tool response edit/submit.
2025-12-04 19:41:39 +05:30
hanishkvc f3424d3a2a SimpleChatTCRV:Cleanup: Efficient ChatMessage Ui Delete
avoid refreshing the full chat session messages ui

also Update readme
2025-12-04 19:41:39 +05:30
hanishkvc 95f79eb8b0 SimpleChatTCRV:CleanUp: Refresh chat ui, if user empty submits
This ensures that the tool call edit/trigger is reshown, when user
submits a empty response and the logic stops from going ahead.
2025-12-04 19:41:39 +05:30
hanishkvc efcd81aa2f SimpleChatTCRV:SimpleProxy:DumpHeaders 2025-12-04 19:41:39 +05:30
hanishkvc 67b9c68b3e SimpleChatTCRV: Update readme a bit, need to cleanup later 2025-12-04 19:41:39 +05:30
hanishkvc e731d29dc9 SimpleChatTCRV:Cleanup:Delete keeps view around adjacent messages
Rename to get_chatmessage_index.

Return the index of the chatmessage deleted.

Add a scroll element into view helper.

Now the UniqId wrt the ChatMessage is stored as a attribute
wrt the corresponding chatmessage block. And same used wrt
scrolling after deleting messages.

When a chat message is deleted, previously the screen would have
moved to last message in the chat session, now it tries to remain
wrt adjacent messages on the screen.
2025-12-04 19:41:39 +05:30
hanishkvc c0dbc1d59c SimpleChatTCRV:ChatMessage:Copy using PopOver menu & navigator
Currently only the text/content part is handled wrt copy. Image
URL isnt handled, even if present.
2025-12-04 19:41:39 +05:30
hanishkvc 6a67d002d6 SimpleChatTCRV:CMPopOver:Relative positioning - P2
As position-area is not yet officially supported in firefox (its
only in nightly builds, as of now), so switching to the inset
block/inline start/end css properties.
2025-12-04 19:41:39 +05:30
hanishkvc 70a163fd18 SimpleChatTCRV:CMPopOver:Relative positioning - P1
Use position fixed followed by using position-area so that one
can use anchor passed through showPopover.

Avoid the hidePopover from mouseLeave, because as the mouse moves
over the poped up popover ui, the mouseLeave will be called on
the chat message block/container. And that would have closed the
popover and inturn mouseEnter would have got called on ChatMsg,
given now with the popover hidden, the ChatMsg block is directly
accessible. So this leads to twinkling / toggling ie continues
show/hide of the popover.

Inturn in mouseEnter itself decide when to close the previous
popover (ie if the chatmessage id is different from what it was
before).
2025-12-04 19:41:39 +05:30
hanishkvc 62fb992e0e SimpleChatTCRV:CMPopOver: show within chatmessage, del logic
Trap the mouseenter and mouseleave events wrt the chatmessage
block to show the chatmessage-popover ui inturn within the
corresponding chatmessage.

When ever user clicks the popover menu's delete button, the
uniqId associated with each chat message, is now used to
delete the user selected chat message.

Initial skeleton wrt clipboard copy.
2025-12-04 19:41:39 +05:30
hanishkvc 1d2ef9dddb SimpleChatTCRV:ChatMessage: UniqId, Delete logic, edit popover ui 2025-12-04 19:41:39 +05:30
hanishkvc dc71a9be4c SimpleChatTCRV:Remember to reset the Input File type value 2025-12-04 19:41:39 +05:30
hanishkvc a2a0a378a9 SimpleChatTCRV: Response handling try catch, update errors
Had forgotten to move the one shot resp into try catch before.
Fixed it. Ensure both oneshot multipart resp try catch

Add some todos for later.

Add a new check wrt response being normal or a error related one
ie the content is actually a error message.
2025-12-04 19:41:39 +05:30
hanishkvc 18b94482c5 SimpleChatTCRV:InputFileDialog:AcceptList:Images:Jpeg and Png
Allow passing the accept list for file type input element helper.

Inturn given that currently it is used for the image selection
for vision models, set it to jpeg and png in the caller for the
same.
2025-12-04 19:41:39 +05:30
hanishkvc ca8e6ab1a6 SimpleChatTCRV:iDB:GetKeys: helps decide whether restore btn shown 2025-12-04 19:41:39 +05:30
hanishkvc 570131943f SimpleChatTCRV:iDB:Add Put/Get; SimpleChat Save/Load using iDB
Added put and get helpers wrt indexedDB.

Updated save and load related logics in SimpleChatTCRV.
2025-12-04 19:41:39 +05:30
hanishkvc 52cce3e5f7 SimpleChatTC:IDBHelper: Move core indexedDB helper as a module
ie opening db as well as a transaction to access a store within
the db.
2025-12-04 19:41:39 +05:30
hanishkvc f8c0fe6845 SimpleChatTCRV:UICleanup: gradient wrt heading
and placeholders for few other logical elements
2025-12-04 19:41:39 +05:30
hanishkvc f8af792dc2 SimpleChatTCRV:UICleanup: ObjInfo dClassNames
Distinguish between top level and remaining levels.

More flexibility and also cleaner flow
2025-12-04 19:41:39 +05:30
hanishkvc dac97c1e8f SimpleChatTCRV:UI Cleanup: DetailsNotDiv Current settings info
So that we dont overload users with the details by default, but
user can open or close the block of current settings info details.
2025-12-04 19:41:39 +05:30
hanishkvc c94471a56f SimpleChatTCRV:UI Cleanup: scrollOnlyIf, Tool HR, Msg Margin
Limit scroll to veritical dir and inturn show only when needed

Move the Tool Call Edit UI's HR into its div.

Add a bottom margin wrt the individual chat messages.
2025-12-04 19:41:39 +05:30
hanishkvc 29c2bafec8 SimpleChatTCRV:HandleUserSubmit:details of internaly caught exc
If a caught error had chained in details about what triggered it
in the 1st place, then show it also to user.
2025-12-04 19:41:39 +05:30
hanishkvc 13c1c9d285 SimpleChatTCRV:Vision: DataUrl helpers
Move all dataUrl handling into helper functions.

So that its manipulation is done in a controlled manner, as well as
in future, changes to the semantic can be easily carried out by
updating the helper functions suitably and inturn updating the caller
as needed.

For now avoid push and pop and work with 0th index directly, given
that currently the logic is setup for handling only a single image
with the ai model. This keeps things simple. It can be changed if
required in future easily.
2025-12-04 19:41:39 +05:30
hanishkvc 4e4dc30ffe SimpleChatTCRV:Vision:HandleUserSubmit: Ensure cleanup even early
There can be issue with chat.add->chat.save, in that trying to
store into localStorage or so can raise exception, like quota
exceeded and so.

So now trap chat.add also and inturn for now take care of clearing
image state while also trapping and rethrowing a new error which
identifies the above location, as well as tracks the original err
2025-12-04 19:41:39 +05:30
hanishkvc 4ee6e271fb SimpleChatTCRV:Vision:Show user image selection in btn
Add a new helper to create a file type input which includes a btn
with image. Use same wrt the user image selection button.

Update button creation helper to show innerText only if the newly
added innerHTML arg is undefined.

When ever user makes a image selection, the image will be shown
in the input-filetype-image-button. In turn when the same is
submitted to ai engine server, the image will be cleared.
2025-12-04 19:41:39 +05:30
hanishkvc 8d762fcf3f SimpleChatTCRV:Vision:Show images as part of the message 2025-12-04 19:41:39 +05:30
hanishkvc a6b5555fe5 SimpleChatTCRV:Submit: Remember to include image, if available
Also rename the id/label of InFile+Btn to Image.

Extra fields while Adding.
2025-12-04 19:41:39 +05:30
hanishkvc 930fd656b9 SimpleChatTCRV:Basic skeleton to load a dataUrl 2025-12-04 19:41:39 +05:30
hanishkvc da75564d26 SimpleChatTCRV:Vision: Add file input to get hold of img file
If I cant control the look of the file type input, I may have to
hide it and use a normal button, which chains into file selection
or so
2025-12-04 19:41:39 +05:30
hanishkvc dfba64e0ae SimpleChatTCRV:Vision: Create needed MixedContent b4 nw handshake 2025-12-04 19:41:39 +05:30
hanishkvc 72f62eed0f SimpleChatTC:Vision: take care of image_url wrt newFrom & load 2025-12-04 19:41:39 +05:30
hanishkvc 5db6f927df SimpleChatTC:Vision: Prepare NSChatMessage for Text &| Image
Avoid directly accessing content field, from any place other than
where it is absolutely requried.

Add a bOverwrite field to the content_adj helper, so that one can
overwrite instead of appending passed content to whats already in.

* this is currently used only wrt
  * promote_tooltemp helper
  * trim garbage helper
* the oneshot could ideally use overwriting, but currently
  not doing as this flow will occur only once per message

Add a image_url field for the image url with image data in dataurl
format with base64 encoded image data.
2025-12-04 19:41:39 +05:30
hanishkvc 8079618c85 SimpleChatTC:Alert end user in case emtpy message to ai
Currently the logic doesnt allow user to send a empty message to
ai, during their term. Previously this path wasnt directly alerting
the end user. Now it informs the end user using placeholder property
so they can see the alert, while also ensuring that once user enters
something, the alert wont interfere.

The logic takes care of saving any original placeholder, so that
the same is restored, when user switches sessions.
2025-12-04 19:41:39 +05:30
hanishkvc eaffdf3535 SimpleChatTC:NSChatMessage:ToolResult User Input Background color
Use css conditional attribute styling to change background color
of the user input textarea to match the tool role message block
color, when the user input textarea is in the TOOL.TEMP mode

With this user can know that the user input area is currently
showing and accepting tool result data for submission.
2025-12-04 19:41:39 +05:30
hanishkvc fe0cc8bef1 SimpleChatTC:NSChatMessage: fix up initial go
Allow for empty tool call results

Block no content response from user role only.

Also change for console.debug to console.log so people can
see the blocking of empty response from user, in the browser
console.
2025-12-04 19:41:39 +05:30
hanishkvc b4aaf5bd1b SimpleChatTC:NSChatMessage:Tool role newFromOld and load fixup
Had forgotten to update these two functions wrt the tool response
related new fields. This is fixed now.

Also show tool-call-id and tool-name to end user as part of chat
message showing.

ALERT on disk structure change old saves wont work esp wrt tool
responses
2025-12-04 19:41:39 +05:30
hanishkvc b9defe2843 SimpleChatTC:NSChatMessage: Handle edits by user wrt tool response 2025-12-04 19:41:39 +05:30
hanishkvc 3d4f84947a SimpleChatTC:NSChatMessage:ToolResponse show handling
Given that the user query box no longer includes the special xml
string wrt tool response data (TOOL.TEMP ROLE), so now instead set
a special attribute to indicate that user query/input box is
maintaining a tool response.

For regular Tool responses in the chat session, now show the tool
call id and tool name before the tool response data (ie content
field).
2025-12-04 19:41:39 +05:30
hanishkvc b251f7de7c SimpleChatTC:NSChatMessage with tool response/result fields
Add a new static helper to create a ChatMessageEx for a given
tool response data.

Use the same when storing tool response in the chat session msgs
list.

This inturn avoids the need for creating a xml string with all
the fields corresponding to tool response. So also no need to
extract the individiual tool response fields from the all-in-one
xml string and populate the tool response fields in the network
structure equivalent ns data structure, when recent_chat_ns is
called.
2025-12-04 19:41:39 +05:30
hanishkvc 7a61ca6aac SimpleChatTC:NSChatMessage: MultiChatUI and beyond updated for same
TODO: individual tool/function calls from tool_calls field, accessed
using different methods in different places for now. Need to think
on which is the best method to retain and use everywhere and or
retain things as is.
2025-12-04 19:41:39 +05:30
hanishkvc 9bd754d594 SimpleChatTC:NSChatMessage: Update SimpleChat to use same
Remove the load from disk support that was previously retained
wrt the old on-disk-storage format for the chat session messages.

Make a note to allow non ai server handshake roles to be maintained
wrt NSChatMessage. Add helper to cross check if a message belongs
to such temp roles or not.

Update SimpleChat class to make use of the new NSChatMessage based
needed flow.
2025-12-04 19:41:39 +05:30
hanishkvc 70b754c5a6 SimpleChatTC:NSChatMessage class driven wrt ChatMessageEx
NSChatMessage implements the undefined based flow and provides
helpers to check if any of the field like content or reasoning
or tool_calls is available in the chat message or not.

It also provides helpers to get the corresponding fields.

ChatMessageEx updated to make use of NSChatMessage.
2025-12-04 19:41:39 +05:30
hanishkvc b2d53c1e14 SimpleChatTC:ChatMessage undefined driven
Switch from empty strings or empty list and so to undefined.

undefined will be treated by Javascript and JSON to mean, not even
instantiated and also dont instantiate the same
2025-12-04 19:41:39 +05:30
hanishkvc 9484bea71a SimpleChatTC:PdfText:Basic Outline and its Numbering done
Pass a list to keep track of the numbering at different depths
as well as to delay incrementing the numbering to the last min

Dont let recursion go beyond a predefined limit
2025-12-04 19:41:39 +05:30
hanishkvc 15e99843db SimpleChatTC:PdfText:Numbering T2 - Need diff scheme
This increaments before itself, but we need to increment after
2025-12-04 19:41:39 +05:30
hanishkvc bd60437cc6 SimpleChatTC:PdfText: Numbering T1 - Diff Scheme needed
This simple scheme doesnt work. Rather the pdf outline seems
to follow below logic

If a child list is found when processing the current list, dont
increment the numbering.
2025-12-04 19:41:39 +05:30
hanishkvc 51707b5169 SimpleChatTC:PdfText:Add initial skeleton for outline 2025-12-04 19:41:39 +05:30
hanishkvc 272e2689f7 SimpleChatTC:Get body also for Not Ok responses from ai server
Rather a chat with gpt-oss generated a assistant response which
included chat-content, chat-reasoning and chat-toolcall all in the
same response. On responding to same with tool call result, the
server http handshake responded with a 500 Internal server error,
So added this to get more details in this case, as well as in
general for future.
2025-12-04 19:41:39 +05:30
hanishkvc 0628226ea1 SimpleChatTC:XmlFiltered: Avoid showing skipped tags as no content
Dont even insert skipped tags as tag blocks with empty content.

This should make the resultant xml cleaner and make it use less
space.
2025-12-04 19:41:39 +05:30
hanishkvc 143f9c0b1a SimpleChatTC:Rename fetch_web_url_text to fetch_html_text
To make it easier for the ai model to understand that this works
mainly for html pages and not say xml or pdf or so. For those
one needs to use other explict tool calls provided like fetchpdftext
or fetchxmltext or so

The server service path renamed from urltext to htmltext.

SearchWebText also updated to use htmltext now
2025-12-04 19:41:39 +05:30
hanishkvc c0f7c8654e SimpleChatTC:ShowToolCall: Trap invalid args generated by GenAi 2025-12-04 19:41:39 +05:30
hanishkvc 9f5c3d7776 SimpleChatTC:XmlFiltered: Use re with heirarchy of tags to filter
Rename xmltext to xmlfiltered.

This simplifies the filtering related logic as well as gives more
fine grained flexibility wrt filtering bcas of re.
2025-12-04 19:41:39 +05:30
hanishkvc 9ed1cf9886 SimpleChatTC:XMLFiltered: Retain xml tags with selective dropping
instead of the prefixing of tag heirarchy retain the xml structure
while parallely allowing unwanted tags and their contents to be
dropped.
2025-12-04 19:41:39 +05:30
hanishkvc b8bb258dd5 SimpleChatTC:XmlText: Cleanup initial go
At simpleproxy end

* Add the tag names hierarchy before contents of a tag

* Remember to convert the tagDrops to small case as HTMLParser base
  class seems to do that by default.

At the client ui end

* if undefined remember to pass a empty list wrt tagDrops.

* cleanup the func description and also mention possible tagDrops
  for RSS feeds in the tool meta
2025-12-04 19:41:39 +05:30
hanishkvc fbe9b2369f SimpleChatTC:XmlText: Add plumbing on web client ui ie js side
Add the meta data for the fetch xml as text tool call

Implement the handler and the setup tool call plumbing logic
2025-12-04 19:41:39 +05:30
hanishkvc 92b0dd7d36 SimpleChatTC:SimpleProxy:XMLText: initial go
Take the existing urltext logic including its html parser and
strip it out to be simpler.
2025-12-04 19:41:39 +05:30
hanishkvc 899dff4eb4 SimpleChatTC:IndexHTML:Fix a oversight with new module added
Add forgotten to add , after simplechat entry.

Currently I am not strictly using the importmap feature, so the
error didnt create any problem, but the error was there which has
been fixed.
2025-12-04 19:41:39 +05:30
hanishkvc f7cff8232d SimpleChatTC:TCPending: Clear pending in unhappy paths
ie if exception raised during tool call execution and or time out
occurs
2025-12-04 19:41:39 +05:30
hanishkvc 313b5f6db7 SimpleChatTC:TrackToolCalls:helps ignor delayed response, if reqd
Add a pending object which maintains the pending toolcallid wrt
each chat session, when ever a tool call is made.

In turn when ever a tool call response is got cross check if its
toolcallid matches that in the pending list. If so accept the
tool call response and remove from pending list. If not just
ignore the response.

NOTE: The current implementation supports only 1 pending tool call
at any time.

NOTE: Had to change from a anonymous to arrow function so as to
be able to get access to the ToolsManager instance (this) from
within the function. ie make use of lexical binding semantic of
arrow functions.
2025-12-04 19:41:39 +05:30
hanishkvc b2e7f5fd44 SimpleChatTC:ToolsManager: Cleanup inc delayed direct posting
Me.tools.toolNames is now directly updated by init of ToolsManager

The two then in the old tools.init was also unneeded then also as
both could have been merged into a single then, even then. However
with the new flow, the 1st then is no longer required.

Also now the direct calling of onmessage handler on the main thread
side wrt immidiate result from tool call is delayed for a cycling
through the events loop, by using a setTimeout.

No longer expose the tools module throught documents, given that
the tools module mainly contains ToolsManager, whose only instance
is available through the global gMe.

Move the devel related exposing throught document object into a
function of its own.
2025-12-04 19:41:39 +05:30
hanishkvc 4d71ded5df SimpleChatTC:ToolsManager: Instantiate in Me and Use
Rename Tools to ToolsManager to convey its semantic better.

Move setup of workers onmessage callback as well as directly passing
result to these callbacks into ToolsManager.

Now that Workers have been moved into ToolsManager, and ToolsManager
has been instantiated as a member of Me, use the same in place of
prev workers of Me.
2025-12-04 19:41:39 +05:30
hanishkvc 2534af8215 SimpleChatTC:Rather bring in Tools Class
So that all tools related management logic sits in tools module
itself, but is accessible from Me by having a instance of Tools.

The Workers moved into Tools class.

The tc_switch moved into Tools class.

The setup_workers, init, meta and tool_call moved into Tools class.
2025-12-04 19:41:39 +05:30
hanishkvc 0e7fe8bcf2 SimpleChatTC:MeInTools: WebWorkers in Me
Given that Me is now passed to the tools logic during setup, have
the web worker handles in Me itself, instead of in tool related
modules.

Move setup of web worker related main thread callbacks, as well as
posting messages directly to these main thread callbacks, into Me.
2025-12-04 19:41:39 +05:30
hanishkvc 85c2779579 SimpleChatTC:Cleanup:MeInTools: update tools, toolweb
Now gMe can be used in toolweb with proper knowledge of available
members and can also be cross checked by tools
2025-12-04 19:41:39 +05:30
hanishkvc d56a4a06b0 SimpleChatTC:Cleanup:Make main chat related classes importable
Have main classes defined independent of and away from runtime flow

Move out the entry point including runtime instantiation of the
core Me class (which inturn brings other class instances as neede)
into its own main.js file.

With this one should be able to import simplechat.js into other
files, where one might need the SimpleChat or MultiChat or Me class
definitions.
2025-12-04 19:41:39 +05:30
hanishkvc 83a4b1a3fa SimpleChatTC:System Date and Time 2025-12-04 19:41:39 +05:30
hanishkvc d6fd4ea533 SimpleChatTC:FetchPdfAsText: Renamed function call
Some ai's dont seem to be prefering to use this direct helper
provided for fetching pdf as text, on its own. Instead ai (gptoss)
seems to be keen on fetching raw pdf and extract text etal, so now
renaming the function call to try and make its semantic more
readily obivious hopefully.

It sometimes (not always) seem to assum fetch_web_url_text, can
convert pdf to text and return it. Maybe I need to place the
specific fetch pdf as text before the generic fetch web url text
and so...

With the rename, the pdf specific fetch seems to be getting used
more.
2025-12-04 19:41:39 +05:30
hanishkvc 0fcb13257c SimpleChatTC:UI:ClearChat, Unicode icons for Clear, settings
Allow user to clear the existing chat. The user does have the
option to load the just cleared chat, if required.

Add icons wrt clearing chat and settings.
2025-12-04 19:41:39 +05:30
hanishkvc 2394d38d58 SimpleChatTC:Cleanup: General T2
Pretty print SimpleProxy gMe config

Dont ignore the got http response status text.

Update readme wrt why autoSecs
2025-12-04 19:41:39 +05:30
hanishkvc c5ff065ad2 SimpleChatTC:Cleanup in general
Update readme wrt searchDrops, auto settings ui creation

Rename tools-auto to tools-autoSecs, to make it easy to realise
that the value represents seconds.
2025-12-04 19:41:39 +05:30
hanishkvc c316f5a2bd SimpleChatTC:WebTools:UrlText:HtmlParser: tag drops - refine
Update the initial skeleton wrt the tag drops logic

* had forgotten to convert object to json string at the client end
* had confused between js and python and tried accessing the dict
  elements using . notation rather than [] notation in python.
* if the id filtered tag to be dropped is found, from then on
  track all other tags of the same type (independent of id),
  so that start and end tags can be matched. bcas end tag call
  wont have attribute, so all other tags of same type need to
  be tracked, for proper winding and unwinding to try find
  matching end tag
* remember to reset the tracked drop tag type to None once matching
  end tag at same depth is found. should avoid some unnecessary
  unwinding.
* set/fix the type wrt tagDrops explicitly to needed depth and
  ensure the dummy one and any explicitly got one is of right type.

Tested with duckduckgo search engine and now the div based unneeded
header is avoided in returned search result.
2025-12-04 19:41:39 +05:30
hanishkvc 06fd41a88e SimpleChatTC:WebTools: urltext-tag-drops python side - skel
Rename search-drops to urltext-tag-drops, to indicate its more
generic semantic. Rather search drops specified in UI by user
will be mapped to urltext-tag-drops header entry of a urltext
web fetch request.

Implement a crude urltext-tag-drops logic in TextHtmlParser.
If there is any mismatch with opening and closing tags in the
html being parsed and inturn wrt the type of tag being targetted
for dropping, things can mess up.
2025-12-04 19:41:39 +05:30
hanishkvc f75bdb0e00 SimpleChatTC:WebTools And Search - headers and search drops - js
Allow the web tools handshake helper to pass additional header
entries provided by its caller.

Make use of this to send a list of tag and id pairs wrt web search
tool. Which will be used to drop div's matching the specified id.
2025-12-04 19:41:39 +05:30
hanishkvc 7fce3eeb2a SimpleChatTC:SettingsDefault:Enable cache prompt api option 2025-12-04 19:41:39 +05:30
hanishkvc 2cdf3f574c SimpleChatTC:SimpleProxy: Validate deps wrt enabled service paths
helps ensure only service paths that can be serviced are enabled

Use same to check for pypdf wrt pdftext
2025-12-04 19:41:39 +05:30
hanishkvc e6fd0ed05a SimpleChatTC: ToolCalling enabled, Sliding window adjust
Chances are for ai models which dont support tool calling, things
will be such that the tool calls meta data shared will be silently
ignored without much issue.

So enabling tool calling feature by default, so that in case one
is using a ai model with tool calling the feature is readily
available for use.

Revert SlidingWindow ChatHistory in Context from last 10 to last 5
(2 more then origianl, given more context support in todays models)
by default, given that now tool handshakes go through the tools
related side channel in the http handshake and arent morphed into
normal user-assistant channel of the handshake.
2025-12-04 19:41:39 +05:30
hanishkvc 1d1894ad14 SimpleChatTC:PdfText:Cleanup rename to follow a common convention
Rename path and tags/identifiers from Pdf2Text to PdfText

Rename the function call to pdf_to_text, this should also help
indicate semantic more unambiguously, just in case, especially
for smaller models.
2025-12-04 19:41:39 +05:30
hanishkvc 8501759f60 SimpleChatTC:Cleanup:UsageNote, Initial SettingsInfo shown
Usage Note
* Cleanup / fix some wording.
* Pick chat history handshaked len from config

Ensure the settings info is uptodate wrt available tool names
by chaining a reshowing with tools manager initialisation.
2025-12-04 19:41:39 +05:30
hanishkvc a4483e3bc7 SimpleChatTC:Cleanup Usage Note and its presentation a bit
Make it a details block and update the content a bit
2025-12-04 19:41:39 +05:30