Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
9b9bead
creating workflows
paullizer Sep 23, 2025
92db48f
fraud analyssis
paullizer Sep 23, 2025
864a80e
support agents
paullizer Sep 23, 2025
4e98d2a
update
paullizer Sep 23, 2025
64080a5
fix
paullizer Sep 23, 2025
20dc12d
updated demo
paullizer Sep 23, 2025
8df0343
Swagger lite (#469)
paullizer Sep 29, 2025
d24ff83
adding support for xlsm, Macro Excel files.
paullizer Sep 29, 2025
446b71f
Merge branch 'workflows' into Development
paullizer Sep 29, 2025
e97d470
moved into features
paullizer Sep 29, 2025
adbed01
initial
paullizer Sep 30, 2025
3292be1
added readme
paullizer Sep 30, 2025
75ca487
removed html code
paullizer Sep 30, 2025
24528ac
Update config.py (#477)
Patrick-Davis-MSFT Oct 1, 2025
e37bf50
Initial Setup for Pages documentation (#479)
paullizer Oct 2, 2025
46b9163
initial
paullizer Oct 2, 2025
58b58b0
added to base
paullizer Oct 2, 2025
5cd2f28
adding real data endpoints
paullizer Oct 2, 2025
2e0942f
Update route_backend_control_center.py
paullizer Oct 2, 2025
6ec77ee
added individual charts
paullizer Oct 3, 2025
1eda535
fix for bug 485
nadoylemsft Oct 3, 2025
e42ce5c
added document metrics
paullizer Oct 4, 2025
b225502
added links to control center
paullizer Oct 4, 2025
7841e42
debug
paullizer Oct 5, 2025
f39da82
added date
paullizer Oct 6, 2025
a8221b9
fixed bugs due to branch descrepancies
cjackson202 Oct 6, 2025
3e3c8c8
added Azure SQL Driver Docker File
cjackson202 Oct 7, 2025
c93ea7b
added documentation for docker_fileSession updates
cjackson202 Oct 7, 2025
8c5c2ba
Redis Managed Identity Azure Government Support Changes
cjackson202 Oct 7, 2025
39b4528
Stop tracking ignored folders
cjackson202 Oct 8, 2025
ba1ca48
updated gitignore
cjackson202 Oct 8, 2025
95a7647
Merge branch 'cj-dev' into Development - Ensured ManagedIdentity supp…
cjackson202 Oct 8, 2025
711e0de
Merge pull request #488 from cjackson202/Development
Bionic711 Oct 10, 2025
6a3c322
Merge branch 'Development' into bugfix485
nadoylemsft Oct 10, 2025
71eff52
Merge pull request #487 from microsoft/bugfix485
Bionic711 Oct 10, 2025
33f5d8c
added sort by to table for user management
paullizer Oct 16, 2025
9e124ff
storage account size processing
paullizer Oct 16, 2025
fe75d09
Front end now shows storage account sizing
paullizer Oct 16, 2025
556f6d8
export user management list to csv
paullizer Oct 16, 2025
6e6c976
adding group management
paullizer Oct 16, 2025
f5fa596
fixing swagger generation
paullizer Oct 23, 2025
b412a60
fix
paullizer Oct 23, 2025
17e6fed
Added inline dynamic property generation
paullizer Oct 23, 2025
9ca0bf2
added YAML support
paullizer Oct 23, 2025
34b2b71
Improved muiltform vs app/json detection
paullizer Oct 23, 2025
5090eec
added Control Center Admin role
paullizer Oct 23, 2025
52ac365
ai search sizing is working for groups
paullizer Oct 24, 2025
0a0978e
group refresh fixed
paullizer Oct 24, 2025
c72dfe1
added group data fix
paullizer Oct 24, 2025
503a3e0
group table refresh
paullizer Oct 24, 2025
0f5c73f
updated export to include group docs
paullizer Oct 25, 2025
b4007c8
adding public workspace management
paullizer Oct 25, 2025
9eca474
removed sample data and consolidated row generators
paullizer Oct 25, 2025
8469bc7
Changed both caching helper functions to use the existing update_docu…
paullizer Oct 29, 2025
b520432
removed workflow, will work on that in different branch
paullizer Oct 31, 2025
044c7d9
Document Set Fingerprinting, Scope-Aware Cache Key Generation, Event-…
paullizer Nov 10, 2025
7ac37b4
added debug logging
paullizer Nov 10, 2025
3d84394
setup cache feature and ttl time to admin app settings
paullizer Nov 10, 2025
bf1f14a
removed cosmos level ttl
paullizer Nov 10, 2025
baa71a9
Keyvault for secrets (#492)
Bionic711 Nov 11, 2025
db74c0d
Feature/remove abp for pr (#510)
Bionic711 Nov 12, 2025
0fd0eae
Merge branch 'improved-search' into Development
paullizer Nov 12, 2025
2035b90
Feature/group agents actions (#521)
Bionic711 Nov 19, 2025
fab926b
Merge branch 'Data-and-Workspace-Management' into Development
paullizer Nov 19, 2025
ab0a4ef
Add cosmos activity logs container configuration
paullizer Nov 20, 2025
d50064a
incorporate branch updates Add 372 fix 489
paullizer Nov 21, 2025
41e924d
Support deployment via AZD UP (#530)
SteveCInVA Nov 23, 2025
e545917
Video Indexer, Multi-Modal Enhancements, Scope Bug
paullizer Nov 24, 2025
164459f
Conversation Management Features (#532)
paullizer Nov 24, 2025
3bf067a
Message management (#553)
paullizer Dec 19, 2025
c91d555
Configure Application from AZD Up command (#548)
SteveCInVA Dec 19, 2025
f7afced
Adds Azure Billing Plugin in Community Customizations (#546)
Bionic711 Dec 19, 2025
ef2a2a7
Security/container build (#549)
Bionic711 Dec 19, 2025
04b5c12
Feature/speech managed identity (#543)
Xeelee33 Dec 19, 2025
6a85856
Banner text color picker from Vivien (#555)
clarked-msft Dec 23, 2025
0e67ac8
Remove opencensus
clarked-msft Jan 5, 2026
460b14b
Merge pull request #559 from clarked-msft/remove-opencensus-requirement
Bionic711 Jan 6, 2026
1555dbf
Add flask instrumentation
clarked-msft Jan 6, 2026
40f5cfd
Add troubleshooting doc
clarked-msft Jan 6, 2026
74df9f8
Add troubleshooting doc
clarked-msft Jan 6, 2026
164dd80
Merge pull request #562 from clarked-msft/flask-intrumentor
Bionic711 Jan 6, 2026
3913480
Control center (#567)
paullizer Jan 13, 2026
a2bb469
Adding release notes
paullizer Jan 13, 2026
43989ac
Merge origin/main into Development - Resolved all conflicts
paullizer Jan 13, 2026
29dfbe0
fixed debug_debug_print
paullizer Jan 13, 2026
df2d77e
Updated README
paullizer Jan 13, 2026
2c7b627
Update README.md
paullizer Jan 13, 2026
9a8ce3b
Merge branch 'main' into Development
paullizer Jan 13, 2026
de013e4
accepted changes
paullizer Jan 13, 2026
49959e8
removed files
paullizer Jan 13, 2026
db0729e
GitHub Actions workflow that runs Python compilation checks on all Py…
paullizer Jan 13, 2026
1c3c133
Upated to v0.235.002
paullizer Jan 13, 2026
b20a5c7
removed debug test file
paullizer Jan 13, 2026
f70934c
Updated to v0.235.003
paullizer Jan 13, 2026
80ec215
Merge branch 'main' into Development
paullizer Jan 13, 2026
09fe817
Update python-syntax-check.yml
paullizer Jan 13, 2026
ce140f5
fixed disable group creation bug
paullizer Jan 15, 2026
4aac607
fixed bug not showing raw activity log for groups
paullizer Jan 15, 2026
9b9644e
fixed control center access to not require admin role when enabling c…
paullizer Jan 15, 2026
31ced93
fix documentation
paullizer Jan 15, 2026
e6f33c0
Update release_notes.md
paullizer Jan 15, 2026
919ed52
Update README.md
paullizer Jan 15, 2026
8878f1d
Merge branch 'main' into control-center-bug-fixes
paullizer Jan 15, 2026
646aaba
added click restrictions to top items in control center
paullizer Jan 15, 2026
2c2d92a
Merge pull request #598 from microsoft/control-center-bug-fixes
Bionic711 Jan 15, 2026
8af21bc
bug fix - fixed group member select after search, group member remova…
Xeelee33 Jan 16, 2026
3b0aa7f
Retention execution activity log (#600)
paullizer Jan 17, 2026
db25652
Merge branch 'Staging' into Development
paullizer Jan 17, 2026
305275d
Updated branch flow
paullizer Jan 17, 2026
7c04b7e
Merge pull request #608 from Xeelee33/bugfix/manage_group_errors
Bionic711 Jan 18, 2026
2ebfff6
added log_event to exceptions
paullizer Jan 20, 2026
5c58096
enforce-branch-flow
paullizer Jan 20, 2026
49c3a69
Merge branch 'Staging' into Development
paullizer Jan 20, 2026
875c338
v0.235.025 (#609)
paullizer Jan 20, 2026
d05f354
Updated searchUsers() function with inline and toast messages instead…
Xeelee33 Jan 21, 2026
3378bb9
Bugfix - removed hardcoded references to commerical cognitive service…
Xeelee33 Jan 21, 2026
db5a3f8
Support of Private Networking via Bicep / AZD (#617)
SteveCInVA Jan 21, 2026
467d7b9
Configure a user agreement that users must accept before uploading fi…
paullizer Jan 21, 2026
7525792
Merge branch 'Staging' into Development
paullizer Jan 21, 2026
74cccf4
Add default retention policy (#623)
paullizer Jan 22, 2026
ebe25ce
Web Search and other Misc items (#624)
Bionic711 Jan 22, 2026
6dbb107
Updated release notes
paullizer Jan 22, 2026
d0872e6
Create release-notes-check.yml
paullizer Jan 22, 2026
4e0a54b
added debug_print logging to web search
paullizer Jan 22, 2026
c44ca65
Updated the admin UI for web search
paullizer Jan 23, 2026
56212be
Added configuration setup to web search admin ui
paullizer Jan 23, 2026
98ac837
Added chat ui user message for web search
paullizer Jan 23, 2026
d7d9bc1
Updated release notes
paullizer Jan 23, 2026
d754af6
removed agent template gallery from release notes as its not in this …
paullizer Jan 23, 2026
efea5aa
removed broad ai foundry agent support release notes, as its not in t…
paullizer Jan 23, 2026
5cd3e1d
bugfix - fixed content safety client creation so that it creates prop…
Xeelee33 Jan 23, 2026
a639f0e
Merge pull request #632 from microsoft/v0.236.011-release-notes
Bionic711 Jan 23, 2026
258cd16
Merge pull request #636 from microsoft/Development
Bionic711 Jan 23, 2026
e20f549
pipeline trigger fix (#637)
Bionic711 Jan 23, 2026
24bca76
Merge pull request #638 from microsoft/Development
Bionic711 Jan 23, 2026
315f8fd
added events for buttons
paullizer Jan 24, 2026
1bb6863
updated the logging logic when running retention delete with archivin…
paullizer Jan 26, 2026
abe76ef
Development (#646)
paullizer Jan 26, 2026
b36325c
Development to Staging - v0.237.001 (#650)
paullizer Jan 26, 2026
42a7673
Merge branch 'main' into Staging
paullizer Jan 26, 2026
8f4ef13
Development to Staging - v0.237.003 (#655)
paullizer Jan 26, 2026
c4e04c1
Merge branch 'main' into Staging
paullizer Jan 26, 2026
9446de9
Development (#658)
paullizer Jan 26, 2026
468c7e5
Merge branch 'main' into Staging
paullizer Jan 26, 2026
6ed8e19
v0.237.005 (#673)
paullizer Jan 30, 2026
c95093d
Merge branch 'main' into Staging
paullizer Jan 30, 2026
53447c9
Development (#677)
paullizer Jan 30, 2026
12910ab
Merge branch 'main' into Staging
paullizer Jan 30, 2026
77b3385
v0.237.007 (#680)
paullizer Jan 30, 2026
4f296b5
Merge branch 'main' into Staging
paullizer Jan 30, 2026
3e208c7
v0.237.009 (#699)
paullizer Feb 9, 2026
6862f6e
Merge branch 'main' into Staging
paullizer Feb 9, 2026
19b37bd
Development (#710)
paullizer Feb 11, 2026
98e86b6
Merge branch 'main' into Staging
paullizer Feb 11, 2026
7a3d467
v0.238.024 - Development into Staging (#733)
paullizer Mar 2, 2026
6c3e292
Development (#754)
paullizer Mar 3, 2026
0b80ded
Development (#756)
paullizer Mar 3, 2026
6850326
Merge branch 'main' into Staging
paullizer Mar 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu
# Install the xz-utils package
RUN apt-get update && apt-get install -y xz-utils
20 changes: 14 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
//"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "3.11"
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest"
Expand All @@ -14,18 +21,16 @@
"installBicep": true,
"installUsingPython": true,
"version": "2.72.0",
"bicepVersion": "latest"
"bicepVersion": "latest"
},
"ghcr.io/devcontainers/features/terraform:1": {},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/azure/azure-dev/azd:latest": {}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install --user -r application/single_app/requirements.txt",
"postCreateCommand": "python3 -m venv .venv && .venv/bin/pip install -r application/single_app/requirements.txt",
// Configure tool-specific properties.
"customizations": {
"vscode": {
Expand All @@ -36,7 +41,10 @@
"ms-vscode.azurecli",
"HashiCorp.terraform",
"ms-vscode.powershell"
]
],
"settings": {
"python.defaultInterpreterPath": "${containerWorkspaceFolder}/.venv/bin/python"
}
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ flask_session
**/my_chart.png
**/sample_pie.csv
**/sample_stacked_column.csv
tmp**cwd
/tmp_images
nul
160 changes: 160 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# SimpleChat — Project Instructions

SimpleChat is a Flask web application using Azure Cosmos DB, Azure AI Search, and Azure OpenAI. It supports personal, group, and public workspaces for document management and AI-powered chat.

## Code Style — Python

- Start every file with a filename comment: `# filename.py`
- Place imports at the top, after the module docstring (exceptions must be documented)
- Use 4-space indentation, never tabs
- Use `log_event` from `functions_appinsights.py` for logging instead of `print()`

## Code Style — JavaScript

- Start every file with a filename comment: `// filename.js`
- Group imports at the top of the file (exceptions must be documented)
- Use 4-space indentation, never tabs
- Use camelCase for variables and functions: `myVariable`, `getUserData()`
- Use PascalCase for classes: `MyClass`
- Never use `display:none` in JavaScript; use Bootstrap's `d-none` class instead
- Use Bootstrap alert classes for notifications, not `alert()` calls

## Route Decorators — Swagger Security

**Every Flask route MUST include the `@swagger_route(security=get_auth_security())` decorator.**

- Import `swagger_route` and `get_auth_security` from `swagger_wrapper`
- Place `@swagger_route(security=get_auth_security())` immediately after the `@app.route(...)` decorator and before any authentication decorators (`@login_required`, `@user_required`, etc.)
- This applies to all new and existing routes — no exceptions

Correct pattern:
```python
from swagger_wrapper import swagger_route, get_auth_security

@app.route("/api/example", methods=["GET"])
@swagger_route(security=get_auth_security())
@login_required
@user_required
def example_route():
...
```

## Security — Settings Sanitization

**NEVER send raw settings or configuration data to the frontend without sanitization.**

- Always use `sanitize_settings_for_user()` from `functions_settings.py` before passing settings to `render_template()` or `jsonify()`
- **Exception**: Admin routes should NOT be sanitized (breaks admin features)
- Sanitization strips: API keys, Cosmos DB connection strings, Azure Search admin keys, Document Intelligence keys, authentication secrets, internal endpoint URLs, database credentials, and any field containing "key", "secret", "password", or "connection"

Correct pattern:
```python
from functions_settings import get_settings, sanitize_settings_for_user

settings = get_settings()
public_settings = sanitize_settings_for_user(settings)
return render_template('page.html', settings=public_settings)
```

## Version Management

- Version is stored in `config.py`: `VERSION = "X.XXX.XXX"`
- When incrementing, only change the third segment (e.g., `0.238.024` -> `0.238.025`)
- Include the current version in functional test file headers and documentation files

## Documentation Locations

- **Feature documentation**: `docs/explanation/features/[FEATURE_NAME].md` (uppercase with underscores)
- **Fix documentation**: `docs/explanation/fixes/[ISSUE_NAME]_FIX.md` (uppercase with underscores)
- **Release notes**: `docs/explanation/release_notes.md`

### Feature Documentation Structure

1. Header: title, overview, version, dependencies
2. Technical specifications: architecture, APIs, configuration, file structure
3. Usage instructions: enable/configure, workflows, examples
4. Testing and validation: coverage, performance, limitations

### Fix Documentation Structure

1. Header: title, issue description, root cause, version
2. Technical details: files modified, code changes, testing, impact
3. Validation: test results, before/after comparison

## Release Notes

After completing code changes, offer to update `docs/explanation/release_notes.md`.

- Add entries under the current version from `config.py`
- If the version was bumped, create a new section at the top: `### **(vX.XXX.XXX)**`
- Entry categories: **New Features**, **Bug Fixes**, **User Interface Enhancements**, **Breaking Changes**
- Format each entry with a bold title, bullet-point details, and a `(Ref: ...)` line referencing relevant files/concepts

## Functional Tests

- **Location**: `functional_tests/`
- **Naming**: `test_{feature_area}_{specific_test}.py` or `.js`
- **When to create**: bug fixes, new features, API changes, database migration, UI/UX changes, authentication/security changes

Every test file must include a version header:
```python
#!/usr/bin/env python3
"""
Functional test for [feature/fix name].
Version: [current version from config.py]
Implemented in: [version when fix/feature was added]
This test ensures that [description of what is being tested].
"""
```

Test template pattern:
```python
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

def test_primary_functionality():
"""Test the main functionality."""
print("Testing [Feature Name]...")
try:
# Setup, execute, validate, cleanup
print("Test passed!")
return True
except Exception as e:
print(f"Test failed: {e}")
import traceback
traceback.print_exc()
return False

if __name__ == "__main__":
success = test_primary_functionality()
sys.exit(0 if success else 1)
```



## Key Project Files

| File | Purpose |
|------|---------|
| `application/single_app/config.py` | App configuration and `VERSION` |
| `application/single_app/functions_settings.py` | `get_settings()`, `sanitize_settings_for_user()` |
| `application/single_app/functions_appinsights.py` | `log_event()` for logging |
| `application/single_app/functions_documents.py` | Document CRUD, chunk operations, tag management |
| `application/single_app/functions_group.py` | Group workspace operations |
| `application/single_app/functions_public_workspaces.py` | Public workspace operations |
| `application/single_app/route_backend_documents.py` | Personal document API routes |
| `application/single_app/route_backend_group_documents.py` | Group document API routes |
| `application/single_app/route_external_public_documents.py` | Public document API routes |
| `application/single_app/route_backend_chats.py` | Chat API routes and AI search integration |

## Frontend Architecture

- Templates: `application/single_app/templates/` (Jinja2 HTML)
- Static JS: `application/single_app/static/js/`
- `chat/` — Chat interface modules (chat-messages.js, chat-documents.js, chat-citations.js, chat-streaming.js)
- `workspace/` — Personal workspace (workspace-documents.js, workspace-tags.js)
- `public/` — Public workspace (public_workspace.js)
- Group workspace JS is inline in `templates/group_workspaces.html`
- Uses Bootstrap 5 for UI components and styling
4 changes: 4 additions & 0 deletions application/single_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
from route_backend_public_documents import *
from route_backend_public_prompts import *
from route_backend_user_agreement import register_route_backend_user_agreement
from route_backend_conversation_export import register_route_backend_conversation_export
from route_backend_speech import register_route_backend_speech
from route_backend_tts import register_route_backend_tts
from route_enhanced_citations import register_enhanced_citations_routes
Expand Down Expand Up @@ -628,6 +629,9 @@ def list_semantic_kernel_plugins():
# ------------------- API Public Workspaces Routes -------
register_route_backend_public_workspaces(app)

# ------------------- API Conversation Export Routes -----
register_route_backend_conversation_export(app)

# ------------------- API Public Documents Routes --------
register_route_backend_public_documents(app)

Expand Down
9 changes: 8 additions & 1 deletion application/single_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
import fitz # PyMuPDF
import math
import mimetypes
# Register font MIME types so Flask serves them correctly (required for
# X-Content-Type-Options: nosniff to not block Bootstrap Icons)
mimetypes.add_type('font/woff', '.woff')
mimetypes.add_type('font/woff2', '.woff2')
mimetypes.add_type('font/ttf', '.ttf')
mimetypes.add_type('font/otf', '.otf')
import openpyxl
import xlrd
import traceback
Expand Down Expand Up @@ -88,7 +94,7 @@
EXECUTOR_TYPE = 'thread'
EXECUTOR_MAX_WORKERS = 30
SESSION_TYPE = 'filesystem'
VERSION = "0.237.011"
VERSION = "0.239.001"

SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')

Expand Down Expand Up @@ -213,6 +219,7 @@ def get_allowed_extensions(enable_video=False, enable_audio=False):
elif AZURE_ENVIRONMENT == "custom":
resource_manager = CUSTOM_RESOURCE_MANAGER_URL_VALUE
authority = CUSTOM_IDENTITY_URL_VALUE
video_indexer_endpoint = os.getenv("CUSTOM_VIDEO_INDEXER_ENDPOINT", "https://api.videoindexer.ai")
credential_scopes=[resource_manager + "/.default"]
cognitive_services_scope = CUSTOM_COGNITIVE_SERVICES_URL_VALUE
search_resource_manager = CUSTOM_SEARCH_RESOURCE_MANAGER_URL_VALUE
Expand Down
54 changes: 54 additions & 0 deletions application/single_app/functions_activity_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,60 @@ def log_web_search_consent_acceptance(
debug_print(f"Error logging web search consent acceptance for user {user_id}: {str(e)}")


def log_index_auto_fix(
index_type: str,
missing_fields: list,
user_id: str = 'system',
admin_email: Optional[str] = None
) -> None:
"""
Log automatic Azure AI Search index field fixes to activity_logs and App Insights.

Args:
index_type (str): Type of index fixed ('user', 'group', or 'public').
missing_fields (list): List of field names that were added.
user_id (str, optional): User ID triggering the fix. Defaults to 'system'.
admin_email (str, optional): Admin email if triggered by admin.
"""
try:
activity_record = {
'id': str(uuid.uuid4()),
'activity_type': 'index_auto_fix',
'user_id': user_id,
'timestamp': datetime.utcnow().isoformat(),
'created_at': datetime.utcnow().isoformat(),
'index_type': index_type,
'missing_fields': missing_fields,
'fields_added': len(missing_fields),
'trigger': 'automatic',
'description': f"Automatically added {len(missing_fields)} missing field(s) to {index_type} index: {', '.join(missing_fields)}"
}

if admin_email:
activity_record['admin_email'] = admin_email

cosmos_activity_logs_container.create_item(body=activity_record)

log_event(
message=f"Auto-fixed {index_type} index: added {len(missing_fields)} field(s)",
extra=activity_record,
level=logging.INFO
)
debug_print(f"Logged index auto-fix for {index_type} index: {', '.join(missing_fields)}")

except Exception as e:
log_event(
message=f"Error logging index auto-fix: {str(e)}",
extra={
'user_id': user_id,
'index_type': index_type,
'error': str(e)
},
level=logging.ERROR
)
debug_print(f"Error logging index auto-fix for {index_type}: {str(e)}")


def log_document_upload(
user_id: str,
container_type: str,
Expand Down
25 changes: 24 additions & 1 deletion application/single_app/functions_conversation_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,30 @@ def collect_conversation_metadata(user_message, conversation_id, user_id, active
}
current_tags[semantic_key] = semantic_tag # Update the tags array
conversation_item['tags'] = list(current_tags.values())


# --- Scope Lock Logic ---
current_scope_locked = conversation_item.get('scope_locked')

if document_map:
# Always update locked_contexts when search results exist (even if unlocked)
# This ensures re-locking uses the most up-to-date workspace list
locked_set = set()
for ctx in conversation_item.get('context', []):
if ctx.get('scope') != 'model_knowledge' and ctx.get('type') in ('primary', 'secondary'):
locked_set.add((ctx['scope'], ctx.get('id')))

# Merge with existing locked_contexts
for ctx in conversation_item.get('locked_contexts', []):
locked_set.add((ctx.get('scope'), ctx.get('id')))

conversation_item['locked_contexts'] = [
{"scope": s, "id": i} for s, i in locked_set if s and i
]

# Only auto-lock the FIRST time (from null state)
if current_scope_locked is None:
conversation_item['scope_locked'] = True

return conversation_item


Expand Down
Loading
Loading