Skip to content

feat: story prompt customisation, LLM Q&A chat, and filter execution fix#142

Merged
NotYuSheng merged 2 commits intomainfrom
feature/story-enhancements-and-filter-fix
Mar 31, 2026
Merged

feat: story prompt customisation, LLM Q&A chat, and filter execution fix#142
NotYuSheng merged 2 commits intomainfrom
feature/story-enhancements-and-filter-fix

Conversation

@NotYuSheng
Copy link
Copy Markdown
Owner

Summary

  • Story enhancements (closes feat: allow users to customise the story generation prompt #135): optional additional-context field for generation, collapsible info card (default minimised), StoryChat component with continuous LLM conversation, dynamic suggested questions on generation and after each answer
  • Hibernate warning fix: remove @CreationTimestamp from StoryEntity.created_at — let DB DEFAULT CURRENT_TIMESTAMP handle it instead of causing a PreparedStatementDetails warning in the batch pipeline
  • Filter execution fix: tshark 3.6.2 silently produces no output when -Y is combined with -T fields; replaced with -2 -R (two-pass read filter) in both validateDisplayFilter and filterPackets

Changes

Backend

  • GenerateStoryRequest — optional additionalContext body field for POST /story/generate/{fileId}
  • StoryQuestionRequest — question + full conversation history for POST /story/{storyId}/ask
  • StoryAnswerResponse — includes followUpQuestions: List<String> alongside answer
  • StoryService — threads additionalContext into the user prompt; askQuestion returns JSON {answer, followUpQuestions} in one LLM call; suggestedQuestions added to story generation schema and parsed
  • StoryEntitycreated_at marked insertable=false, @CreationTimestamp removed
  • FilterServicevalidateDisplayFilter and filterPackets changed from -Y to -2 -R

Frontend

  • StoryInfoCard — collapsible (default closed), context textarea inside card body with suggestion placeholder text
  • StoryChat — chat bubble UI, scrolls within card (no page jump), suggestion buttons above input, refreshed after each answer, conversation history sent with every request
  • StoryPage — wires context + storyId through to both components
  • Story type — suggestedQuestions?: string[]

Test plan

  • Generate a story — 3 suggested questions appear in the chat card
  • Ask a question — answer appears, 3 follow-up suggestions replace the previous ones
  • Ask a follow-up referencing the previous answer — LLM uses conversation history correctly
  • Leave additional-context blank — story generation unchanged
  • Add additional context, regenerate — context is appended to prompt
  • Execute a filter on a PCAP — matching packets returned (not empty)
  • Execute an invalid filter — still gets rejected with a syntax error message

🤖 Generated with Claude Code

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an interactive Q&A feature for network traffic stories, enabling users to ask the LLM specific questions about the analysis. Key changes include the addition of a StoryChat frontend component, new backend endpoints for Q&A and context-aware story generation, and updates to the tshark filtering logic. The review feedback suggests improving the API controllers by using UUID types for path variables to leverage Spring's automatic validation and removing redundant fully qualified class names in the service layer.

Comment thread backend/src/main/java/com/tracepcap/story/controller/StoryController.java Outdated
Comment thread backend/src/main/java/com/tracepcap/story/controller/StoryController.java Outdated
Comment thread backend/src/main/java/com/tracepcap/story/controller/StoryController.java Outdated
Comment thread backend/src/main/java/com/tracepcap/story/controller/StoryController.java Outdated
Comment thread backend/src/main/java/com/tracepcap/story/service/StoryService.java Outdated
…fix (#135)

Story enhancements:
- Add optional additional-context textarea to story generation (frontend + backend)
- Collapse StoryInfoCard by default; move context field inside it below the info
- Add StoryChat component: LLM Q&A with continuous conversation history, suggested
  follow-up questions generated per response, scroll-within-card (no page jump)
- LLM generates 3 dynamic suggested questions when story is created (suggestedQuestions
  in JSON schema); follow-up questions regenerated after each answer
- Fix Hibernate PreparedStatementDetails warning: remove @CreationTimestamp, mark
  created_at as insertable=false (DB DEFAULT CURRENT_TIMESTAMP handles it)

Filter fix:
- Replace -Y (single-pass display filter) with -2 -R (two-pass read filter) in both
  validateDisplayFilter and filterPackets — tshark 3.6.2 silently drops -T fields output
  when -Y is combined with it
- Fix tcp.flags.rst → tcp.flags.reset: invalid field name caused tshark to reject the
  entire command and return zero output regardless of filter matches

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NotYuSheng NotYuSheng force-pushed the feature/story-enhancements-and-filter-fix branch from 416ab7b to 9b5a7ec Compare March 31, 2026 13:27
@NotYuSheng
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an interactive Q&A feature for network traffic stories, allowing users to ask follow-up questions to the LLM. Key changes include new backend endpoints and service logic for handling conversation history and suggested questions, along with the addition of a StoryChat frontend component. The StoryInfoCard was also updated to allow users to provide additional context during story generation. Furthermore, tshark command arguments were adjusted for improved filtering compatibility. The review feedback suggests enhancing type safety by using UUID for path variables and simplifying redundant class references.

Comment thread backend/src/main/java/com/tracepcap/story/controller/StoryController.java Outdated
Comment thread backend/src/main/java/com/tracepcap/story/controller/StoryController.java Outdated
Comment thread backend/src/main/java/com/tracepcap/story/service/StoryService.java Outdated
- Use UUID path variable types directly in StoryController (generateStory, askQuestion)
  so Spring handles conversion and returns 400 for invalid UUIDs instead of 500
- Remove redundant UUID.fromString() calls now that path vars are already UUID
- Use StoryQuestionRequest.HistoryEntry (short form) instead of fully qualified name
  since com.tracepcap.story.dto.* is already imported

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NotYuSheng NotYuSheng merged commit 5d87e01 into main Mar 31, 2026
@NotYuSheng NotYuSheng deleted the feature/story-enhancements-and-filter-fix branch March 31, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: allow users to customise the story generation prompt

1 participant