Skip to content

Commit f38491d

Browse files
authored
Week 12 updates by Aman Naik (#409)
1 parent 3d3e48b commit f38491d

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: "DMP ’25 Week 12 Update by Aman Naik"
3+
excerpt: "This week focused on implementing persistent storage for chat history by integrating with Sugar’s Journal, ensuring continuity for students across sessions."
4+
category: "DEVELOPER NEWS"
5+
date: "2025-08-16"
6+
slug: "2025-08-16-dmp-25-AmanNaik-week12"
7+
author: "@/constants/MarkdownFiles/authors/amannaik247.md"
8+
tags: "dmp25,writeactivity,write,sugarlabs,week12,amannaik247"
9+
image: "assets/Images/c4gt_DMP.webp"
10+
---
11+
12+
<!-- markdownlint-disable -->
13+
14+
# Week 12 Progress Report by Aman Naik
15+
16+
**Project:** [Add an AI-assistant to the Write Activity](https://github.com/sugarlabs/write-activity/issues/52)
17+
**Mentors:** [Walter Bender](https://github.com/walterbender), [Ibiam Chihurumnaya](https://github.com/chimosky)
18+
**Reporting Period:** 2025-08-16 – 2025-08-23
19+
20+
---
21+
22+
## Goals for This Week
23+
24+
- Store chat history in the Sugar Journal for persistent storage
25+
26+
---
27+
28+
## This Week’s Achievements
29+
30+
1. **Implemented Journal-based Chat History Persistence**
31+
- Until now, conversations with Mary Tales were lost when the activity was closed, limiting continuity for students.
32+
- Leveraging Sugar’s existing Journal integration, I extended the `write_file` method to save chat history alongside document text.
33+
- This ensures that when students reopen the activity, whether the next day or after class, their previous chat is restored and they can continue seamlessly.
34+
35+
```python
36+
def write_file(self, file_path):
37+
logging.debug('AbiWordActivity.write_file: %s, mimetype: %s',
38+
file_path, self.metadata['mime_type'])
39+
40+
# ... exiting code to save canvas text
41+
42+
# Save conversation messages to metadata
43+
if hasattr(self, 'chat_sidebar') and hasattr(self.chat_sidebar, 'context') and hasattr(self.chat_sidebar.context, 'messages'):
44+
try:
45+
self.metadata['conversation'] = json.dumps(self.chat_sidebar.context.messages)
46+
except TypeError as e:
47+
logger.debug(f"Error serializing conversation messages in write_file: {e}")
48+
```
49+
50+
2. **Refined Data Handling with Journal Metadata**
51+
- Instead of generating separate JSON files for storing chat messages (which Sugar does not allow), I embedded serialized chat history into Journal metadata.
52+
- This approach keeps all user data consolidated in a single entry, aligning with Sugar’s design philosophy of having one canonical record per activity session.
53+
54+
---
55+
56+
## Challenges & How I Overcame Them
57+
58+
- **Challenge:** Finding a way to persist chat history without creating additional files
59+
**Problem:** My first approach involved writing a JSON file every time the activity closed. However, Sugar prohibits programmatically creating arbitrary files within its environment.
60+
**Solution:** After a discussion with my mentor Ibiam, I adopted Sugar’s built-in `read_file` and `write_file` methods to store metadata directly into the Journal entry. This allowed me to serialize and persist the chat state without breaking Sugar’s constraints.
61+
62+
---
63+
64+
## Key Learnings
65+
66+
- Learned how to extend Sugar’s `write_file` and `read_file` methods to handle custom metadata, enabling persistent storage beyond just document text.
67+
- Understood the importance of designing within platform constraints, as Sugar discourages arbitrary file creation and instead enforces centralized data storage through the Journal.
68+
- Realized that persistent context is essential for educational UX, as students benefit from being able to revisit and build upon previous conversations across multiple sessions.
69+
70+
---
71+
72+
## Next Week’s Roadmap
73+
74+
- Draft and finalize maintainer and user-facing documentation
75+
- Submit the final project reports
76+
- Prepare a presentation deck for the DMP final showcase
77+
78+
---
79+
80+
## Acknowledgments
81+
82+
Thanks to my mentor Ibiam for pointing me towards Sugar’s Journal `read_file`/`write_file` workflow, which turned out to be the correct and elegant solution for persisting chat history.
83+
84+
---

0 commit comments

Comments
 (0)